/*[[ Name := NFP Author := Copyright © 2005, MetaQuotes Software Corp. Link := http://www.metaquotes.net/ Lots := 1.00 Stop Loss := 40 Take Profit := 40 Trailing Stop := 0 ]]*/ Var: counta(0), countb(0), cnt(0), priceh(0), pricel(0), countc(0), Ilo(0), countd(0), counte(0), countf(0); Define: orderspread(5), straddlespread(10), trailone(10), trailtwo(30), maxtrades1 (40), maxtrades(20); If Day > 7 or DayOfWeek <> 6 then exit; Ilo = ceil(Balance*0.001)/10; If Ilo > 1 then { Ilo = ceil(Ilo);} If Ilo > 100 then {Ilo = 100;}; /////////////////////Determine last bar high and low when EA is attached//////////////////////////////////// if counta = 0 and Hour = 15 and Minute = 28 then { priceh = High[1]; pricel = Low[1]; counta++; }; ///////////////////////////////////Enter grid stop orders////////////////////////////////////////// if curtime - LastTradeTime >= 10 and countb = countc and countb < maxtrades and Hour = 15 and Minute >= 29 and Minute < 30 then {SetOrder(OP_BUYSTOP,Ilo*10,priceh+straddlespread*point/*+orderspread*(maxtrades-countb)*point*/,0, priceh+straddlespread*point+orderspread*countb*point-stoploss/2*point, priceh+straddlespread*point+orderspread*countb*point+TakeProfit*point,Blue); countb =20/*++*/;}; if curtime - LastTradeTime >= 10 and countc < maxtrades and Hour = 15 and Minute >= 29 and Minute < 30 then {SetOrder(OP_SELLSTOP,Ilo*10,pricel-straddlespread*point/*-orderspread*(maxtrades-countc)*point*/,0, pricel-straddlespread*point-orderspread*countc*point+stoploss/2*point, pricel-straddlespread*point-orderspread*countc*point-TakeProfit*point,Red); countc =20/*++*/;}; if DayOfWeek = 6 and Hour == 15 and Minute >= 34 and Minute < 36 then for cnt = 1 to TotalTrades { if ord(cnt,VAL_SYMBOL) = symbol and Ord(cnt,VAL_TYPE) > OP_SELL then { DeleteOrder(Ord(cnt,VAL_TICKET),White); Exit; } }; /////////////////////close orders //////////////////////////////////////// /*if DayOfWeek = 6 and Hour == 15 and Minute >= 34 and Minute < 36 then for cnt = 1 to TotalTrades Begin if ord(cnt,VAL_TYPE) = 0 then {CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,10,Yellow); Exit;} end; if DayOfWeek = 6 and Hour == 15 and Minute > 33 and Minute < 36 then for cnt = 1 to TotalTrades Begin if ord(cnt,VAL_TYPE) = 1 then {CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,10,Yellow); Exit;} end; */ /////////////////////Determine last bar high and low when EA is attached//////////////////////////////////// if countd = 0 and Hour = 15 and Minute = 35 then { priceh = O /*+ 15 * point*/; pricel = O /*- 15 * point*/; countd++; }; ///////////////////////////////////Enter grid stop orders////////////////////////////////////////// if curtime - LastTradeTime >= 10 and counte = countf and counte < maxtrades1 and Hour = 15 and Minute > 35 and Minute < 55 then {SetOrder(OP_BUYSTOP,Ilo,priceh+straddlespread*1.5*point+orderspread*counte*point,0, priceh+straddlespread*point+orderspread*counte*point-stoploss*point, priceh+straddlespread*point+orderspread*counte*point+TakeProfit*point*2,Blue); counte ++;}; if curtime - LastTradeTime >= 10 and countf < maxtrades1 and Hour = 15 and Minute > 35 and Minute < 55 then {SetOrder(OP_SELLSTOP,Ilo,pricel-straddlespread*1.5*point-orderspread*countf*point,0, pricel-straddlespread*point-orderspread*countf*point+stoploss*point, pricel-straddlespread*point-orderspread*countf*point-TakeProfit*point*2,Red); countf ++;}; if Hour = 18 then { counta = 0; countb = 0; countc = 0; countd = 0; counte = 0; countf = 0; }; if DayOfWeek = 6 and Hour == 22 and Minute > 30 then for cnt = 1 to TotalTrades { if ord(cnt,VAL_SYMBOL) = symbol and Ord(cnt,VAL_TYPE) > OP_SELL then { DeleteOrder(Ord(cnt,VAL_TICKET),White); Exit; } }; ///////////////////////////Trailing stop code/////////////////////////////////////// if DayOfWeek = 6 and Hour == 15 and Minute > 29 and Minute < 36 then { for cnt = 1 to TotalTrades Begin if Ord(cnt,VAL_TYPE)=0 then { if (Bid - OrderValue(cnt,VAL_OPENPRICE)) > (Point*trailone) then { if OrderValue(cnt,VAL_STOPLOSS) < (Bid-Point*trailone) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Bid-Point*trailone,OrderValue(cnt,VAL_TAKEPROFIT),Yellow); exit; } } } if Ord(cnt,VAL_TYPE)=1 then { if (OrderValue(cnt,VAL_OPENPRICE) - Ask) > (Point*trailone) then { if OrderValue(cnt,VAL_STOPLOSS) > (Ask + Point*trailone) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Ask + Point*trailone,OrderValue(cnt,VAL_TAKEPROFIT),Yellow); exit; } } } end; } else /*if DayOfWeek = 6 and Hour >= 15 and Minute > 35 then*/ { for cnt = 1 to TotalTrades Begin if Ord(cnt,VAL_TYPE)=0 then { if (Bid - OrderValue(cnt,VAL_OPENPRICE)) > (Point*trailtwo) then { if OrderValue(cnt,VAL_STOPLOSS) < (Bid-Point*trailtwo) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Bid-Point*trailtwo,OrderValue(cnt,VAL_TAKEPROFIT),Yellow); exit; } } } if Ord(cnt,VAL_TYPE)=1 then { if (OrderValue(cnt,VAL_OPENPRICE) - Ask) > (Point*trailtwo) then { if OrderValue(cnt,VAL_STOPLOSS) > (Ask + Point*trailtwo) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Ask + Point*trailtwo,OrderValue(cnt,VAL_TAKEPROFIT),Yellow); exit; } } } end; }; /////////////////////close orders //////////////////////////////////////// /*if DayOfWeek = 6 and Hour == 22 and Minute > 30 then for cnt = 1 to TotalTrades Begin if ord(cnt,VAL_TYPE) = 0 then {CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,10,Yellow); Exit;} end; if DayOfWeek = 6 and Hour == 22 and Minute > 30 then for cnt = 1 to TotalTrades Begin if ord(cnt,VAL_TYPE) = 1 then {CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,10,Yellow); Exit;} end;