/*[[ 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(20),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),YCLOSE(0),X(0),BL(0),SH(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=High[0]; TargetLow=Low[0]; YCLOSE=CLOSE[0]; IF CLOSE[1] < OPEN[1] THEN { X=(H[1]+L[1]+C[1]+L[1]); SH=X/2-(L[1]); BL=X/2-(H[1]); MoveObject("YESTERDAYS HIGH",OBJ_HLINE,time,SH,time,SH,RED,1,STYLE_SOLID); MoveObject("YESTERDAYS LOW",OBJ_HLINE,time,BL,time,BL,GREEN,1,STYLE_SOLID); comment(" PLACE A BUYSTOP ORDER AT ", BL ," PLACE A SELLSTOP ORDER AT " , SH); } IF CLOSE[1] > OPEN[1] THEN { X=(H[1]+L[1]+C[1]+H[1]); SH=X/2-(L[1]); BL=X/2-(H[1]); MoveObject("YESTERDAYS HIGH",OBJ_HLINE,time,SH,time,SH,RED,1,STYLE_SOLID); MoveObject("YESTERDAYS LOW",OBJ_HLINE,time,BL,time,BL,GREEN,1,STYLE_SOLID); comment(" PLACE A BUYSTOP ORDER AT ", BL ," PLACE A SELLSTOP ORDER AT " , SH); } IF CLOSE[1] = OPEN[1] THEN { X=(H[1]+L[1]+C[1]+C[1]); SH=X/2-(L[1]); BL=X/2-(H[1]); MoveObject("YESTERDAYS HIGH",OBJ_HLINE,time,SH,time,SH,RED,1,STYLE_SOLID); MoveObject("YESTERDAYS LOW",OBJ_HLINE,time,BL,time,BL,GREEN,1,STYLE_SOLID); comment(" PLACE A BUYSTOP ORDER AT ", BL ," PLACE A SELLSTOP ORDER AT " , SH); } IF open < BL THEN { If hour > 0 and orders<1 and openedBuy=0 then { openedBuy=2; SetOrder(OP_BUYSTOP,lotsi,BL,Slippage,BL-StopLoss*Point,SH,blue); exit; }; }; IF open > BL THEN { If hour > 0 and orders<1 and openedBuy=0 then { openedBuy=2; SetOrder(OP_BUYlimit,lotsi,BL,Slippage,BL-StopLoss*Point,SH,blue); exit; }; }; IF open > SH 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,SH,Slippage,SH+StopLoss*Point,BL,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,SH,Slippage,SH+StopLoss*Point,BL,RED); exit; }; };