Dear all,
I am trying to make an ea which trade in 1m chart, with the help of few indicators like MACD,MA,ADX,BB
the strategy for long is MA8 close abouve BB middle line,ADX should be abouve 25,and MACD moves above 0 leval from down,
trade long close when MACD create a negative crossover from above,
The same opposit for selling side,
i coded,myself but i have some difficulties in it,after the coding EA not trading,if i made some mistake in my coding please help me to correct,
thanks in advance for your helping mind .
Thank you
Suresh
India
What is your problem exactly ? No trade open, on strategy tester ? on live chart ?
Do you have error message in Journal and/or Experts tabs ?
May be you have there, a message similar to :
2013.03.29 18:13:15 Core 1 2013.03.01 00:00:00 array out of range in 'JAIL5.mq5' (193,30)
Dear all,
I am trying to make an ea which trade in 1m chart, with the help of few indicators like MACD,MA,ADX,BB
the strategy for long is MA8 close abouve BB middle line,ADX should be abouve 25,and MACD moves above 0 leval from down,
trade long close when MACD create a negative crossover from above,
The same opposit for selling side,
i coded,myself but i have some difficulties in it,after the coding EA not trading,if i made some mistake in my coding please help me to correct,
thanks in advance for your helping mind .
Thank you
Suresh
India
I think you miss this line (yellow mark)
void OnTick() { //--- we will use the static Old_Time variable to serve the bar time. //--- at each OnTick execution we will check the current bar time with the saved one. //--- if the bar time isn't equal to the saved time, it indicates that we have a new tick. static datetime Old_Time; datetime New_Time[1]; bool IsNewBar=false; //--- copying the last bar time to the element New_Time[0] int copied=CopyTime(_Symbol,_Period,0,1,New_Time); if(copied>0) // ok, the data has been copied successfully { if(Old_Time!=New_Time[0]) // if old time isn't equal to new bar time { IsNewBar=true; // if it isn't a first call, the new bar has appeared if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("We have new bar here ",New_Time[0]," old time was ",Old_Time); Old_Time=New_Time[0]; // saving bar time } } else { Alert("Error in copying historical times data, error =",GetLastError()); ResetLastError(); return; } //--- EA should only check for new trade if we have a new bar if(IsNewBar==false) { return; } //--- do we have enough bars to work with int Mybars=Bars(_Symbol,_Period); if(Mybars<60) // if total bars is less than 60 bars { Alert("We have less than 60 bars, EA will now exit!!"); return; } MqlRates mrate[]; // To be used to store the prices, volumes and spread of each bar /* Let's make sure our arrays values for the Rates and Indicators is stored serially similar to the timeseries array */ // the rates arrays ArraySetAsSeries(mrate,true); ArraySetAsSeries(maVal,true); // the indicator arrays ArraySetAsSeries(BBUp,true); ArraySetAsSeries(BBLow,true); ArraySetAsSeries(BBMidle,true); ArraySetAsSeries(MACDValues, true); //--- the ADX DI+values array ArraySetAsSeries(plsDI,true); //--- the ADX DI-values array ArraySetAsSeries(minDI,true); //--- the ADX values arrays ArraySetAsSeries(adxVal,true); //--- the MA-8 values arrays ArraySetAsSeries(maVal,true); //--- Get the details of the latest 3 bars if(CopyRates(_Symbol,_Period,0,3,mrate)<0) { Alert("Error copying rates/history data - error:",GetLastError(),"!!"); return; } //--- Copy the new values of our indicators to buffers (arrays) using the handle if(CopyBuffer(BolBandsHandle,0,0,3,BBMidle)<0 || CopyBuffer(BolBandsHandle,1,0,3,BBUp)<0 || CopyBuffer(BolBandsHandle,2,0,3,BBLow)<0) { Alert("Error copying Bollinger Bands indicator Buffers - error:",GetLastError(),"!!"); return; } //--- copy the new values of our indicators to buffers (arrays) using the handle if(CopyBuffer(adxHandle,0,0,3,adxVal)<0 || CopyBuffer(adxHandle,1,0,3,plsDI)<0 || CopyBuffer(adxHandle,2,0,3,minDI)<0) { Alert("Error copying ADX indicator Buffers - error:",GetLastError(),"!!"); ResetLastError(); return; } if(CopyBuffer(maHandle,0,0,3,maVal)<0) { Alert("Error copying Moving Average indicator buffer - error:",GetLastError()); ResetLastError(); return; } if(CopyBuffer(MACDHandle,0,0,3,MACDValues)<0) { Alert("Error copying MACD indicator buffer - error:",GetLastError()); ResetLastError(); return; } double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); // Ask price double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Bid price //--- Declare bool type variables to hold our Buy and Sell Conditions bool Buy_Condition =( adxVal[0]>adxVal[1] && adxVal[0]>Adx_Min && MACDValues[2]<MACDLeval && MACDValues[1] > MACDLeval && maVal[1]>BBMidle[1]); // White (bull) candle crossed the Lower Band from below to above bool Sell_Condition = ( adxVal[0]>adxVal[1] && adxVal[0]>Adx_Min && MACDValues[2]>MACDLeval && MACDValues[1]<MACDLeval && maVal[1]<BBMidle[1]); bool Buy_Close=(MACDValues[1] < signalPeriod ); // Black candle crossed the Upper Band from above to below bool Sell_Close=(MACDValues[1] > signalPeriod); // White candle crossed the Lower Band from below to above if(Buy_Condition && !PositionSelect(_Symbol)) // Open long position { // DEÌÀ is growing up LongPositionOpen(); // and white candle crossed the Lower Band from below to above } if(Sell_Condition && !PositionSelect(_Symbol)) // Open short position { // DEÌÀ is falling down ShortPositionOpen(); // and Black candle crossed the Upper Band from above to below } if(Buy_Close && PositionSelect(_Symbol)) // Close long position { // Black candle crossed the Upper Band from above to below LongPositionClose(); } if(Sell_Close && PositionSelect(_Symbol)) // Close short position { // White candle crossed the Lower Band from below to above ShortPositionClose(); } return; }
I think you miss this line (yellow mark)
hiiiii i am jignesh if u have any scalp ea will you send me on my mail id pathak_jignesh@yahoo.co.in
thanks
surubabs:Thank you achidayat, u did it for, u are correct now its working fine.hii
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear all,
I am trying to make an ea which trade in 1m chart, with the help of few indicators like MACD,MA,ADX,BB
the strategy for long is MA8 close abouve BB middle line,ADX should be abouve 25,and MACD moves above 0 leval from down,
trade long close when MACD create a negative crossover from above,
The same opposit for selling side,
i coded,myself but i have some difficulties in it,after the coding EA not trading,if i made some mistake in my coding please help me to correct,
thanks in advance for your helping mind .
Thank you
Suresh
India