#property copyright "@2009 Desynced Tech" #property link "http://desynced.no-ip.org/fx" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ datetime lastOrder; extern int takeProfit = 60; extern int FastEMA=8; extern int FFastEMA=7; extern int FFFastEMA=6; extern int SlowEMA=17; extern int SSlowEMA=16; extern int SSSlowEMA=15; extern int SignalSMA=9; extern int SSignalSMA=8; extern int SSSignalSMA=7; int ticket ; int MAGIC = 12; int orderType ; int decision () { double macd_M1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_MM1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); double macd_M5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_MM5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); double macd_M15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_MM15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); double macd_M30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_MM30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); double macd_H1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_HH1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); double macd_H4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0); double macd_HH4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0); string trend_signal = "", trend_main = "", trend_level = ""; color color_m1, color_m5, color_m15, color_m30, color_h1, color_h4, color_d1, color_w1, color_mn, color_signal, color_main, color_level; // UP Data if ((macd_M5 > macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal = "TREND/UP"; color_signal = Lime;} //Down Data if ((macd_M5 < macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal = "TREND/DN"; color_signal = Red; } //Consolidation Data if ((macd_M5 < macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal = "SIDEWAY"; color_signal = Orange; } if ((macd_M5 > macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal = "SIDEWAY"; color_signal = Orange; } if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)&& (macd_H4 < macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; } if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)&& (macd_H4 > macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; } if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 >macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/UP"; color_main = YellowGreen; } if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/DN"; color_main = Tomato; } if ((macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/DN"; color_main = Tomato; } if ((macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/UP"; color_main = YellowGreen; } if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main = "TREND/DN"; color_main = Red; } if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main = "TREND/UP"; color_main = Lime; } if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; } if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level = "WEAK"; color_level = Tomato; } if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_level = "MEDIUM"; color_level = Orange; } if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_level = "STRONG"; color_level = Yellow; } if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_level = "STRONG"; color_level = Yellow; } if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_main = "TREND/UP"; color_main = Lime; } if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_main = "TREND/DN"; color_main = Red; } if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_main = "TREND/UP"; color_main = Lime; } if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_main = "TREND/DN"; color_main = Red; } double incolor = iCustom(NULL,0,"lswpr_in_color",4,0); double incolorx = iCustom(NULL,0,"lswpr_in_color",4,1); string adap = ""; int adaptrend = 0 ; if ( incolor > incolorx ) { adap = "going up"; adaptrend = 1; } else if ( incolor < incolorx ) { adap = "going down"; adaptrend = -1; } double incolor0 = iCustom(NULL,0,"lswpr_in_color",0,0); double incolor1 = iCustom(NULL,0,"lswpr_in_color",1,0); double incolor2 = iCustom(NULL,0,"lswpr_in_color",2,0); double ad=(iCustom(NULL,0,"adaptive rsi",0,0)*10000-iCustom(NULL,0,"adaptive rsi",0,1)*10000); Comment ( "current Value = " , ad , " trendlevel " , trend_level , " trend_main" , trend_main , " " , trend_signal , " adap " , adap ); if (ad>9 ) { if ( trend_level == "STRONG" && trend_main == "TREND/UP" && trend_signal == "TREND/UP" && adaptrend == 1 ) return(1); } if ( ad<-9) { if ( trend_level == "STRONG" && trend_main == "TREND/DN" && trend_signal == "TREND/DN" && adaptrend == -1 ) return(-1); } } int init() { //---- //---- return(0); } bool canTrade() { if ( Minute() == 0 ) return(false); if ( Hour() >= 1 && Hour() < 2 ) return (false); if ( Hour() >= 9 && Hour() < 10 ) return (false); if ( Hour() >= 13 && Hour() < 14 ) return (false); return (true); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int decision = decision(); /* if ( OrdersTotal() > 0 ) { if ( (TimeCurrent() - lastOrder ) > 60*60*2 && orderType == OP_BUY) { OrderClose(ticket,0.1,Bid,3,Red); } if ( (TimeCurrent() - lastOrder ) > 60*60*2 && orderType == OP_SELL ) { OrderClose(ticket,0.1,Ask,3,Red); } return(0); } */ double lots = 0.1; //if ( Hour() == 17 || Hour() == 15 ) lots = 0.2; if ( !canTrade() ) return(0); if ( decision == 1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) { if ( OrdersTotal() == 0 ) { // // Print("buy " , y0 , " " , y1); // Print("buy ", (x0 - y0)*1000 , " ==>" , l0, " =>", val); ticket = OrderSend(Symbol(),OP_BUY, lots, Ask, 3,0/* Ask-70*Point*/,Ask+takeProfit*Point,"", MAGIC, 0, Red); lastOrder = TimeCurrent(); orderType = OP_BUY; } } else if ( decision == -1 && (TimeCurrent() - lastOrder ) > (60*60*3 ) ) { if ( OrdersTotal() == 0 ) { ticket = OrderSend(Symbol(),OP_SELL, lots, Bid, 3, 0/*Bid+70*Point*/,Bid-takeProfit*Point,"", MAGIC, 0, Red); lastOrder = TimeCurrent(); orderType = OP_SELL; } } //---- //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
MACD Histogram
Custom Indicators Used:
adaptive rsi
lswpr_in_color
Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
It automatically opens orders when conditions are reached
Other Features: