Indicator Null/Empty Value

To add comments, please log in or register
SJCFX
238
SJCFX  

Hi all,

So i have been going around in circles trying to use an indicator within an EA i have built, however i'm struggling to recognise the values behind 2 of the buffers are populated with a value. I'm fully aware of how EMPTY_VALUE works and have previously built EAs using indicators with this function with no problem.

Below is the code within the Indicator:

void OnInit()
  {
   int t1;

//---- indicators
   SetIndexStyle(0,DRAW_ARROW,EMPTY,ArrowSize,LongColour);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,ArrowSize,ShortColour);
   SetIndexStyle(2,DRAW_LINE,RSIStyle,RSIWidth,RSIColour);
   
   t1=3;
   while(t1<=5)
     {
      SetIndexStyle(t1,DRAW_NONE);
      t1++;
     }

//----
   SetIndexBuffer(0, bullishDivergence);
   SetIndexBuffer(1, bearishDivergence);
   SetIndexBuffer(2, rsi);
   SetIndexBuffer(3, divergencesType);
   SetIndexBuffer(4, divergencesRSIDiff);
   SetIndexBuffer(5, divergencesPriceDiff);  
   
//----
   SetIndexArrow(0,LongArrowCode);
   SetIndexArrow(1,ShortArrowCode);

If the conditions are met, the arrows are populated, however there is no 'else' feature if conditions are not met so i can only assume EMPTY_VALUE is used as default?

bullishDivergence[currentTrough] = rsi[currentTrough];

Below is a screenshot of the data window when backtesting which shows as blank for buffers 0 and 1 when no arrow is generated:

then when an arrow is generated, i can correctly see data value behind it:



I have tried using the following but i can't seem to generate anything off them. I have also tried >0 which also doesn't work.

int fill_levels()
  {
   cur_buy=iCustom(Symbol(),0,"RSI_Divergence2",RSI_settings,RSI_period,RSI_applied_price,DrawIndicatorTrendLines,DrawPriceTrendLines,DisplayAlert,DisplayClassicalDivergences,DisplayHiddenDivergences,LongColour,ShortColour,LongArrowCode,ShortArrowCode,ArrowSize,RSIColour,RSIStyle,RSIWidth,rsilower,rsiupper,0,1);   
   cur_sell=iCustom(Symbol(),0,"RSI_Divergence2",RSI_settings,RSI_period,RSI_applied_price,DrawIndicatorTrendLines,DrawPriceTrendLines,DisplayAlert,DisplayClassicalDivergences,DisplayHiddenDivergences,LongColour,ShortColour,LongArrowCode,ShortArrowCode,ArrowSize,RSIColour,RSIStyle,RSIWidth,rsilower,rsiupper,1,1);
     {
         if(cur_buy!=EMPTY_VALUE)return 1;
         if(cur_sell!=EMPTY_VALUE)return 0;
     }
   return -1;
  }

Any tips or help here would be very useful!

Jefferson Metha
2365
Jefferson Metha  
Why not set buffer styles as property values as opposed to in the init function
SJCFX
238
SJCFX  
Jefferson Metha:
Why not set buffer styles as property values as opposed to in the init function

Thank you for the comment Jefferson - will this solve the issue of recognising buffer 0 and 1? I suppose my underlying question is, should i be referring to EMPTY_VALUE or something else?  

To add comments, please log in or register