/*[[ Name := 10 pips a day Author := Copyright c 2004, WWW Link := http://www.moneytec.com/forums/showthread.php?s=&threadid=10834&perpage=8&pagenumber=1 Notes := programmed by Nick Bilak beluck[AT]ukr.net Lots := 1 Stop Loss := 200 Take Profit := 10 Trailing Stop := 0 ]]*/ //set RefHour to when you want to get RefPrice //CloseHour - when to close and delete trades - be careful on friday - last hour is 22 gmt //TradesDay - how many trades per day allow Define: RefHour(0),CloseHour(22),TradesDay(1),BigBen(0); Define: mm(0),slippage(5),risk(10),RefSetup(5),RefDistance(35),BigBenDistance(6); Var:RefPrice(-1); Var:Cnt(0),CurHour(-1),TradesMade(0); Var:orders(0),lotsi(0),i(0),RefPrev(0); If FreeMargin<100 then Exit; if CurTime-LastTradeTime < 20 then exit; if TradesMade 0 or TimeHour(time) <> RefHour then { if RefPrev==0 then { Cnt=0; While ( Cnt <= 60/period*24 ) { if TimeHour(Time[Cnt]) == RefHour and TimeMinute(Time[cnt]) == 0 then { RefPrice=O[Cnt]; //print(RefPrice," : ",TimeToStr(t[cnt])); //print to log //Comment(RefPrice," : ",TimeToStr(t[cnt])); //comment on chart //uncomment above if need to see RefPrice cnt=60/period*24; RefPrev=1; }; Cnt++; }; }; if mm<>0 then lotsi=Ceil(Balance*risk/10000)/10 else lotsi=Lots; if lotsi>50 then lotsi=50; orders=0; For cnt=1 to TotalTrades { If Ord(cnt,Val_Symbol)=Symbol then { orders++; }; }; if BigBen == 0 then { // www original idea if RefPrice-close[0] >= RefDistance*point then If orders=0 then { TradesMade++; 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 { TradesMade++; SetOrder(OP_SELLSTOP,lotsi,RefPrice+RefSetup*Point,Slippage,RefPrice+RefSetup*Point+StopLoss*Point,RefPrice+RefSetup*Point-TakeProfit*Point,red); exit; }; } else { // www + BigBen if RefPrice+BigBenDistance*point == close[0] then If orders=0 then { TradesMade++; SetOrder(OP_SELL,lotsi,bid,Slippage,bid+StopLoss*Point,bid-TakeProfit*Point,blue); exit; }; if RefPrice-BigBenDistance*point == close[0] then If orders=0 then { TradesMade++; SetOrder(OP_BUY,lotsi,ask,Slippage,ask-StopLoss*Point,ask+TakeProfit*Point,blue); exit; }; }; }; if TimeHour(time) = CloseHour then { //close and delete orders after 23:00 for i=1 to TotalTrades { if ord(i,VAL_SYMBOL)=Symbol and ord(i,VAL_TYPE)=OP_BUY or ord(i,VAL_TYPE)=OP_SELL then { CloseOrder(ord(i,VAL_TICKET),ord(i,VAL_LOTS),ord(i,VAL_CLOSEPRICE),Slippage,LightBlue); 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; }; }; TradesMade=0; RefPrev=0; }; 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; }; }; }; }; };