/*[[ Name := Your_Choice_Hourly_Breakout_v4e Author := Copyright © 2005, David W Honeywell Link := transport.david@gmail.com Lots := 0.10 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ /*- Terms Of Use = If Any Value Other Than 0 (zero) is in the "IAcceptTerms" defined value , "You" ( the user ) , "Accept Full Unlimited Responsibility Of The Operation And Results Obtained From The Use Of This Expert Advisor" , "Use At Your Own Risk" . */ Define: IAcceptTerms(1); // Default=0 If (IAcceptTerms==0) Then Exit; If (IAcceptTerms<>0) Then { //- This version will operate on multiple currency pairs Define: ShowComments(1); // 1 = Yes , 0 = No . //- Set Defined Values ------------------------------------------------------------------------------------ /* Adjust These Values To Your Liking ------------------------------------------------------------------------------------------------------------ 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 ------------------------------------------------------------------------------------------------------------ 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 ------------------------------------------------------------------------------------------------------------ If AtrTrailing is 0 , this TrailingStop amount Will Be Used StandardTrailAmt Set this as you would for a standard TrailingStop ------------------------------------------------------------------------------------------------------------ */ Defines: FrstSessHour(8), SecondSessHour(12), MaxProfit(125), MaxLoss(125), PeriodsLookback(14), CnclPndngIfActvTrd(1), DeleteOrderAfterMnts(1), DltAftr_Mnts(240), AdjustToBreakeven(0), Adj2B.E.Aftr_Pips(27), DynamicProfit(1), ProfitAtrPrds(2), FactorProf(1.75), AtrTrailing(1), AtrPeriods(2), TrailAt_TimesATR(1.5), StandardTrailAmt(62); If TimeYear(Time)<2006 Then Exit; If IsIndirect(Symbol) Then Exit; Variables: cnt(0), opentrades(0), bought(0), sold(0), buyorder(0), sellorder(0), limbuy(0), sellim(0), spread(0), rds(0), buyStop(0), sellStop(0), pips(0), stops(0), closebuyorder(0), closesellorder(0), allow(0), byok(0), slok(0), psld(0), pbht(0), deleteall(0); Variables: aa(0),ab(0),ac(0),ad(0),ae(0),af(0),ag(0),ah(0),ai(0),aj(0),ak(0),al(0),am(0),ao(0),ap(0),aq(0),ar(0),as(0),au(0),av(0), ba(0),bb(0),bc(0),bd(0),be(0),bf(0),bg(0),bh(0),bi(0),bj(0),bk(0),bl(0),bm(0),bo(0),bp(0),bq(0),br(0),bs(0),bu(0),bv(0), ca(0),cb(0),cc(0),cd(0),ce(0),cf(0),cg(0),ch(0),ci(0),cj(0),ck(0),cl(0),cm(0),co(0),cp(0),cq(0),cr(0),cs(0),cu(0),cv(0), da(0),db(0),dc(0),dd(0),de(0),df(0),dg(0),dh(0),di(0),dj(0),dk(0),dl(0),dm(0),do(0),dp(0),dq(0),dr(0),ds(0),du(0),dv(0), ea(0),eb(0),ec(0),ed(0),ee(0),ef(0),eg(0),eh(0),ei(0),ej(0),ek(0),el(0),em(0),eo(0),ep(0),eq(0),er(0),es(0),eu(0),ev(0), fa(0),fb(0),fc(0),fd(0),fe(0),ff(0),fg(0),fh(0),fi(0),fj(0),fk(0),fl(0),fm(0),fo(0),fp(0),fq(0),fr(0),fs(0),fu(0),fv(0), ga(0),gb(0),gc(0),gd(0),ge(0),gf(0),gg(0),gh(0),gi(0),gj(0),gk(0),gl(0),gm(0),go(0),gp(0),gq(0),gr(0),gs(0),gu(0),gv(0), ha(0),hb(0),hc(0),hd(0),he(0),hf(0),hg(0),hh(0),hi(0),hj(0),hk(0),hl(0),hm(0),ho(0),hp(0),hq(0),hr(0),hs(0),hu(0),hv(0), ja(0),jb(0),jc(0),jd(0),je(0),jf(0),jg(0),jh(0),ji(0),jj(0),jk(0),jl(0),jm(0),jo(0),jp(0),jq(0),jr(0),js(0),ju(0),jv(0), ka(0),kb(0),kc(0),kd(0),ke(0),kf(0),kg(0),kh(0),ki(0),kj(0),kk(0),kl(0),km(0),ko(0),kp(0),kq(0),kr(0),ks(0),ku(0),kv(0), hidiff(0),lowdiff(0),rdhidiff(0),rdlwdiff(0); //- Check for open trades and pending orders per symbol ---------------------------------------------------- opentrades=0; bought=0; sold=0; buyorder=0; sellorder=0; limbuy=0; sellim=0; closebuyorder=0; closesellorder=0; For cnt=1 To TotalTrades { If (OrderValue(cnt,VAL_SYMBOL)==Symbol) Then { opentrades++; }; 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++; }; }; //- Reset allow , deleteall ------------------------------------------------------------------ If ((allow != T[0]) and (Hour==FrstSessHour or Hour == SecondSessHour)) then { deleteall = 10; byok = -10; slok = -10; allow = T[0]; }; //- Reset deleteall , byok , slok----------------------------------------------------- If ((buyorder == 0) and (sellorder == 0)) Then { deleteall = -10; }; //- Reset byok ----------------------------------------------------------------------- For cnt=1 To TotalTrades { If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_BUYSTOP)) Then { byok = 10; }; }; //- Reset slok ----------------------------------------------------------------------- For cnt=1 To TotalTrades { If ((OrderValue(cnt,VAL_SYMBOL)==Symbol) and (OrderValue(cnt,VAL_TYPE)==OP_SELLSTOP)) Then { slok = 10; }; }; //- Set Variable Values ------------------------------------------------------------------------------------ aa=abs(H[101]-H[100]);ab=abs(H[100]-H[99]);ac=abs(H[99]-H[98]);ad=abs(H[98]-H[97]);ae=abs(H[97]-H[96]); af=abs(H[96]-H[95]);ag=abs(H[95]-H[94]);ah=abs(H[94]-H[93]);ai=abs(H[93]-H[92]);aj=abs(H[92]-H[91]); ak=abs(H[91]-H[90]);al=abs(H[90]-H[89]);am=abs(H[89]-H[88]);ao=abs(H[88]-H[87]);ap=abs(H[87]-H[86]); aq=abs(H[86]-H[85]);ar=abs(H[85]-H[84]);as=abs(H[84]-H[83]);au=abs(H[83]-H[82]);av=abs(H[82]-H[81]); ba=abs(H[81]-H[80]);bb=abs(H[80]-H[79]);bc=abs(H[79]-H[78]);bd=abs(H[78]-H[77]);be=abs(H[77]-H[76]); bf=abs(H[76]-H[75]);bg=abs(H[75]-H[74]);bh=abs(H[74]-H[73]);bi=abs(H[73]-H[72]);bj=abs(H[72]-H[71]); bk=abs(H[71]-H[70]);bl=abs(H[70]-H[69]);bm=abs(H[69]-H[68]);bo=abs(H[68]-H[67]);bp=abs(H[67]-H[66]); bq=abs(H[66]-H[65]);br=abs(H[65]-H[64]);bs=abs(H[64]-H[63]);bu=abs(H[63]-H[62]);bv=abs(H[62]-H[61]); ca=abs(H[61]-H[60]);cb=abs(H[60]-H[59]);cc=abs(H[59]-H[58]);cd=abs(H[58]-H[57]);ce=abs(H[57]-H[56]); cf=abs(H[56]-H[55]);cg=abs(H[55]-H[54]);ch=abs(H[54]-H[53]);ci=abs(H[53]-H[52]);cj=abs(H[52]-H[51]); ck=abs(H[51]-H[50]);cl=abs(H[50]-H[49]);cm=abs(H[49]-H[48]);co=abs(H[48]-H[47]);cp=abs(H[47]-H[46]); cq=abs(H[46]-H[45]);cr=abs(H[45]-H[44]);cs=abs(H[44]-H[43]);cu=abs(H[43]-H[42]);cv=abs(H[42]-H[41]); da=abs(H[41]-H[40]);db=abs(H[40]-H[39]);dc=abs(H[39]-H[38]);dd=abs(H[38]-H[37]);de=abs(H[37]-H[36]); df=abs(H[36]-H[35]);dg=abs(H[35]-H[34]);dh=abs(H[34]-H[33]);di=abs(H[33]-H[32]);dj=abs(H[32]-H[31]); dk=abs(H[31]-H[30]);dl=abs(H[30]-H[29]);dm=abs(H[29]-H[28]);do=abs(H[28]-H[27]);dp=abs(H[27]-H[26]); dq=abs(H[26]-H[25]);dr=abs(H[25]-H[24]);ds=abs(H[24]-H[23]);du=abs(H[23]-H[22]);dv=abs(H[22]-H[21]); ea=abs(H[21]-H[20]);eb=abs(H[20]-H[19]);ec=abs(H[19]-H[18]);ed=abs(H[18]-H[17]);ee=abs(H[17]-H[16]); ef=abs(H[16]-H[15]);eg=abs(H[15]-H[14]);eh=abs(H[14]-H[13]);ei=abs(H[13]-H[12]);ej=abs(H[12]-H[11]); ek=abs(H[11]-H[10]);el=abs(H[10]-H[9]);em=abs(H[9]-H[8]);eo=abs(H[8]-H[7]);ep=abs(H[7]-H[6]); eq=abs(H[66]-H[5]);er=abs(H[5]-H[4]);es=abs(H[4]-H[3]);eu=abs(H[3]-H[2]);ev=abs(H[2]-H[1]); fa=abs(L[101]-L[100]);fb=abs(L[100]-L[99]);fc=abs(L[99]-L[98]);fd=abs(L[98]-L[97]);fe=abs(L[97]-L[96]); ff=abs(L[96]-L[95]);fg=abs(L[95]-L[94]);fh=abs(L[94]-L[93]);fi=abs(L[93]-L[92]);fj=abs(L[92]-L[91]); fk=abs(L[91]-L[90]);fl=abs(L[90]-L[89]);fm=abs(L[89]-L[88]);fo=abs(L[88]-L[87]);fp=abs(L[87]-L[86]); fq=abs(L[86]-L[85]);fr=abs(L[85]-L[84]);fs=abs(L[84]-L[83]);fu=abs(L[83]-L[82]);fv=abs(L[82]-L[81]); ga=abs(L[81]-L[80]);gb=abs(L[80]-L[79]);gc=abs(L[79]-L[78]);gd=abs(L[78]-L[77]);ge=abs(L[77]-L[76]); gf=abs(L[76]-L[75]);gg=abs(L[75]-L[74]);gh=abs(L[74]-L[73]);gi=abs(L[73]-L[72]);gj=abs(L[72]-L[71]); gk=abs(L[71]-L[70]);gl=abs(L[70]-L[69]);gm=abs(L[69]-L[68]);go=abs(L[68]-L[67]);gp=abs(L[67]-L[66]); gq=abs(L[66]-L[65]);gr=abs(L[65]-L[64]);gs=abs(L[64]-L[63]);gu=abs(L[63]-L[62]);gv=abs(L[62]-L[61]); ha=abs(L[61]-L[60]);hb=abs(L[60]-L[59]);hc=abs(L[59]-L[58]);hd=abs(L[58]-L[57]);he=abs(L[57]-L[56]); hf=abs(L[56]-L[55]);hg=abs(L[55]-L[54]);hh=abs(L[54]-L[53]);hi=abs(L[53]-L[52]);hj=abs(L[52]-L[51]); hk=abs(L[51]-L[50]);hl=abs(L[50]-L[49]);hm=abs(L[49]-L[48]);ho=abs(L[48]-L[47]);hp=abs(L[47]-L[46]); hq=abs(L[46]-L[45]);hr=abs(L[45]-L[44]);hs=abs(L[44]-L[43]);hu=abs(L[43]-L[42]);hv=abs(L[42]-L[41]); ja=abs(L[41]-L[40]);jb=abs(L[40]-L[39]);jc=abs(L[39]-L[38]);jd=abs(L[38]-L[37]);je=abs(L[37]-L[36]); jf=abs(L[36]-L[35]);jg=abs(L[35]-L[34]);jh=abs(L[34]-L[33]);ji=abs(L[33]-L[32]);jj=abs(L[32]-L[31]); jk=abs(L[31]-L[30]);jl=abs(L[30]-L[29]);jm=abs(L[29]-L[28]);jo=abs(L[28]-L[27]);jp=abs(L[27]-L[26]); jq=abs(L[26]-L[25]);jr=abs(L[25]-L[24]);js=abs(L[24]-L[23]);ju=abs(L[23]-L[22]);jv=abs(L[22]-L[21]); ka=abs(L[21]-L[20]);kb=abs(L[20]-L[19]);kc=abs(L[19]-L[18]);kd=abs(L[18]-L[17]);ke=abs(L[17]-L[16]); kf=abs(L[16]-L[15]);kg=abs(L[15]-L[14]);kh=abs(L[14]-L[13]);ki=abs(L[13]-L[12]);kj=abs(L[12]-L[11]); kk=abs(L[11]-L[10]);kl=abs(L[10]-L[9]);km=abs(L[9]-L[8]);ko=abs(L[8]-L[7]);kp=abs(L[7]-L[6]); kq=abs(L[66]-L[5]);kr=abs(L[5]-L[4]);ks=abs(L[4]-L[3]);ku=abs(L[3]-L[2]);kv=abs(L[2]-L[1]); //---------------------------------- hidiff=(aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+ao+ap+aq+ar+as+au+av+ ba+bb+bc+bd+be+bf+bg+bh+bi+bj+bk+bl+bm+bo+bp+bq+br+bs+bu+bv+ ca+cb+cc+cd+ce+cf+cg+ch+ci+cj+ck+cl+cm+co+cp+cq+cr+cs+cu+cv+ da+db+dc+dd+de+df+dg+dh+di+dj+dk+dl+dm+do+dp+dq+dr+ds+du+dv+ ea+eb+ec+ed+ee+ef+eg+eh+ei+ej+ek+el+em+eo+ep+eq+er+es+eu+ev)/100; rdhidiff=(Round(hidiff/Point))*Point; lowdiff=(fa+fb+fc+fd+fe+ff+fg+fh+fi+fj+fk+fl+fm+fo+fp+fq+fr+fs+fu+fv+ ga+gb+gc+gd+ge+gf+gg+gh+gi+gj+gk+gl+gm+go+gp+gr+gs+gu+gv+ ha+hb+hc+hd+he+hf+hg+hh+hi+hj+hk+hl+hm+ho+hp+hr+hs+hu+hv+ ja+jb+jc+jd+je+jf+jg+jh+ji+jj+jk+jl+jm+jo+jp+jq+jr+js+ju+jv+ ka+kb+kc+kd+ke+kf+kg+kh+ki+kj+kk+kl+km+ko+kp+kq+kr+ks+ku+kv)/100; rdlwdiff=(Round(lowdiff/Point))*Point; spread = (Round((Ask-Bid)/Point))*Point; buystop = (((Round((High[Highest(MODE_HIGH,PeriodsLookback,PeriodsLookback)])/Point))*Point)+(rdhidiff))+spread; sellstop = (((Round((Low[Lowest(MODE_LOW,PeriodsLookback,PeriodsLookback)])/Point))*Point)-(rdlwdiff))-spread; pips = ((Round((iATR(ProfitAtrPrds,0)*FactorProf)/Point))*Point); stops = ((Round((iATR(AtrPeriods,0)*TrailAt_TimesATR)/Point))*Point); //- Place Comments on Chart Window ------------------------------------------------------------------------- If (ShowComments <> 0) then { Comment("\n"," Chart Hour: = ",Hour," , FrstSessHour: = ",FrstSessHour, " , SecondSessHour: = ",SecondSessHour, "\n", //"\n"," pbht: = ",pbht," , psld: = ",psld," , deleteall: = ",deleteall, // " , byok: = ",byok," , slok: = ",slok, "\n"," Symbol: = ",Symbol," , MaxProfit: = ",MaxProfit," , MaxLoss: = ",MaxLoss, "\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"," PeriodsLookback: = ",PeriodsLookback, "\n"," Spread: = ",spread, "\n"," rdhidiff: = ",rdhidiff," , rdlwdiff: = ",rdlwdiff, "\n"," Highest High of PeriodsLookback + Spread + rdhidiff: = ",buystop, "\n"," Lowest Low of PeriodsLookback - Spread - rdlwdiff: = ",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(); }; If (CurTime-LastTradeTime) < 10 Then Exit; //- Delete Previous Pending Orders ------------------------------------------------------------------------- If (deleteall > 0) then { For cnt = 1 To TotalTrades { If ((Ord(cnt,VAL_SYMBOL)==Symbol) and (Hour==FrstSessHour or Hour == SecondSessHour)) and ((Ord(cnt,VAL_TYPE)==OP_SELLSTOP)or(Ord(cnt,VAL_TYPE)==OP_BUYSTOP)) Then { byok = -10; slok = -10; pbht = bought; psld = sold; DeleteOrder(OrderValue(cnt,VAL_TICKET),Cyan); Print("Deleted Order For New Session Trade ",Symbol);Exit; }; }; }; //- If a trade closes , reset pbht / psld ------------------------------------------------------------------ If (bought < pbht) Then { pbht = bought; }; If (sold < psld) Then { psld = sold; }; //- If pending order becomes active Set Flag to delete opposing stop order --------------------------------- For cnt=1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (CnclPndngIfActvTrd==1)) Then { If ((buyorder == 0) and (pbht != bought)) Then { closesellorder = 1; }; }; }; For cnt=1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (CnclPndngIfActvTrd==1)) Then { If((sellorder == 0) and (psld != sold)) Then { closebuyorder = 1; }; }; }; //- If active order flag , Delete Opposing Stop Order ------------------------------------------------------ For cnt=1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (closesellorder==1) and (Ord(cnt,VAL_TYPE)==OP_SELLSTOP)) Then { DeleteOrder(OrderValue(cnt,VAL_TICKET),LightGoldenrod); pbht = bought; Print("Deleted Due To Active Buy Order ",Symbol);Exit; }; }; For cnt=1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (closebuyorder==1) and (Ord(cnt,VAL_TYPE)==OP_BUYSTOP)) Then { DeleteOrder(OrderValue(cnt,VAL_TICKET),LightGoldenrod); psld = sold; Print("Deleted Due To Active Sell Order ",Symbol);Exit; }; }; //- Delete Pending Orders when DltAftr_Mnts has elapsed ---------------------------------------------------- For cnt = 1 To TotalTrades { If (((Ord(cnt,VAL_TYPE)==OP_BUYSTOP)or(Ord(cnt,VAL_TYPE)==OP_SELLSTOP))and(DeleteOrderAfterMnts==1)) Then { If (CurTime-OrderValue(cnt,VAL_OPENTIME))>(DltAftr_Mnts*60) Then { DeleteOrder(OrderValue(cnt,VAL_TICKET),LightGoldenrod); Print("Delete after minutes ",Symbol);Exit; }; }; }; //- Set BuyStop and SellStop ------------------------------------------------------------------------------- If (Hour==FrstSessHour) or (Hour == SecondSessHour) Then { If ((buyorder == 0) and (byok <= 0) and (deleteall < 0)) Then { SetOrder(OP_BUYSTOP,Lots,buystop,0,(buystop)-MaxLoss*Point,(buystop)+MaxProfit*Point,Cyan); Print("New Session BuyStop ",Symbol);Exit; }; }; If (Hour == FrstSessHour) or (Hour == SecondSessHour) Then { If ((sellorder == 0) and (slok <= 0) and (deleteall < 0)) Then { SetOrder(OP_SELLSTOP,Lots,sellstop,0,(sellstop)+MaxLoss*Point,(sellstop)-MaxProfit*Point,Fuchsia); Print("New Session SellStop ",Symbol);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); Print("Adjusted To Breakeven ",Symbol);Exit; }; }; }; For cnt = 1 To TotalTrades { 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); Print("Adjusted To Breakeven ",Symbol);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 ((OrderValue(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE)) > pips) Then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS), OrderValue(cnt,VAL_CLOSEPRICE),0,SandyBrown); Print("ATR TakeProfit ",Symbol);Exit; }; }; }; For cnt = 1 To TotalTrades { If ((Ord(cnt,Val_Symbol)==Symbol) and (DynamicProfit==1) and (Ord(cnt,VAL_TYPE)==OP_BUY)) Then { If ((Ord(cnt,VAL_CLOSEPRICE)-OrderValue(cnt,VAL_OPENPRICE)) > pips) Then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS), OrderValue(cnt,VAL_CLOSEPRICE),0,SandyBrown); Print("ATR TakeProfit ",Symbol);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); Print("ATR TrailingStop ",Symbol);Exit; }; }; }; For cnt = 1 To TotalTrades { 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); Print("Standard TrailingStop ",Symbol);Exit; }; }; }; For cnt = 1 To TotalTrades { 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))