/*[[ Name := Volume TRADER Author := Copyright © 2005 FAB4x Lots := 1.00 Link := Trades off volume from last hour data Stop Loss := 999 Take Profit := 999 Trailing Stop := 999 ]]*/ Define: StartHour(0); Define: StartMinute(30); Define: EndHour(22); Define: EndMinute(0); Define: mm(0); Define: risk(7.5); var: cnt(0); var: lotsi(0); var: OpenTrades(0); var: FilledOrders(0); var: Slippage(5); var: BuyPrice(0); var: SellPrice(0); var: TimetoOpen(0); var: TimetoClose(0); var: tmp(0); var: i(0); var: Trades(2); var: Type("NONE"); var: Reverse(False); var: mode(0); var: closerangesell(0); var: closerangebuy(0); var: range(0); var:vol1(0),vol2(0); if Period != 1440 then { Comment("This expert is for DAY Charts Only!!!"); Exit; } If TimeYear(time)<2005 then Exit; if Curtime - LastTradeTime < 5 then exit; if mm<>0 then lotsi=Ceil(Balance*risk/10000)/10 else lotsi=Lots; //comment(" PLACE A BUYSTOP ORDER AT ", BuyPrice ," PLACE A SELLSTOP ORDER AT " , SellPrice,"\nYesteday Range ",range,"\nCloseRangeBuy > 25? ",closerangebuy, "\nCloseRangeSell > 25? ", closerangesell); //MoveObject("YESTERDAYS HIGH",OBJ_HLINE,time, BuyPrice,time, BuyPrice,BLUE,1,STYLE_dot); //MoveObject("YESTERDAYS LOW",OBJ_HLINE,time,SellPrice,time,SellPrice,RED,1,STYLE_dot); OpenTrades=0; For cnt=1 to TotalTrades{ if OrderValue(cnt,VAL_SYMBOL)==Symbol then { OpenTrades++; If OrderValue(cnt,VAL_TYPE)==OP_SELL OR OrderValue(cnt,VAL_TYPE)==OP_BUY then { FilledOrders++; }; }; }; if (Hour==EndHour and Minute>=EndMinute) then { cnt=0;While cnt<=10000 { cnt++; }; For cnt=1 to TotalTrades { mode = OrderValue(cnt,VAL_TYPE); If OrderValue(cnt,VAL_SYMBOL)==Symbol then { Trades=2; Type="NONE"; Reverse=False; If (mode == OP_BUY) then CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),bid,Slippage,Blue); If (mode == OP_SELL) then CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),ask,Slippage,red); Exit; }; }; }; if (Hour==StartHour and Minute>=StartMinute) then { vol1=volume[1]; vol2=volume[2]; If OpenTrades<1 then { if vol1vol2 then { Trades=1; Type="NONE"; Reverse=True; SetOrder(OP_SELL,Lotsi,bid,Slippage,bid+StopLoss*Point,bid-TakeProfit*Point,Red); comment("Volume Up from last 2 days...Nowing Selling"); }; Exit; }; }; /* // if we only have one Stop order we place the another one to always have ready both sides If OpenTrades==1 and Trades>=1 then { for cnt=1 to TotalTrades { if (OrderValue(cnt,VAL_SYMBOL) == Symbol) then { if OrderValue(cnt,VAL_TYPE)==OP_SELLSTOP then { Trades=1; Type="NONE"; Reverse=True; SetOrder(OP_BUYSTOP,Lotsi,BuyPrice,Slippage,BuyPrice-StopLoss*Point,BuyPrice+TakeProfit*Point,blue); Exit; }; if OrderValue(cnt,VAL_TYPE)==OP_BUYSTOP then { Trades=1; Type="NONE"; Reverse=True; SetOrder(OP_SELLSTOP,Lotsi,SellPrice,Slippage,SellPrice+StopLoss*Point,SellPrice-TakeProfit*Point,Red); Exit; }; }; }; }; /* If OpenTrades<1 and Trades==1 and Reverse then { if Type=="BUY") then { Trades=0; Type="NONE"; Reverse=False; SetOrder(OP_BUY,Lotsi,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,Blue); Exit; }; if Type=="SELL") then { Trades=0; Type="NONE"; Reverse=False; SetOrder(OP_SELL,Lotsi,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,Red); Exit; }; }; */ /* // if we have opened positions we take care of them for cnt=1 to TotalTrades { if OrderValue(cnt,VAL_SYMBOL) == Symbol then { if OrderValue(cnt,VAL_TYPE) == OP_BUY then { for i=1 to TotalTrades { if (OrderValue(i,VAL_SYMBOL)==Symbol) then { if OrderValue(i,VAL_TYPE)==OP_SELLSTOP OR OrderValue(i,VAL_TYPE)==OP_BUYSTOP then { Trades=1; Type="SELL"; Reverse=True; DeleteOrder(OrderValue(i,VAL_TICKET),brown); Exit; }; }; }; //We secure SecureProfit (10) pips after TrailSecureProfit (16) pips if Ord(cnt,VAL_STOPLOSS)<=(Ord(cnt,VAL_OPENPRICE)-(StopLoss*Point)) and ((Bid-(Ord(cnt,VAL_OPENPRICE)))>=TrailSecureProfit*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),((Ord(cnt,VAL_OPENPRICE))+SecureProfit*Point),0,DeepSkyBlue); Trades=0; Type="NONE"; Reverse=False; tmp=(Ord(cnt,VAL_OPENPRICE))+SecureProfit*Point; Print("BUY Stoploss trailed to Openprice+SecureProfit=",tmp); Exit; }; // Trailing stop after profit secured If TrailingStop>0 then { If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(SecureProfit+TrailingStop)*Point then { If OrderValue(cnt,VAL_STOPLOSS)<(Bid-Point*(TrailingStop+SecureProfit)) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),Bid-Point*(SecureProfit+TrailingStop),0,Yellow); Trades=0; Type="NONE"; Reverse=False; Exit; }; }; }; }; if OrderValue(cnt,VAL_TYPE) == OP_SELL then { for i=1 to TotalTrades { if (OrderValue(i,VAL_SYMBOL)==Symbol) then { if OrderValue(i,VAL_TYPE)==OP_SELLSTOP OR OrderValue(i,VAL_TYPE)==OP_BUYSTOP then { Trades=1; Type="BUY"; Reverse=True; DeleteOrder(OrderValue(i,VAL_TICKET),brown); Exit; }; }; }; //We secure SecureProfit (10) pips after TrailSecureProfit (16) pips if Ord(cnt,VAL_STOPLOSS)>=(Ord(cnt,VAL_OPENPRICE)+(StopLoss*Point)) and (((Ord(cnt,VAL_OPENPRICE)-Ask))>=TrailSecureProfit*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),((Ord(cnt,VAL_OPENPRICE))-SecureProfit*Point),0,DeepSkyBlue); Trades=0; Type="NONE"; Reverse=False; tmp=(Ord(cnt,VAL_OPENPRICE))-SecureProfit*Point; Print("SELL Stoploss trailed to Openprice-SecureProfit=",tmp); Exit; }; If TrailingStop>0 then { If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(Point*(TrailingStop+SecureProfit)) then { if OrderValue(cnt,VAL_STOPLOSS)>(Ask+Point*(TrailingStop+SecureProfit)) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),Ask+Point*(TrailingStop+SecureProfit),0,Purple); Trades=0; Type="NONE"; Reverse=False; Exit; }; }; }; }; }; }; */ Exit;