Custom Indicator is working fine on Strategy tester but not on price chart

 
Hello, 
My custom Indicator was working fine before 15th April 2022, and it stopped working suddenly. 

It still works properly on strategy tester, but messing up all points for all points on the graph before 

 
Cruz Solace :
Hello, 
My custom Indicator was working fine before 15th April 2022, and it stopped working suddenly. 

It still works properly on strategy tester , but messing up all points for all points on the graph before 

If you do not show your MQL5 code, no one will be able to help you.

 
Cruz Solace: My custom Indicator was working fine before 15th April 2022, and it stopped working suddenly. It still works properly on strategy tester, but messing up all points for all points on the graph before 

Besides requiring to post your code as Vladimir commented above, also tell us what build of MetaTrader 5 you are using.

 
Fernando Carreiro #:

Besides requiring to post your code as Vladimir commented above, also tell us what build of MetaTrader 5 you are using.

 
Vladimir Karputov #:

If you do not show your MQL5 code, no one will be able to help you.

It's on MT4,
Here is the code
#property copyright "Created with EABuilder.com"
#property link      "https://www.eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 3
#property indicator_color1 0xFF8C00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 3
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

extern double GAP1 = 3;
extern double GAP2 = 1.5;
extern double Arrow_Separator = 2;
datetime time_alert; //used when sending alert
extern bool Audible_Alerts = true;
extern bool Push_Notifications = true;
double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | SSD @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
   else if(type == "indicator")
     {
      Print(type+" | SSD @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Audible_Alerts) Alert(type+" | Scalpinator Shadow Diamond @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Push_Notifications) SendNotification(type+" | SSD @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, EMPTY_VALUE);
      ArrayInitialize(Buffer2, EMPTY_VALUE);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      
      int barshift_M15 = iBarShift(Symbol(), PERIOD_M15, Time[i]);
      if(barshift_M15 < 0) continue;
      int barshift_M1 = iBarShift(Symbol(), PERIOD_M1, Time[i]);
      if(barshift_M1 < 0) continue;
      
      //Indicator Buffer 1
      RefreshRates();
      if(iRSI(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, i) > 50
      && iRSI(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, i+1) < 50 //Relative Strength Index crosses above fixed value
      && iMA(NULL, PERIOD_M15, 100, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) < Bid //Moving Average < Price
      && iMA(NULL, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) < Bid - GAP1 * myPoint //Moving Average < Price - fixed value
      && Bid > iOpen(NULL, PERIOD_M15, 1+barshift_M15) //Price > Candlestick Open
      && Bid > iOpen(NULL, PERIOD_M15, 2+barshift_M15) //Price > Candlestick Open
      && iMA(NULL, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) > iMA(NULL, PERIOD_M15, 100, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) + GAP2 * myPoint //Moving Average > Moving Average + fixed value
      )
        {
         Buffer1[i] = Low[i] - Arrow_Separator * myPoint - iATR(NULL, PERIOD_M1, 14, barshift_M1); //Set indicator value at Candlestick Low - fixed value - Average True Range
         if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer1[i] = EMPTY_VALUE;
        }
      //Indicator Buffer 2
      RefreshRates();
      if(iRSI(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, i) < 50
      && iRSI(NULL, PERIOD_CURRENT, 14, PRICE_CLOSE, i+1) > 50 //Relative Strength Index crosses below fixed value
      && iMA(NULL, PERIOD_M15, 100, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) > Ask //Moving Average > Price
      && iMA(NULL, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) > Ask + GAP1 * myPoint //Moving Average > Price + fixed value
      && Ask < iOpen(NULL, PERIOD_M15, 1+barshift_M15) //Price < Candlestick Open
      && Ask < iOpen(NULL, PERIOD_M15, 2+barshift_M15) //Price < Candlestick Open
      && iMA(NULL, PERIOD_M15, 50, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) < iMA(NULL, PERIOD_M15, 100, 0, MODE_SMA, PRICE_CLOSE, barshift_M15) - GAP2 * myPoint //Moving Average < Moving Average - fixed value
      )
        {
         Buffer2[i] = High[i] + Arrow_Separator * myPoint + iATR(NULL, PERIOD_M1, 14, barshift_M1); //Set indicator value at Candlestick High + fixed value + Average True Range
         if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer2[i] = EMPTY_VALUE;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

Cruz Solace #: It's on MT4,Here is the code

#property copyright "Created with EABuilder.com"
#property link      "https://www.eabuilder.com"
#property version   "1.00"
#property description ""

Please remember that all MT4 / MQL4 related issues should be posted in the MQL4 and MetaTrader 4 section (located at the end of the forum). A moderator will move this thread for you in due time.

When placing code, please use the "</>" (Alt+S) icon and don't just paste it as normal text.

Your Indicator was build with the EABuilder generator which produces very bad code. Don't use it. Either have someone code it for you or learn to code yourself.

We can't help you here, because the generator produces bad code and even if we were to provide guidance, you would not know how to make the necessary changes.

 
Fernando Carreiro #:

Please remember that all MT4 / MQL4 related issues should be posted in the MQL4 and MetaTrader 4 section (located at the end of the forum). A moderator will move this thread for you in due time.

When placing code, please use the "</>" (Alt+S) icon and don't just paste it as normal text.

Your EA was build with the EABuilder generator which produces very bad code. Don't use it. Either have someone code it for you or learn to code yourself.

We can't help you! Because the generator produces bad code and even if we were to provide guidance you would not know how to make the necessary changes.

Thank you, I understand that.
But could you explain why it was working before last friday, and still works on the tester, but not on live price chart anymore. 
 
Cruz Solace #: Thank you, I understand that. But could you explain why it was working before last friday, and still works on the tester, but not on live price chart anymore. 

There have been no official MT4 updates recently, so your MT4 build should still be 1353 since December 2021.

Only you can answer what happened to your PC on the 15th April.

That being said, since we know that EABuilder produces bad code, we are not going to waste time analysing and debugging the code for you.

However, I did compile your code and attached it to a chart and it seems to be displaying on a live chart (but I have no idea if it is correct or not).


 
Fernando Carreiro #:

There have been no official MT4 updates recently, so your MT4 build should still be 1353 since December 2021.

Only you can answer what happened to your PC on the 15th April.

That being said, since we know that EABuilder produces bad code, we are not going to waste time analysing and debugging the code for you.

However, I did compile your code and attached it to a chart and it seems to be displaying on a live chart (but I have no idea if it is correct or not).


Yes , it's showing on live chart, but it's not coherent with as it shows on the tester.

Also, on the live chart, it's missing the buy signals.
I understand EA builder is not ideal, but it was working fine till last Friday (for almost a month). Suddenly after the easter break , it changed. Started showing excess sell signals against the conditions, also not showing buy signals. That's why I doubt if code is the issue here.
 
  1. EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor STRATEGY BUILDER, ForexRobotAcademy.com, FX EA Builder, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Online Forex Expert Advisor Generator, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    2. EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
      EA builder makes bad code, not checking return codes.

    3. EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

    4. FX EA Builder makes bad code, not checking return codes.
      FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
      FX EA Builder makes bad code, not adjusting stops for the spread.
      FX EA Builder makes bad code, using OrdersTotal directly.

    5. FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
      FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

    Learn to code it, or pay someone (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum #1 (2019)


  2. Please edit your (#4) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

 
Cruz Solace #: Yes , it's showing on live chart, but it's not coherent with as it shows on the tester. Also, on the live chart, it's missing the buy signals.
I understand EA builder is not ideal, but it was working fine till last Friday (for almost a month). Suddenly after the easter break , it changed. Started showing excess sell signals against the conditions, also not showing buy signals. That's why I doubt if code is the issue here.

Did you check the build of your MT4? Is it still 1353?

If not then you were probably updated with a beta version when connected to MetaQuotes demo accounts on April 15th. If that is the case, then don't connect to MetaQuotes demo accounts and only connect to broker demo accounts.

However, if it is due to a beta build, then most probably when an official update to 1353 comes out, then your indicator will not work any-more and it will need to be fixed.

Reason: