//+------------------------------------------------------------------+ //| NeuroTrend_Indicator.mq4 | //| Copyright © 2008, Arun Kumar Raj | //| avoruganti@gmail.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, Arun Kumar Raj" #property link "avoruganti@gmail.com" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Yellow #property indicator_width1 1 #property indicator_color2 GreenYellow #property indicator_width2 1 #property indicator_color3 Gold #property indicator_width3 1 //includes #include <NeuroTrend_Include.mqh> //---- buffers double gmNN1[]; double gmNN2[]; double gmNN3[]; extern bool alert = true; extern bool sendMail = false; extern string netfile = "neurotrend.net"; extern string logfile = "netlog.txt"; extern bool log = false; extern bool barUpdate = true; bool gmBuy = false, gmSell = false; int reset, gmPrevBars = 0,h1shift = 0; double input[17]; double output[3]; double cEMA = 0, cRSI = 0, pRSI = 0, cStochMain = 0, pStochMain = 0, cStochSignal = 0, pStochSignal = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0,DRAW_LINE,EMPTY); SetIndexStyle(1,DRAW_LINE,EMPTY); SetIndexStyle(2,DRAW_LINE,EMPTY); SetIndexBuffer(0,gmNN1); SetIndexBuffer(1,gmNN2); SetIndexBuffer(2,gmNN3); SetIndexEmptyValue(0,0.0); IndicatorDigits(Digits); SetIndexShift (0, 0); IndicatorShortName ("NeuroTrend"); SetIndexLabel (0, "NeuroTrend"); //create network int units[3] = {17, 10, 3}; GenerateNetwork(3, units); ReadNetwork(netfile, logfile, log); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if(Bars < 1500) return (0); if(barUpdate && (gmPrevBars == Bars)) return (0); int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; while(limit >= 0) { cEMA = iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit); cRSI = iRSI(NULL,PERIOD_M15,9,PRICE_CLOSE,limit); pRSI = iRSI(NULL,PERIOD_M15,9,PRICE_CLOSE,limit+1); cStochMain = iStochastic(NULL,PERIOD_M15,5,3,3,MODE_EMA,0,MODE_MAIN,limit); pStochMain = iStochastic(NULL,PERIOD_M15,5,3,3,MODE_EMA,0,MODE_MAIN,limit+1); cStochSignal = iStochastic(NULL,PERIOD_M15,5,3,3,MODE_EMA,0,MODE_SIGNAL,limit); pStochSignal = iStochastic(NULL,PERIOD_M15,5,3,3,MODE_EMA,0,MODE_SIGNAL,limit+1); input[0] = gmThreshold((cEMA - iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit+1))/(Point*10)); input[1] = gmThreshold((iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit+1)-iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit+2))/(Point*10)); input[2] = gmThreshold((iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit+2)-iMA(NULL,PERIOD_M15,5,0,MODE_EMA,PRICE_CLOSE,limit+3))/(Point*10)); input[3] = gmThreshold(cRSI /100); input[4] = gmThreshold(pRSI /100); input[5] = gmThreshold((iWPR(NULL,PERIOD_M15,14,limit)+100)/100); input[6] = gmThreshold((iWPR(NULL,PERIOD_M15,14,limit+1)+100)/100); input[7] = gmThreshold(iMACD(NULL,PERIOD_M15,12,26,9,PRICE_CLOSE,MODE_MAIN,limit)*100); input[8] = gmThreshold(iMACD(NULL,PERIOD_M15,12,26,9,PRICE_CLOSE,MODE_MAIN,limit+1)*100); input[9] = gmThreshold(iMACD(NULL,PERIOD_M15,12,26,9,PRICE_CLOSE,MODE_SIGNAL,limit)*100); input[10] = gmThreshold(iMACD(NULL,PERIOD_M15,12,26,9,PRICE_CLOSE,MODE_SIGNAL,limit+1)*100); input[11] = gmThreshold(cStochMain /100); input[12] = gmThreshold(pStochMain /100); input[13] = gmThreshold(cStochSignal /100); input[14] = gmThreshold(pStochSignal /100); h1shift = iBarShift(NULL,PERIOD_H1,iTime(NULL,PERIOD_M15,limit),true); input[15] = gmThreshold((iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift)-iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift+1))/(Point*10)); input[16] = gmThreshold((iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift+1)-iMA(NULL,PERIOD_H1,5,0,MODE_EMA,PRICE_CLOSE,h1shift+2))/(Point*10)); SetInput(input); PropagateNet(); gmNN1[limit] = GetOutput(1)*Point*10+ cEMA; gmNN2[limit] = GetOutput(2)*Point*10+gmNN1[limit]; gmNN3[limit] = GetOutput(3)*Point*10+gmNN2[limit]; //Print(GetOutput(1)+" "+GetOutput(2)+" "+GetOutput(3)); if((limit < 2)) { if((gmBuy == false) && (gmNN3[limit] > gmNN2[limit]) && (gmNN2[limit] > gmNN1[limit]) && (gmNN1[limit] > cEMA)) { if((cRSI >= pRSI) && (cRSI > 45) && (cRSI < 50) && (cStochMain > cStochSignal) && (cStochMain >= pStochMain) && (cStochMain > 20) && (cStochMain < 80) && (cStochSignal >= pStochSignal) && (cStochSignal > 20) && (cStochSignal < 80)) { if(sendMail && (IsDemo() == FALSE)) SendMail("BUY SIGNAL", DoubleToStr(Ask,5)); if(alert) Alert("BUY SIGNAL"); gmBuy = true; gmSell = false; } } if((gmSell == false) && (gmNN3[limit] < gmNN2[limit]) && (gmNN2[limit] < gmNN1[limit]) && (gmNN1[limit] < cEMA)) { if((cRSI <= pRSI) && (cRSI > 50) && (cRSI < 55) && (cStochMain < cStochSignal) && (cStochMain <= pStochMain) && (cStochMain > 20) && (cStochMain < 80) && (cStochSignal <= pStochSignal) && (cStochSignal > 20) && (cStochSignal < 80)) { if(sendMail && (IsDemo() == FALSE)) SendMail("SELL SIGNAL", DoubleToStr(Bid,5)); if(alert) Alert("SELL SIGNAL"); gmSell = true; gmBuy = false; } } } limit--; }//end while loop gmPrevBars = Bars; return(0); } //------------------------------------------------------------------------------------------------- double gmThreshold(double value) { if(value > 0.99999) return (0.99999); if(value < -0.99999) return (-0.99999); return (value); } //-------------------------------------------------------------------------------------------------
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Relative strength index
Stochastic oscillator
Larry William percent range indicator
MACD Histogram
Custom Indicators Used:
Order Management characteristics:
Other Features:
It sends emails
It issuies visual alerts to the screen