//+------------------------------------------------------------------+ #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 #property copyright "Ronald Raygun" #property link "http://Forex.offers4u.biz/support" // Oct 12,2009 - Added Partial close lot management - Matrixebiz extern string Remark1 = "== Main Settings =="; extern int MagicNumber = 27123; extern bool SignalsOnly = False; extern bool Alerts = False; extern bool SignalMail = False; extern bool PlaySounds = False; extern bool ECNBroker = False; extern int PipBuffer = 0; extern bool EachTickMode = True; extern double Lots = 1.0; extern bool MoneyManagement = False; extern int Risk = 0; extern int Slippage = 5; extern bool UseStopLoss = True; extern int StopLoss = 100; extern bool UseTakeProfit = True; extern int TakeProfit = 100; extern bool UseTrailingStop = False; extern int TrailingStop = 30; extern bool MoveStopOnce = False; extern int MoveStopWhenPrice = 50; extern int MoveStopTo = 1; extern string Remark2 = ""; extern string Remark3 = "== Zig Zag Settings =="; extern int ExtDepth=2; extern int ExtDeviation=1; extern int ExtBackstep=1; extern string Remark4 = "== Partial close lot management =="; extern string Remark5 = "== Two options for Partial closing; =="; extern string Remark6 = "== Close Percent of Initial Lotsize =="; extern string Remark7 = "== or Close Percent of Remaining Lotsize =="; extern bool Use_Partial_Close = True; extern bool CloseFromInitialLotsize = True; extern int PipsTarget_1 = 10; extern double CloseLotsPercentage_1 = 10.0; extern int Move_SL_1 = 1; extern int PipsTarget_2 = 20; extern double CloseLotsPercentage_2 = 10.0; extern int Move_SL_2 = 0; extern int PipsTarget_3 = 40; extern double CloseLotsPercentage_3 = 10.0; extern int Move_SL_3 = 0; extern int PipsTarget_4 = 60; extern double CloseLotsPercentage_4 = 10.0; extern int Move_SL_4 = 0; extern string Remark8 = "== Partial close lot management END =="; int MaxTradesPerBar = 1; int CurrentTrades = 0; int TradeBars = 0; //Version 2.01 int OpenBarCount; int CloseBarCount; string BrokerType = "4-Digit Broker"; double BrokerMultiplier = 1; int Current; bool TickCheck = False; int Dig = 1; double PC1,PC2,PC3,PC4,PC1a,PC2a,PC3a; string OrderCommentSell; string OrderCommentBuy; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { OpenBarCount = Bars; CloseBarCount = Bars; if(Digits == 3 || Digits == 5) { BrokerType = "5-Digit Broker"; BrokerMultiplier = 10; } if (MarketInfo(Symbol(), MODE_MINLOT) == 0.01) Dig = 2; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (!IsExpertEnabled()) { Alert("You did not allow your expert to run live, change your settings and apply the expert again"); return (0); } int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; double PotentialStopLoss; double BEven; double TrailStop; OrderCommentSell = "123 Sell(#" + MagicNumber + ")"; OrderCommentBuy = "123 Buy(#" + MagicNumber + ")"; if (EachTickMode && Bars != CloseBarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //Money Management sequence if (MoneyManagement) { if (Risk<1 || Risk>100) { Comment("Invalid Risk Value."); return(0); } else { Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*BrokerMultiplier*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT); } } if(CloseFromInitialLotsize==False){ PC1 = NormalizeDouble((Lots * CloseLotsPercentage_1) / 100.0, Dig); PC1a= NormalizeDouble((Lots - PC1), Dig); PC2 = NormalizeDouble((PC1a * CloseLotsPercentage_2) / 100.0, Dig); PC2a= NormalizeDouble((PC1a - PC2), Dig); PC3 = NormalizeDouble((PC2a * CloseLotsPercentage_3) / 100.0, Dig); PC3a= NormalizeDouble((PC2a - PC3), Dig); PC4 = NormalizeDouble((PC3a * CloseLotsPercentage_4) / 100.0, Dig);} if(CloseFromInitialLotsize==True){ PC1 = NormalizeDouble((Lots * CloseLotsPercentage_1) / 100.0, Dig); PC1a= NormalizeDouble((Lots - PC1), Dig); PC2 = NormalizeDouble((Lots * CloseLotsPercentage_2) / 100.0, Dig); PC2a= NormalizeDouble((Lots - (PC2+PC1)), Dig); PC3 = NormalizeDouble((Lots * CloseLotsPercentage_3) / 100.0, Dig); PC3a= NormalizeDouble((Lots - (PC3+PC2+PC1)), Dig); PC4 = NormalizeDouble((Lots * CloseLotsPercentage_4) / 100.0, Dig);} if (Use_Partial_Close) ManageOrders(); //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ if(TradeBars != Bars) { TradeBars = Bars; CurrentTrades = 0; } int PointShift = 1; string ConfirmedPoint = "Not Found"; string PointShiftDirection = "None"; while (ConfirmedPoint != "Found") { double ZZ = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift); if(iHigh(NULL, 0, PointShift) == ZZ || iLow(NULL, 0, PointShift) == ZZ) { ConfirmedPoint = "Found"; if(iHigh(NULL, 0, PointShift) == ZZ) { PointShiftDirection = "High"; break; } if(iLow(NULL, 0, PointShift) == ZZ) { PointShiftDirection = "Low"; break; } } PointShift++; } int PointShift2 = PointShift; string ConfirmedPoint2 = "Not Found"; while (ConfirmedPoint2 != "Found") { double ZZ2 = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift2); if(iHigh(NULL, 0, PointShift2) == ZZ2 && PointShiftDirection == "Low") { ConfirmedPoint2 = "Found"; break; } if(iLow(NULL, 0, PointShift2) == ZZ2 && PointShiftDirection == "High") { ConfirmedPoint2 = "Found"; break; } PointShift2++; } int PointShift3 = PointShift2; string ConfirmedPoint3 = "Not Found"; while (ConfirmedPoint3 != "Found") { double ZZ3 = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift3); if(iHigh(NULL, 0, PointShift3) == ZZ3 && PointShiftDirection == "High") { ConfirmedPoint3 = "Found"; break; } if(iLow(NULL, 0, PointShift3) == ZZ3 && PointShiftDirection == "Low") { ConfirmedPoint3 = "Found"; break; } PointShift3++; } double ZZZ1 = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift); double ZZZ2 = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift2); double ZZZ3 = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, PointShift3); double LongEntry = 0; double ShortEntry = 0; if(ZZZ3 < ZZZ2 && ZZZ2 > ZZZ1 && ZZZ1 > ZZZ3) { LongEntry = ZZZ2 + (PipBuffer * Point); ShortEntry = 0; } if(ZZZ3 > ZZZ2 && ZZZ2 < ZZZ1 && ZZZ1 < ZZZ3) { LongEntry = 0; ShortEntry = ZZZ2 - (PipBuffer * Point); } string TradeTrigger = "None"; if(CurrentTrades < MaxTradesPerBar && iOpen(NULL, 0, Current + 0) < LongEntry && iClose(NULL, 0, Current + 0) >= LongEntry) TradeTrigger = "Open Long"; if(CurrentTrades < MaxTradesPerBar && iOpen(NULL, 0, Current + 0) > ShortEntry && iClose(NULL, 0, Current + 0) <= ShortEntry) TradeTrigger = "Open Short"; Comment("Broker Type: ", BrokerType, "\n", "Long Entry: ", LongEntry, "\n", "Short Entry: ", ShortEntry, "\n", "Trade Trigger: ", TradeTrigger // "Lots to close - PC1: ",PC1, " PC2: ", PC2, " PC3: ",PC3, "\n", // "Remainder Lots after PC1: ", PC1a, " Remainder Lots after PC2: ", PC2a ); ObjectDelete("Point1"); ObjectCreate("Point1", OBJ_VLINE, 0, Time[PointShift], 0); ObjectSet("Point1", OBJPROP_COLOR, Aqua); ObjectSet("Point1", OBJPROP_STYLE, STYLE_DASH); ObjectSet("Point1", OBJPROP_BACK, True); ObjectDelete("Point2"); ObjectCreate("Point2", OBJ_VLINE, 0, Time[PointShift2], 0); ObjectSet("Point2", OBJPROP_COLOR, Aqua); ObjectSet("Point2", OBJPROP_STYLE, STYLE_DASHDOT); ObjectSet("Point2", OBJPROP_BACK, True); ObjectDelete("Point3"); ObjectCreate("Point3", OBJ_VLINE, 0, Time[PointShift3], 0); ObjectSet("Point3", OBJPROP_COLOR, Aqua); ObjectSet("Point3", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSet("Point3", OBJPROP_BACK, True); ObjectDelete("LongEntry"); ObjectCreate("LongEntry", OBJ_HLINE, 0, 0, LongEntry); ObjectSet("LongEntry", OBJPROP_COLOR, Lime); ObjectSet("LongEntry", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSet("LongEntry", OBJPROP_BACK, True); ObjectDelete("ShortEntry"); ObjectCreate("ShortEntry", OBJ_HLINE, 0, 0, ShortEntry); ObjectSet("ShortEntry", OBJPROP_COLOR, Red); ObjectSet("ShortEntry", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSet("ShortEntry", OBJPROP_BACK, True); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != CloseBarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) CloseBarCount = Bars; IsTrade = False; continue; } PotentialStopLoss = OrderStopLoss(); BEven = BreakEvenValue(MoveStopOnce, OrderTicket(), MoveStopTo, MoveStopWhenPrice); TrailStop = TrailingStopValue(UseTrailingStop, OrderTicket(), TrailingStop); if(BEven > PotentialStopLoss && BEven != 0) PotentialStopLoss = BEven; if(TrailStop > PotentialStopLoss && TrailStop != 0) PotentialStopLoss = TrailStop; if(PotentialStopLoss != OrderStopLoss()) OrderModify(OrderTicket(),OrderOpenPrice(), PotentialStopLoss, OrderTakeProfit(), 0, MediumSeaGreen); } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != CloseBarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) CloseBarCount = Bars; IsTrade = False; continue; } PotentialStopLoss = OrderStopLoss(); BEven = BreakEvenValue(MoveStopOnce, OrderTicket(), MoveStopTo, MoveStopWhenPrice); TrailStop = TrailingStopValue(UseTrailingStop, OrderTicket(), TrailingStop); if((BEven < PotentialStopLoss && BEven != 0) || (PotentialStopLoss == 0)) PotentialStopLoss = BEven; if((TrailStop < PotentialStopLoss && TrailStop != 0) || (PotentialStopLoss == 0)) PotentialStopLoss = TrailStop; if(PotentialStopLoss != OrderStopLoss() || OrderStopLoss() == 0) OrderModify(OrderTicket(),OrderOpenPrice(), PotentialStopLoss, OrderTakeProfit(), 0, DarkOrange); } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry) | //+------------------------------------------------------------------+ if(TradeTrigger == "Open Long") Order = SIGNAL_BUY; if(TradeTrigger == "Open Short") Order = SIGNAL_SELL; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ IsTrade = False; //Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != OpenBarCount)))) { if(SignalsOnly) { if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal"); if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal"); if (PlaySounds) PlaySound("alert.wav"); } if(!IsTrade && !SignalsOnly) { //Check free margin if (AccountFreeMargin() < (1 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; if(ECNBroker) Ticket = OrderModify(OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, OrderCommentBuy, MagicNumber, 0, DodgerBlue), OrderOpenPrice(), StopLossLevel, TakeProfitLevel, 0, CLR_NONE); if(!ECNBroker) Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, OrderCommentBuy, MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal"); if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + "Buy Signal"); if (PlaySounds) PlaySound("alert.wav"); CurrentTrades++; } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) OpenBarCount = Bars; return(0); } } //Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != OpenBarCount)))) { if(SignalsOnly) { if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); if (PlaySounds) PlaySound("alert.wav"); } if(!IsTrade && !SignalsOnly) { //Check free margin if (AccountFreeMargin() < (1 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; if(ECNBroker) Ticket = OrderModify(OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, OrderCommentSell, MagicNumber, 0, DeepPink), OrderOpenPrice(), StopLossLevel, TakeProfitLevel, 0, CLR_NONE); if(!ECNBroker) Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, OrderCommentSell, MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); if (Alerts) Alert("[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); if (PlaySounds) PlaySound("alert.wav"); CurrentTrades++; } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) OpenBarCount = Bars; return(0); } } if (!EachTickMode) CloseBarCount = Bars; return(0); } double BreakEvenValue (bool Decision, int OrderTicketNum, int MoveStopTo, int MoveStopwhenPrice) { //Select the appropriate order ticket OrderSelect(OrderTicketNum, SELECT_BY_TICKET, MODE_TRADES); //If the Order is a BUY order... if(OrderType() == OP_BUY) { //Check if the user wants to use the MoveStopOnce function and did it correctly if(Decision && MoveStopWhenPrice > 0) { //Check if the trade is above the required profit threshold if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) { //Return the value of the stoploss return(OrderOpenPrice() + Point * MoveStopTo); } } } //If the Order is a SELL order... if(OrderType() == OP_SELL) { //Check if the user wants to use the MoveStopOnce function and did it correctly if(Decision && MoveStopWhenPrice > 0) { //Check if the trade is above the required profit threshold if(OrderOpenPrice() - Ask >= Point * MoveStopWhenPrice) { //Return the value of the stoploss return(OrderOpenPrice() - Point * MoveStopTo); } } } if(OrderType() != OP_BUY || OrderType() != OP_SELL) return(0); } double TrailingStopValue (bool Decision, int OrderTicketNum, int TrailingStop) { //Select the appropriate order ticket OrderSelect(OrderTicketNum, SELECT_BY_TICKET, MODE_TRADES); //If the Order is a BUY order... if(OrderType() == OP_BUY) { //Check if the user wants to use teh Trailingstop function and did it correctly if(Decision && TrailingStop > 0) { //Check to see that the profit threshold is met if(Bid - OrderOpenPrice() > Point * TrailingStop) { //Return the value of the potential stoploss return(Bid - Point * TrailingStop); } } } //If the Order is a SELL order... if(OrderType() == OP_SELL) { //Check if the user wants to use teh Trailingstop function and did it correctly if(Decision && TrailingStop > 0) { //Check to see that the profit threshold is met if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { //Return the value of the potential stoploss return(Ask + Point * TrailingStop); } } } //If the trade is not the right order type, give a stoploss of 0 if(OrderType() != OP_BUY || OrderType() != OP_SELL) return(0); } void ManageOrders(){ for (int i=0;i= OrderOpenPrice() + PipsTarget_1 * Point && OrderLots() == Lots ) { RefreshRates(); if (Move_SL_1 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Move_SL_1 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC1, MarketInfo(OrderSymbol(), MODE_BID), 0, CLR_NONE); }} if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Ask <= OrderOpenPrice() - PipsTarget_1 * Point && OrderLots() == Lots ) { RefreshRates(); if (Move_SL_1 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Move_SL_1 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC1, MarketInfo(OrderSymbol(), MODE_ASK), 0, CLR_NONE); }} if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Bid >= OrderOpenPrice() + PipsTarget_2 * Point && OrderLots() == PC1a ) { RefreshRates(); if (Move_SL_2 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Move_SL_2 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC2, MarketInfo(OrderSymbol(), MODE_BID), 0, CLR_NONE); }} if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Ask <= OrderOpenPrice() - PipsTarget_2 * Point && OrderLots() == PC1a ) { RefreshRates(); if (Move_SL_2 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Move_SL_2 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC2, MarketInfo(OrderSymbol(), MODE_ASK), 0, CLR_NONE); }} if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Bid >= OrderOpenPrice() + PipsTarget_3 * Point && OrderLots() == PC2a ) { RefreshRates(); if (Move_SL_3 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Move_SL_3 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC3, MarketInfo(OrderSymbol(), MODE_BID), 0, CLR_NONE); }} if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Ask <= OrderOpenPrice() - PipsTarget_3 * Point && OrderLots() == PC2a ) { RefreshRates(); if (Move_SL_3 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Move_SL_3 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC3, MarketInfo(OrderSymbol(), MODE_ASK), 0, CLR_NONE); }} if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Bid >= OrderOpenPrice() + PipsTarget_4 * Point && OrderLots() == PC3a ) { RefreshRates(); if (Move_SL_4 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Move_SL_4 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC4, MarketInfo(OrderSymbol(), MODE_BID), 0, CLR_NONE); }} if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if (Ask <= OrderOpenPrice() - PipsTarget_4 * Point && OrderLots() == PC3a ) { RefreshRates(); if (Move_SL_4 > 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Move_SL_4 * Point, OrderTakeProfit(), 0, CLR_NONE); RefreshRates(); OrderClose(OrderTicket(), PC4, MarketInfo(OrderSymbol(), MODE_ASK), 0, CLR_NONE); }} }}