Buffer dosent show Value?

 

Hello Everyone, 

First I just want to say thanks a lot for your advice in advanced.. :)

So I have the following issue.

I created an indicator using custom indicators by importing them through iCustom. If I simply put the iCustom = IndicatorBuffer I get a Value in my Buffer which is acurate and works the way I want it to in the DATA window. 

Now I don't however wan't the indicator value one to one. What I did next was basicly take the average of the past 3 values so that the indicator would be smoother. This changed, but now the Values in the Data window disapeared. Any helpful insights? Thanks a lot :)

See the code attached keep in mind this isn't the indicator one to one since its a payed, but the principle is the same.


//+------------------------------------------------------------------+
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;
            
   
      
   Limit=rates_total-prev_calculated;
   if (prev_calculated>0)
      Limit++;
      

   
   for (int i=Limit-1; i>=0; i--)
   
      {

         Sentiment_BUY=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i);
         Sentiment_BUY1=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i+1);
         Sentiment_BUY2=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i+2);
       
       if(TimeHour(Time[i])<EndHour && TimeHour(Time[i])>StartHour)
      
      {
         Sentiment[i]   =  (Sentiment_BUY*Sentiment_BUY1*Sentiment_BUY2)/3;
        
       }
       
       
       
     }      
      
//--- return value of prev_calculated for next call
   return(rates_total);
  }


And Here is the one which shows up in the data window:

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;
            
   
      
   Limit=rates_total-prev_calculated;
   if (prev_calculated>0)
      Limit++;
      

   
   for (int i=Limit-1; i>=0; i--)
   
      {

         Sentiment_BUY=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i);
         Sentiment_BUY1=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i+1);
         Sentiment_BUY2=iCustom(Symbol(),PERIOD_CURRENT,"Custom Indicator",1,i+2);
       
       if(TimeHour(Time[i])<EndHour && TimeHour(Time[i])>StartHour)
      
      {
         Sentiment[i]   =  Sentiment_BUY;
        
       }
       
       
       
     }      
      
//--- return value of prev_calculated for next call
   return(rates_total);
  }

Thank you for your help :)

 

Average should be calculated using SUM, not multiplication.

This:

(Sentiment_BUY*Sentiment_BUY1*Sentiment_BUY2)/3;
Should be like this:
(Sentiment_BUY+Sentiment_BUY1+Sentiment_BUY2)/3;
 
Benjamin Riedmueller:

Hello Everyone, 

First I just want to say thanks a lot for your advice in advanced.. :)

So I have the following issue.

I created an indicator using custom indicators by importing them through iCustom. If I simply put the iCustom = IndicatorBuffer I get a Value in my Buffer which is acurate and works the way I want it to in the DATA window. 

Now I don't however wan't the indicator value one to one. What I did next was basicly take the average of the past 3 values so that the indicator would be smoother. This changed, but now the Values in the Data window disapeared. Any helpful insights? Thanks a lot :)

See the code attached keep in mind this isn't the indicator one to one since its a payed, but the principle is the same.



And Here is the one which shows up in the data window:

Thank you for your help :)

Also, you can move the icustom inside the if condition. This will speed up your code a little bit.

 
Ramon Sobrevals Arce #:

Average should be calculated using SUM, not multiplication.

This:

Should be like this:

Thanks a lot, I feel really stupid for not having noticed this ;( xD