/*[[ Name := H & L Author := Copyright c 2005, FAB4X Link := ENTRY PRICES ARE CALCULATED ONLY FROM START OF 00GMT TILL CLOSE OF 23GMT. Notes := Lots := 1 Stop Loss := 999 Take Profit := 0 Trailing Stop := 0 ]]*/ defines: Slippage(5),startHourOfDay(0),endofDAY(23),StopYear(2005),StopMonth(1); var: i(0),lotsi(0),p1(0),p2(0),orders(0),openedBuy(0),openedSell(0); VAR: pips(0); var: yesterday_open(0); var: yesterday_high(0); var: yesterday_low(0); var: yesterday_close(0),b(0),d(0); VAR: vtime(0); VAR: BS(0),SS(0),MR(0); VAR: TARGETHIGH(0),TARGETLOW(0); if year < StopYear then exit; if month < StopMonth and year <> 2005 then exit; //Sorry, only works with H1 timeframe. If Period <> 60 then Alert("System only works on H1 timeframe.") Exit; //If (DayOfWeek <3 or DayOfWeek >5 ) then exit; orders=0; lotsi=Lots; For i=1 to TotalTrades { If Ord(i,Val_Symbol)=Symbol then { orders++; If Ord(i,VAL_TYPE)=OP_BUY then openedBuy=1; If Ord(i,VAL_TYPE)=OP_SELL then openedSell=1; }; }; if openedBuy=1 then { for i=1 to TotalTrades { If Ord(i,Val_Symbol)=Symbol and Ord(i,VAL_TYPE)=OP_SELLLIMIT or Ord(i,VAL_TYPE)=OP_SELLSTOP then { DeleteOrder(ord(i,VAL_TICKET),red); exit; }; }; }; if openedSell=1 then { for i=1 to TotalTrades { If Ord(i,Val_Symbol)=Symbol and Ord(i,VAL_TYPE)=OP_BUYLIMIT OR Ord(i,VAL_TYPE)=OP_BUYSTOP then { DeleteOrder(ord(i,VAL_TICKET),red); exit; }; }; }; if Hour=endofDAY then { openedBuy=0; openedSell=0; for i=1 to TotalTrades { //close trades at the end of day If Ord(i,Val_Symbol)=Symbol and (Ord(i,VAL_TYPE)=OP_BUYSTOP or Ord(i,VAL_TYPE)=OP_SELLSTOP) OR (Ord(i,VAL_TYPE)=OP_BUYLIMIT or Ord(i,VAL_TYPE)=OP_SELLLIMIT) then { DeleteOrder(ord(i,VAL_TICKET),red); exit; }; 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),lots,ord(i,VAL_CLOSEPRICE),slippage,red); exit; }; }; }; if vTime = Time[0] then exit; vTime = Time[0]; d=0; If b-startHourOfDay>=0 then d=open[b-startHourOfDay]; //if TimeHour(time[0])=startHourOfDay and TimeHour(time[1])<>startHourOfDay then //new day b=TimeHour(Time[0]); TargetHigh=Max(High[1+b],(Max(High[2+b],(Max(High[3+b],(Max(High[4+b],(Max(High[5+b],(Max(High[6+b],(Max(High[7+b],(Max(High[8+b], (Max(High[9+b],(Max(High[10+b],(Max(High[11+b],(Max(High[12+b],(Max(High[13+b],(Max(High[14+b],(Max(High[15+b],(Max(High[16+b],(Max(High[17+b],(Max(High[18+b],(Max(High[19+b],(Max(High[20+b],(Max(High[21+b],(Max(High[22+b],(Max(High[23+b],High[24+b]))))))))))))))))))))))))))))))))))))))))))))))))); TargetLow=Min(Low[1+b],(Min(Low[2+b],(Min(Low[3+b],(Min(Low[4+b],(Min(Low[5+b],(Min(Low[6+b],(Min(Low[7+b],(Min(Low[8+b],(Min(Low[9+b], (Min(Low[10+b],(Min(Low[11+b],(Min(Low[12+b],(Min(Low[13+b],(Min(Low[14+b],(Min(Low[15+b],(Min(Low[16+b],(Min(Low[17+b],(Min(Low[18+b], (Min(Low[19+b],(Min(Low[20+b],(Min(Low[21+b],(Min(Low[22+b],(Min(Low[23+b],Low[24+b]))))))))))))))))))))))))))))))))))))))))))))))))); mr=(TargetHigh+TargetLow)/2; //bs=(mr+TargetHigh)/2; //ss=(mr+TargetLow)/2; pips=((TargetHigh-TargetLow)/4)*10000; MoveObject("YESTERDAYS HIGH",OBJ_HLINE,time,TargetHigh,time,TargetHigh,RED,1,STYLE_SOLID); MoveObject("MIDDLE RANGE",OBJ_HLINE,time,MR,time,MR,Yellow,1,STYLE_DASHDOTDOT); MoveObject("YESTERDAYS LOW",OBJ_HLINE,time,TargetLow,time,TargetLow,GREEN,1,STYLE_SOLID); BS=MR+pips*POINT; SS=MR-pips*POINT; comment(" PLACE A BUYSTOP ORDER AT ", BS ," PLACE A SELLSTOP ORDER AT " , SS); IF open < BS THEN { If hour > 0 and orders<1 and openedBuy=0 then { openedBuy=2; SetOrder(OP_BUYSTOP,lotsi,BS,Slippage,BS-StopLoss*Point,TargetHigh,blue); exit; }; }; IF open > BS THEN { If hour > 0 and orders<1 and openedBuy=0 then { openedBuy=2; SetOrder(OP_BUYlimit,lotsi,BS,Slippage,BS-StopLoss*Point,TargetHigh,blue); exit; }; }; IF open > SS THEN { If hour >0 and orders=1 and openedSell=0 and openedBuy>0 then { // If hour >0 and orders<1 and openedSell=0 then { openedSell=2; SetOrder(OP_SELLSTOP,lotsi,SS,Slippage,SS+StopLoss*Point,TargetLow,RED); exit; }; }; IF OPEN < SS THEN { If hour >0 and orders=1 and openedSell=0 and openedBuy>0 then { // If hour > 0 and orders<1 and openedSell=0 then { openedSell=2; SetOrder(OP_SELLLIMIT,lotsi,SS,Slippage,SS+StopLoss*Point,TargetLow,RED); exit; }; };