/*[[ Name := Author := Link := Notes := Lots := 1.00 Stop Loss := Take Profit := 0 Trailing Stop := 0 ]]*/ Var: EMA5ClosePrev(0),EMA8ClosePrev(0),EMA5Close(0),EMA8Close(0),EMASig(0); Var: MACD_DWT(0),MACD_DWT2(0),MACD_DWTPrev(0),MACD_DWT2Prev(0),MACD_DWTPrevPrev(0),MACD_DWT2PrevPrev(0),MACDSig(0); Var: RSI(0),RSISig(0); Var: ValidBuy(0),ValidSell(0),Opentrades(0),OpenBuysThisSymbol(0),OpenSellsThisSymbol(0),vSL(0); Define: slippage(5),RSI_Value(21); Var: sl(0),CheckPoint1B(""),CheckPoint2B(""),CheckPoint3B(""),CheckPoint4B(""),CheckPoint5B(""); Var: tp(0),CheckPoint1S(""),CheckPoint2S(""),CheckPoint3S(""),CheckPoint4S(""),CheckPoint5S(""); Var: cnt(0); Var: b(0); Var: s(0); Var: FreshSignal("Waiting for Fresh Signal"),newbar(0),TimeSlice(0); If newbar != t[0] Then { newbar = t[0]; EMASig=0; MACDSig=0; RSISig=0; EMA5ClosePrev = iMA(5,MODE_EMA,2); EMA5Close = iMA(5,MODE_EMA,1); EMA8ClosePrev = iMA(8,MODE_EMA,2); EMA8Close = iMA(8,MODE_EMA,1); RSI = iRSI(RSI_Value,1); MACD_DWT=icustom("MACD-DWT",MODE_FIRST,1); MACD_DWT2=icustom("MACD-DWT",MODE_SECOND,1); MACD_DWTPrev=icustom("MACD-DWT",MODE_FIRST,2); MACD_DWT2Prev=icustom("MACD-DWT",MODE_SECOND,2); MACD_DWTPrevPrev=icustom("MACD-DWT",MODE_FIRST,3); MACD_DWT2PrevPrev=icustom("MACD-DWT",MODE_SECOND,3); If EMA5Close > EMA8Close and EMA5ClosePrev < EMA8CLosePrev then { CheckPoint1B="Go"; CheckPoint1S=""; }; If EMA5Close < EMA8Close and EMA5ClosePrev > EMA8CLosePrev then { CheckPoint1B=""; CheckPoint1S="Go"; }; If CheckPoint1B =="Go" or CheckPoint1S == "Go" then { If Abs(EMA5Close - EMA8Close) >=2 *Point then { CheckPoint2B="Go"; CheckPoint2S="Go"; }; If Abs(EMA5Close - EMA8Close) < 2 *Point then { CheckPoint2B=""; CheckPoint2S=""; }; }; If CheckPoint1B =="Go" and CheckPoint2b=="Go" then { If MACD_DWT > MACD_DWT2 then { CheckPoint3B="Go"; CheckPoint3S=""; }; }; If CheckPoint1S =="Go" and CheckPoint2S=="Go" then { If MACD_DWT < MACD_DWT2 then { CheckPoint3B=""; CheckPoint3S="Go"; }; }; If CheckPoint1B=="Go" and CheckPoint2B=="Go" and CheckPoint3B=="Go" then { If RSI > 50 then { CheckPoint4B="Go"; CheckPoint4S=""; }; }; If CheckPoint1S=="Go" and CheckPoint2S=="Go" and CheckPoint3S=="Go" then { If RSI < 50 then { CheckPoint4B=""; CheckPoint4S="Go"; }; }; /* Define: StartHour(9),EndHour(19); if TimeHour(CurTime)=EndHour then { FreshSignal = "Waiting for Fresh Signal"; Comment("Outside Trading Hours, Exiting...", "\n","Version 0.6 Carol's MACD EA", "\n", "\n","EMA 9 Close :",EMA9Close," EMA 9 Close Previous :",EMA9ClosePrev, "\n","EMA 20 Close :",EMA20Close," EMA 20 Close Previous :",EMA20ClosePrev, "\n","CCI :",CCI_Value," Typical Price :",CCI, "\n","Bob's MACD Historgram :",BobsMACDHist," Prev Historgram :",BobsMACDHistPrev," Bob's MACD Signal Line :",BobsMACDSigLine, "\n","CCI Crossed Zero going Down :",CCIcrossedZeroDown," CCI Crossed Zero going Up :",CCIcrossedZeroUp, "\n","EMA Signal :",EMASig," CCI Signal :",CCISig," Bob's MACD Signal :",MACDSig, "\n","Using Bob's MACD Hist :",UseRisingFallingHist, "\n","Status : Sleeping"); for cnt=1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE)=OP_BUY then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,5,Violet); exit; }; If OrderValue(cnt,VAL_TYPE)=OP_SELL then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,5,Violet); exit; }; }; }; exit; }; */ Comment("\n","Day : ",Day," Hour : ",Hour," Min ",Minute," Seconds ", Seconds, "\n","Version 0.3 Kurt's EA", "\n", "\n","EMA 5 Close :",EMA5Close," EMA 5 Close Previous :",EMA5ClosePrev, "\n","EMA 8 Close :",EMA8Close," EMA 8 Close Previous :",EMA8ClosePrev, "\n","RSI Period :",RSI_Value," RSI Value :",RSI, "\n","MACD-DWT :",MACD_DWT," MACD-DWT2 :",MACD_DWT2," MACD-DWTPrev :",MACD_DWTPrev," MACD-DWT2Prev :",MACD_DWT2Prev, "\n","Buy CheckPoints [",CheckPoint1B,"] [",CheckPoint2B,"] [",CheckPoint3B,"] [",CheckPoint4B,"]", "\n","Sell CheckPoints [",CheckPoint1S,"] [",CheckPoint2S,"] [",CheckPoint3S,"] [",CheckPoint4S,"]"); OpenBuysThisSymbol=0; for cnt=1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol and OrderValue(cnt,VAL_TYPE) == OP_BUY then { OpenBuysThisSymbol++; }; }; OpenSellsThisSymbol=0; for cnt=1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol and OrderValue(cnt,VAL_TYPE) == OP_Sell then { OpenSellsThisSymbol++; }; }; If OpenSellsThisSymbol == 0 and OpenBuysThisSymbol == 0 then { If CheckPoint1B=="Go" and CheckPoint2B=="Go" and CheckPoint3B=="Go" and CheckPoint4B=="Go" then { vSL=(Ask - (30 * Point)); SetOrder(OP_BUY,Lots,ask,slippage,vSL,0,blue); exit; }; If CheckPoint1S=="Go" and CheckPoint2S=="Go" and CheckPoint3S=="Go" and CheckPoint4S=="Go" then { FreshSignal="Sell Signal Initiated"; vSL=(Bid + (30 * Point)); SetOrder(OP_SELL,Lots,bid,slippage,vSL,0,red); exit; }; }; ////////////////////////////////////////////////// ///////////// Manage multiple trades ///////////// ////////////////////////////////////////////////// Opentrades=0; For cnt=1 to TotalTrades Begin If OrderValue(cnt,Val_Symbol)=Symbol then { Opentrades=Opentrades+1; }; End; if OpenTrades != 0 then { for cnt = 1 to TotalTrades { if OrderValue(cnt, VAL_SYMBOL) == Symbol then { if (OrderValue(cnt, VAL_TYPE) == OP_BUY) then { if CheckPoint1S == "Go" then { Alert("Closing Buy position because EMA is showing Short"); CloseOrder (OrderValue(cnt, VAL_TICKET),OrderValue(cnt, VAL_LOTS),OrderValue(cnt, VAL_CLOSEPRICE),Slippage,blue); Exit; } } if (OrderValue(cnt, VAL_TYPE) == OP_SELL) then { if CheckPoint1B == "Go" then { Alert("Closing Sell position because EMA is showing Long"); CloseOrder (OrderValue(cnt, VAL_TICKET),OrderValue(cnt, VAL_LOTS),OrderValue(cnt, VAL_CLOSEPRICE),Slippage,red); Exit; } } } } } };