/*[[ Name := 10 pips a day, version for online trading Author := Copyright c 2004, WWW, programmed by Nick Bilak beluck[AT]ukr.net Link := Notes := m1 charts Lots := 1 Stop Loss := 14 Take Profit := 10 Trailing Stop := 0 ]]*/ Define: GMTOffset(3); Define: mm(0),slippage(5),risk(10),RefSetup(5),RefDistance(35); Var:Today(0),RefDate(0); Var:RefPrice(0); Var:Cnt(0); Var:orders(0),lotsi(0),i(0); If FreeMargin<100 then Exit; if CurTime-LastTradeTime < 12 then exit; if TimeHour(time)-GMToffset=1 or TimeHour(time)-GMToffset=2 then { //initially set orders at 1:00 or 2:00 gmt Today=Floor((CurTime-GMTOffset*3600)/86400)*86400; If Today<>RefDate Then { RefDate=Today; Cnt=1; While (Cnt<(Bars-1)) & ((T[Cnt]-GMTOffset*3600) >=RefDate) { Cnt++; }; RefPrice=O[Cnt-1]; }; if mm<>0 then lotsi=Ceil(Balance*risk/10000)/10 else lotsi=Lots; if lotsi>25 then lotsi=25; orders=0; For cnt=1 to TotalTrades { If Ord(cnt,Val_Symbol)=Symbol then { orders=orders+1; }; }; if RefPrice-close[0] >= RefDistance*point then If orders=0 then { SetOrder(OP_BUYSTOP,lotsi,RefPrice-RefSetup*Point,Slippage,RefPrice-RefSetup*Point-StopLoss*Point,RefPrice-RefSetup*Point+TakeProfit*Point,blue); exit; }; if close[0]-RefPrice >= RefDistance*point then If orders=0 then { SetOrder(OP_SELLSTOP,lotsi,RefPrice+RefSetup*Point,Slippage,RefPrice+RefSetup*Point+StopLoss*Point,RefPrice+RefSetup*Point-TakeProfit*Point,red); exit; }; }; if TimeHour(time)-GMToffset=23 then { //close and delete orders at 23:00 for i=1 to TotalTrades { if ord(i,VAL_SYMBOL)=Symbol and ord(i,VAL_TYPE)=OP_BUY then { CloseOrder(ord(i,VAL_TICKET),ord(i,VAL_LOTS),ord(i,VAL_CLOSEPRICE),Slippage,red); exit; }; if ord(i,VAL_SYMBOL)=Symbol and ord(i,VAL_TYPE)=OP_SELL then { CloseOrder(ord(i,VAL_TICKET),ord(i,VAL_LOTS),ord(i,VAL_CLOSEPRICE),Slippage,yellow); exit; }; if ord(i,VAL_SYMBOL)=Symbol and ord(i,VAL_TYPE)=OP_SELLSTOP or ord(i,VAL_TYPE)=OP_BUYSTOP then { DeleteOrder(ord(i,VAL_TICKET),white); exit; }; }; }; if TrailingStop>ask-bid then { //simple trailingstop for i=1 to TotalTrades { If ord(i,VAL_SYMBOL)=Symbol and Ord(i,VAL_TYPE)=OP_BUY then { If (Bid-Ord(i,VAL_OPENPRICE))>(TrailingStop*Point) then { If Ord(i,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then { ModifyOrder(Ord(i,VAL_TICKET),Ord(i,VAL_OPENPRICE),Bid-TrailingStop*Point,Ord(i,VAL_TAKEPROFIT),Red); exit; }; }; }; If ord(i,VAL_SYMBOL)=Symbol and Ord(i,VAL_TYPE)=OP_SELL then { If (Ord(i,VAL_OPENPRICE)-Ask)>(TrailingStop*Point) then { If Ord(i,VAL_STOPLOSS)>(Ask+TrailingStop*Point) or Ord(i,VAL_STOPLOSS)=0 then { ModifyOrder(Ord(i,VAL_TICKET),Ord(i,VAL_OPENPRICE),Ask+TrailingStop*Point,Ord(i,VAL_TAKEPROFIT),Red); exit; }; }; }; }; };