/*[[ Name := BOMPREDICT Author := FAB4X Link := http://www.FAB4X.com Notes := Use on 15m charts Lots := 1.00 Stop Loss := 50 Take Profit := 20 Trailing Stop := 10 ]]*/ define: Slippage(5); define: MM(0); define: Risk(7.5); define: SecureProfit(10); define :TrailSecureProfit(17); var: cnt(0); var: Opentrades(0); var: lotsi(0); var: trend(""); var: vTime(0); var: vol1(0); var: vol2(0),tmp(0); VAR: D1(0),D2(0),D3(0),D4(0),D5(0),DATA2(0),DATA5(0),PREDICT(0); ////////////////////////////////////////////////// // Exit if not H4 charts ////////////////////////////////////////////////// /* if Period != 90 then { Comment("This expert is for 4HR Charts"); Exit; } */ ////////////////////////////////////////////////// // Exit if time between EA runs is less than 5 sec. ////////////////////////////////////////////////// if Curtime - LastTradeTime < 5 then exit; ////////////////////////////////////////////////// // Set if back tester earlier than 2005 ////////////////////////////////////////////////// If TimeYear(time)<2005 then Exit; ////////////////////////////////////////////////// // Set Variables ////////////////////////////////////////////////// Slippage = Slippage*Point; D1=CLOSE[1]; D2=CLOSE[2]; D3=CLOSE[3]; D4=CLOSE[4]; D5=CLOSE[5]; DATA2=(D1+D2)/2; DATA5=(D1+D2+D3+D4+D5)/5; predict=((abs(DATA2-DATA5)/D1*125.75 + 0.54528)*10000)/100; ////////////////////////////////////////////////// // Set Comment ////////////////////////////////////////////////// if PREDICT > 60 AND DATA2>DATA5 then trend = "LONG"; if PREDICT > 60 AND DATA2 50 AND PREDICT < 60 then trend = "FLAT"; comment("TREND PREDICTION DIRECTION IS ",trend,"\nTime=",TimeToStr(curtime),"\nPrediction ",predict," % "); ////////////////////////////////////////////////// ///////////// Manage multiple trades ///////////// ////////////////////////////////////////////////// Opentrades = 0; for cnt = 1 to TotalTrades { If OrderValue(cnt,Val_Symbol) == Symbol then { Opentrades++; } }; ////////////////////////////////////////////////// ///////////// Money Manager ///////////// ////////////////////////////////////////////////// if mm != 0 then Lotsi = Ceil(Balance*risk/10000)/10 else Lotsi=Lots; ////////////////////////////////////////////////// // Close Order ////////////////////////////////////////////////// if Opentrades != 0 and vTime != Time[0] and (PREDICT > 50 AND PREDICT < 60) then { for cnt=1 to TotalTrades { If (Ord(cnt,VAL_TYPE)=OP_BUY or Ord(cnt,VAL_TYPE)=OP_SELL) and Ord(cnt,VAL_SYMBOL) == Symbol then { vTime = Time[0]; // CloseOrder(OrderValue(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),(cnt,VAL_CLOSEPRICE),Slippage,BlueViolet); CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,Slippage,yellow); Exit; } } } ////////////////////////////////////////////////// // Open Trade ////////////////////////////////////////////////// if Opentrades == 0 and vTime != Time[0] then { iF PREDICT > 60 AND DATA2>DATA5 then { vTime = Time[0]; SetOrder(OP_BUY,Lotsi,ask,slippage,ask-stoploss*point,ask+takeprofit*point,Blue); Exit; } if PREDICT > 60 AND DATA2=TrailSecureProfit*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),((Ord(cnt,VAL_OPENPRICE))+SecureProfit*Point),0,DeepSkyBlue); 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); Exit; }; }; }; }; if OrderValue(cnt,VAL_TYPE) == OP_SELL then { //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); 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); Exit; }; }; }; }; }; };