/*[[ Name := Your_Choice_Hourly_Breakout_v4 Author := Copyright © 2005, David W Honeywell Link := DavidHon@msn.com Lots := 0.10 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ /*- Terms Of Use = By Entering Any Value Other Than 0 (zero) in the "IAcceptTerms" definition , the user "You" , "Accept Full Unlimited Responsibility Of The Operation And Results Obtained From The Use Of This Expert Advisor , And/Or Any Variation Of Said Expert Advisor That You Have Created" . "Use At Your Own Risk" */ Define: IAcceptTerms(0); // Default=0 If (IAcceptTerms==0) Then Exit; If (IAcceptTerms<>0) Then { //- This version will operate on multiple currency pairs //- Pip buffer of currency pair = spread plus DistFromHL +/- of PeriodsLookback HH/LL If TimeYear(Time)<2006 Then Exit; Define: ShowComments(1); // 1 = Yes , 0 = No . Variables: cnt(0), opentrades(0), bought(0), sold(0), buyorder(0), sellorder(0), limbuy(0), sellim(0), MaxProfit(0), MaxLoss(0), FrstSessHour(0), SecondSessHour(0), LessThanMinute(0), PeriodsLookback(0), DistFromHL(0), CnclPndngIfActvTrd(0), DeleteOrderAfterMnts(0), DltAftr_Mnts(0), AdjustToBreakeven(0), Adj2B.E.Aftr_Pips(0), DynamicProfit(0), ProfitAtrPrds(0), FactorProf(0), AtrTrailing(0), AtrPeriods(0), TrailAt_TimesATR(0), StandardTrailAmt(0), sellcrumbs(0), buycrumbs(0), spread(0), buyStop(0), sellStop(0), pips(0), stops(0), closebuyorder(0), closesellorder(0); //- Check for open trades and pending orders per symbol ---------------------------------------------------- opentrades=0; bought=0; sold=0; buyorder=0; sellorder=0; limbuy=0; sellim=0; For cnt=1 To TotalTrades { If (OrderValue(cnt,VAL_SYMBOL)==Symbol) Then { opentrades++; }; }; For cnt=1 To TotalTrades { If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_BUY)) Then { bought++; }; If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_SELL)) Then { sold++; }; If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_BUYSTOP)) Then { buyorder++; }; If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_SELLSTOP)) Then { sellorder++; }; If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_BUYLIMIT)) Then { limbuy++; }; If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_SELLLIMIT)) Then { sellim++; }; }; If IsIndirect(Symbol) Then Exit; //- Set Variable Values ------------------------------------------------------------------------------------ /* Adjust These Values In The Switch Symbol Section Located Below ------------------------------------------------------------------------------------------------------------ MaxProfit TakeProfit Amount (pips) MaxLoss StopLoss Amount (pips) ------------------------------------------------------------------------------------------------------------ FrstSessHour The Chart Hour You Want The Orders To Be Set And/Or Modified SecondSessHour The Chart Hour You Want The Orders To Be Set And/Or Modified LessThanMinute Orders are set during these minutes-1 ------------------------------------------------------------------------------------------------------------ PeriodsLookback Chart Periods back to monitor HH/LL DistFromHL Order placement pip buffer ------------------------------------------------------------------------------------------------------------ CnclPndngIfActvTrd Set this to 1 if you want pending order cancelled after 1 pending becomes active ------------------------------------------------------------------------------------------------------------ DeleteOrderAfterMnts Set this to 1 if you want the orders deleted using DltAftr_Mnts Set to 0 if you do Not want to delete orders after (n) minutes (DltAftr_Mnts) DltAftr_Mnts Delete Pending Orders After This Many Minutes ------------------------------------------------------------------------------------------------------------ AdjustToBreakeven Set this to 1 if you want to adjust stop to breakeven after (n) pips profit Set to 0 if you do Not want to adjust stop to breakeven after (n) pips profit Adj2B.E.Aftr_Pips Adjust StopLoss to breakeven after this many pips profit ------------------------------------------------------------------------------------------------------------ DynamicProfit Set this to 1 if you want to use the ATR as a TakeProfit ProfitAtrPrds ATR Periods to use for the Atr TakeProfit (DynamicProfit) FactorProf Multiple of the ATR reading to calculate the final TakeProfit (DynamicProfit) amount ------------------------------------------------------------------------------------------------------------ AtrTrailing Set this to 1 if you want to use the ATR TrailingStop Set to 0 if you do not want to use the ATR TrailingStop When Set to 0 , the TrailingStop will Default to a standard TrailingStop AtrPeriods Atr Periods to calculate the ATR TrailingStop TrailAt_TimesATR Multiple of the ATR reading to calculate the final TrailingStop amount ------------------------------------------------------------------------------------------------------------ StandardTrailAmt Set this as you would for a standard TrailingStop If AtrTrailing is 0 , this TrailingStop amount Will Be Used ------------------------------------------------------------------------------------------------------------ */ ///////////////////////////////////////////////////// // Set Each Pairs Settings // Whatever You Like For That Pair ///////////////////////////////////////////////////// Switch Symbol { Case "USDCHF": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "GBPUSD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "USDJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=20; SecondSessHour=0; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURUSD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "AUDUSD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "USDCAD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURGBP": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURCHF": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=20; SecondSessHour=0; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "GBPJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=20; SecondSessHour=0; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "NZDUSD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "GBPCHF": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "CHFJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=20; SecondSessHour=0; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "AUDJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURCAD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "EURAUD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "AUDCAD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "AUDNZD": MaxProfit=666; MaxLoss=125; FrstSessHour=8; SecondSessHour=12; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Case "NZDJPY": MaxProfit=666; MaxLoss=125; FrstSessHour=20; SecondSessHour=0; LessThanMinute=5; PeriodsLookback=13; DistFromHL=5; CnclPndngIfActvTrd=0; DeleteOrderAfterMnts=1; DltAftr_Mnts=235; AdjustToBreakeven=0; Adj2B.E.Aftr_Pips=27; DynamicProfit=1; ProfitAtrPrds=2; FactorProf=1.75; AtrTrailing=1; AtrPeriods=2; TrailAt_TimesATR=1.5; StandardTrailAmt=55; Break; Default:Exit; }; For cnt=1 to TotalTrades { If (opentrades==0) Then { sellcrumbs=0; buycrumbs=0; }; If ((Ord(cnt,Val_Symbol)==Symbol) and (Ord(cnt,VAL_TYPE)==OP_SELL)) Then { sellcrumbs=(Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE)); }; If ((Ord(cnt,Val_Symbol)==Symbol) and (Ord(cnt,VAL_TYPE)==OP_BUY)) Then { buycrumbs=(Ord(cnt,VAL_CLOSEPRICE)-Ord(cnt,VAL_OPENPRICE)); }; }; spread = (Ask-Bid); // currency spread is added as another pip buffer to HH/LL buystop = (High[Highest(MODE_HIGH,PeriodsLookback,PeriodsLookback)]+(DistFromHL*point))+spread; sellstop = (Low[Lowest(MODE_LOW,PeriodsLookback,PeriodsLookback)]-(DistFromHL*point))-spread; pips = (1 * Point) + (iATR(ProfitAtrPrds,0) * FactorProf); stops = (1 * Point) + (iATR(AtrPeriods,0) * TrailAt_TimesATR); //- Place Comments on Chart Window ------------------------------------------------------------------------- If (ShowComments <> 0) then { Comment("\n"," Chart Hour: = ",Hour," , FrstSessHour: = ",FrstSessHour, " , SecondSessHour: = ",SecondSessHour, "\n", "\n"," Open Buys: = ",bought," , Open Sells: = ",sold, "\n"," Buy Stops: = ",buyorder," , Sell Stops: = ",sellorder, "\n"," Buy Limits: = ",limbuy," , Sell Limits: = ",sellim, "\n"," All Positions: = ",Opentrades, "\n", "\n"," Symbol: = ",Symbol," , MaxProfit: = ",MaxProfit," , MaxLoss: = ",MaxLoss, "\n", "\n"," PeriodsLookback: = ",PeriodsLookback, "\n", "\n"," DistFromHL: = ",DistFromHL, "\n"," Highest High of PeriodsLookback + Spread + DistFromHL: = ",buystop, "\n"," Lowest Low of PeriodsLookback - Spread - DistFromHL: = ",sellstop, "\n", "\n"," CnclPndngIfActvTrd: = ",CnclPndngIfActvTrd, "\n", "\n"," DeleteOrderAfterMnts: = ",DeleteOrderAfterMnts," DltAftr_Mnts: = ",DltAftr_Mnts, "\n", "\n"," AdjustToBreakeven: = ",AdjustToBreakeven," , Adj2B.E.Aftr_Pips: = ",Adj2B.E.Aftr_Pips, "\n", "\n"," DynamicProfit: = ",DynamicProfit, "\n"," ProfitAtrPrds: = ",ProfitAtrPrds," , FactorProf: = ",FactorProf, "\n"," ATR Profit Amount: = ",pips, "\n", "\n"," AtrTrailing: = ",ATrTrailing, "\n"," AtrPeriods: = ",AtrPeriods," , TrailAt_TimesATR: = ",TrailAt_TimesATR, "\n"," Atr TrailingStop Amount: = ",stops, "\n", "\n"," StandardTrailAmt: = ",StandardTrailAmt); }; If (ShowComments == 0) then { Comment();}; //- Set BuyStop and SellStop ------------------------------------------------------------------------------- If ((Hour==FrstSessHour) and (Minutebuystop+(1*Point)) Then { ModifyOrder(OrderValue(cnt,VAL_TICKET),buystop,(buystop)-MaxLoss*Point,(buystop)+MaxProfit*Point, Cyan); Exit; }; }; If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (Hour==FrstSessHour) and (Ord(cnt,VAL_TYPE)==OP_SELLSTOP)) Then { If (OrderValue(cnt,VAL_OPENPRICE)buystop+(1*Point)) Then { ModifyOrder(OrderValue(cnt,VAL_TICKET),buystop,(buystop)-MaxLoss*Point,(buystop)+MaxProfit*Point, Cyan); Exit; }; }; If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (Hour==SecondSessHour) and (Ord(cnt,VAL_TYPE)==OP_SELLSTOP)) Then { If (OrderValue(cnt,VAL_OPENPRICE)(DltAftr_Mnts*60) Then { DeleteOrder(OrderValue(cnt,VAL_TICKET),LightGoldenrod); Exit; }; }; }; //- Adjust StopLoss to breakeven if in profit more than Adj2B.E.Aftr_Pips ---------------------------------- For cnt = 1 To TotalTrades { If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (AdjustToBreakeven==1) and (Ord(cnt,VAL_TYPE)==OP_BUY)) Then { If (Ord(cnt,VAL_STOPLOSS)==(Ord(cnt,VAL_OPENPRICE)-MaxLoss*Point)) and (Ord(cnt,VAL_CLOSEPRICE)-(Ord(cnt,VAL_OPENPRICE))>Adj2B.E.Aftr_Pips*Point) Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_CLOSEPRICE)-(Adj2B.E.Aftr_Pips*Point),Ord(cnt,VAL_TAKEPROFIT),Cyan); Exit; }; }; If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (AdjustToBreakeven==1) and (Ord(cnt,VAL_TYPE)==OP_SELL)) Then { If (Ord(cnt,VAL_STOPLOSS)==(Ord(cnt,VAL_OPENPRICE)+MaxLoss*Point)) and (Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE)>Adj2B.E.Aftr_Pips*Point) Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_CLOSEPRICE)+(Adj2B.E.Aftr_Pips*Point),Ord(cnt,VAL_TAKEPROFIT),Fuchsia); Exit; }; }; }; //- ATR TP ------------------------------------------------------------------------------------------------- For cnt=1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (DynamicProfit==1) and (Ord(cnt,VAL_TYPE)==OP_SELL)) Then { If (sellcrumbs > pips) Then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS), OrderValue(cnt,VAL_CLOSEPRICE),0,SandyBrown); Exit; }; }; If ((Ord(cnt,Val_Symbol)==Symbol) and (DynamicProfit==1) and (Ord(cnt,VAL_TYPE)==OP_BUY)) Then { If (buycrumbs > pips) Then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS), OrderValue(cnt,VAL_CLOSEPRICE),0,SandyBrown); Exit; }; }; }; //- ATR TrailingStop --------------------------------------------------------------------------------------- For cnt = 1 To TotalTrades { If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (AtrTrailing==1) and (Ord(cnt,VAL_TYPE)==OP_BUY)) Then { If ((Ord(cnt,VAL_CLOSEPRICE)-OrderValue(cnt,VAL_OPENPRICE))>stops and (Ord(cnt,VAL_CLOSEPRICE)-stops)>Ord(cnt,VAL_STOPLOSS)) or (Ord(cnt,VAL_STOPLOSS)==0) Then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), (Ord(cnt,VAL_CLOSEPRICE)-stops),OrderValue(cnt,VAL_TAKEPROFIT),White); Exit; }; }; If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (AtrTrailing==1) and (Ord(cnt,VAL_TYPE)==OP_SELL)) Then { If ((OrderValue(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))>stops and (Ord(cnt,VAL_CLOSEPRICE)+stops)StandardTrailAmt*Point and (Ord(cnt,VAL_CLOSEPRICE)-StandardTrailAmt*Point)>Ord(cnt,VAL_STOPLOSS)) or (Ord(cnt,VAL_STOPLOSS)==0) Then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), (Ord(cnt,VAL_CLOSEPRICE)-StandardTrailAmt*Point),OrderValue(cnt,VAL_TAKEPROFIT),White); Exit; }; }; If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (AtrTrailing==0) and (Ord(cnt,VAL_TYPE)==OP_SELL)) Then { If ((OrderValue(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))>StandardTrailAmt*Point and (Ord(cnt,VAL_CLOSEPRICE)+StandardTrailAmt*Point)