Custom indicator not working

 

Hi everyone


I am trying to plot a price range with ATR and MA indicator. Here is my code and I receive no error or warning. But lines do not appear in the chart. Anyone has a clue?

         int Countrd_bars=prev_calculated;
   
         for(int i=rates_total-Countrd_bars-1;i>=0;i--)
         {
         EMA[i]=iMA(NULL,PERIOD_CURRENT,9,0,MODE_SMA,PRICE_MEDIAN,0);
         ATR[i]=iATR(NULL,PERIOD_CURRENT,10,0);
         UpperBand[i]=EMA[i]+(Multi*ATR[i]);
         LowerBand[i]=EMA[i]-(Multi*ATR[i]);
   
         }
 

Why don't you use one of the examples from ..\Indicators\Examples?

E.g. take Envelopes.mq5 or BB.mq5 and amend them according your ideas - it's a lot faster.

But make a copy and rename it! Otherwise the next update might overwrite all your changes.

 
Carl Schreiber:

Why don't you use one of the examples from ..\Indicators\Examples?

E.g. take Envelopes.mq5 or BB.mq5 and amend them according your ideas - it's a lot faster.

But make a copy and rename it! Otherwise the next update might overwrite all your changes.

Hi Carl

I do not familiar with examples. I looked at  \Indicators\Examples folder and  Envelopes.mq5 or BB.mq5 were not there

Just SimplePanel.mq4

Maybe because I use MQL4. Right?

 
mohammad gerami: Maybe because I use MQL4. Right?

Yes. So go to the code base and search.

 
mohammad gerami:

Hi everyone


I am trying to plot a price range with ATR and MA indicator. Here is my code and I receive no error or warning. But lines do not appear in the chart. Anyone has a clue?



int Countrd_bars=prev_calculated;
   
         for(int i=rates_total-Countrd_bars-1;i>=0;i--)
         {
         EMA[i]=iMA(NULL,PERIOD_CURRENT,9,0,MODE_SMA,PRICE_MEDIAN,0);
         ATR[i]=iATR(NULL,PERIOD_CURRENT,10,0);
         UpperBand[i]=EMA[i]+(Multi*ATR[i]);
         LowerBand[i]=EMA[i]-(Multi*ATR[i]);
   
         }

 You have to put an "i" at the end of iMA and ATR fonctions

Reason: