Can't find right buffer for iCustom MT5

 

I'm trying to call iCustom from attached volume indicator but no success.

Indicator shows Rising and Climax volume.
I need to get the buffer which shows red or green bar, it means Bullish and Bearish Climax.


Buffers from the volume indicator

double        Phantom[], Normal[], PVA[], PVA_Colors[];
double PVA_Colors[];
ArraySetAsSeries(PVA_Colors,true);

 if(!iGetArray(handle_iPVSRA,3,start_pos,count,PVA_Colors))
     {
      return(false);
     }   
if(PVA_Colors[1]!=EMPTY_VALUE)

Files:
 
 
      SetIndexBuffer(2, PVA, INDICATOR_DATA);
      SetIndexBuffer(3, PVA_Colors, INDICATOR_COLOR_INDEX);
      ArraySetAsSeries(PVA, true);
      ArraySetAsSeries(PVA_Colors, true);
      PlotIndexSetInteger(2, PLOT_DRAW_TYPE, DRAW_COLOR_HISTOGRAM);
      PlotIndexSetInteger(2, PLOT_LINE_WIDTH, Bar_Width);
      PlotIndexSetInteger(2, PLOT_COLOR_INDEXES, 4);
      PlotIndexSetInteger(2, PLOT_LINE_COLOR, 0, Bull_Climax);
      PlotIndexSetInteger(2, PLOT_LINE_COLOR, 1, Bear_Climax);
      PlotIndexSetInteger(2, PLOT_LINE_COLOR, 2, Bull_Rising);
      PlotIndexSetInteger(2, PLOT_LINE_COLOR, 3, Bear_Rising);
      PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0);
You read the color buffer, index three (3). Index 3 has no color values.
 
William Roeder #:
You read the color buffer, index three (3). Index 3 has no color values.

Hi William,

Yeah, he says he wants to read the color buffer.

But timmytrade, take in mind that, as Wiliiam have said, the data itself is not color values, but rather an integer value, starting from 0, that represents which color to use, depends on what is set on the custom indicator.


timmytrade:

I'm trying to call iCustom from attached volume indicator but no success.

Indicator shows Rising and Climax volume.
I need to get the buffer which shows red or green bar, it means Bullish and Bearish Climax.


Buffers from the volume indicator


You haven't shared enough from your code to determine what is your problem.

For example, what happens in the iGetArray function that, I assume, actually responsible for getting the value.

Also- You weren't clear enough about what is the problem.

Do you get a value, but not the one you've expected?

Do you get no value at all?

What does it mean 'I'm trying....but no success.'?

 
AMI289 #: as Wiliiam have said, the data itself is not color values,

Correct the indicator.

 
William Roeder #:

Correct the indicator.

He can still use it,

He just have to look thru the indicator's code and figure out which index represents the green and red colors, which are the colors he's asking about,

Than he can use it to implement his own strategy.

But I am still unclear as to what exactly is the problem he's facing, since he haven't shared enough information or code.

 

Ok, lets keep it simple.

Let say I want to Buy if there was a green bar and want so Sell if there was a red bar.

 

Color buffer is always different than EMPTY_VALUE in your case.

You should check if color buffer (the number 3) has values 0,1,2,3, according to what is coded inside indicator

         // Apply Correct Color to bars
         if (va == 1)
         {
            PVA[i] = (double)Volume[i];
            // Bull Candle
            if (Close[i] > Open[i])
            {
               PVA_Colors[i] = 0;
            }
            // Bear Candle
            else if (Close[i] <= Open[i])
            {
               PVA_Colors[i] = 1;
            }
            // Sound & Text Alert
            if ((i == 0) && (Alert_Allowed) && (Alert_On))
            {
               Alert_Allowed = false;
               Alert(Broker_Name_In_Alert, ":  ", Symbol(), "-", Period(), "   PVA alert!");
            }
         }
         else if (va == 2)
         {
            PVA[i] = (double)Volume[i];
            if (Close[i] > Open[i])
            {
               PVA_Colors[i] = 2;
            }
            if (Close[i] <= Open[i])
            {
               PVA_Colors[i] = 3;
            }
         }
 
Fabio Cavalloni #:

Color buffer is always different than EMPTY_VALUE in your case.

You should check if color buffer (the number 3) has values 0,1,2,3, according to what is coded inside indicator

It works this way.
if(!iGetArray(handle_iPVSRA,3,start_pos,count,PVA_Colors))
     {
      return(false);
     }   
if(PVA_Colors[1]==1)
        do something...
     }   
if(PVA_Colors[1]==2)
        do something...
     }   
if(PVA_Colors[1]==3)
        do something...
The only problem is color value 0, which is green color.

If I use it this way, EA opens just random trades as soon as I start tester. 

if(PVA_Colors[1]==0)
 

If you only need value of last closed candle, set 'start_pos' to 1 and 'count' to 1. Then access PVA_Colors[0].

You are copying more values even if you need only the last one. This is not a good idea, you are wasting time and resources.

 
Fabio Cavalloni #:

If you only need value of last closed candle, set 'start_pos' to 1 and 'count' to 1. Then access PVA_Colors[0].

You are copying more values even if you need only the last one. This is not a good idea, you are wasting time and resources.

Thanks!

Works great!