Calculation using 2 arrays indicator issue

 

Hi all,

So i am building an indicator which stores 2 values in an array which are to be used for the shift function in the High, Low and the standard rsi indicator.

However, i seem to be having an issue calculating the movement between the high and low and the rsi when using the shifts from each array. The movement calculation defined as (low-high)/high.

Below is the code i have tried:

         int currentLow = shift;
         int currentHigh = GetPriceLastHigh(shift);    
         if(MathAbs((Low[currentLow]-High[currentHigh])/High[currentHigh])>MathAbs((rsi[currentLow]-rsi[currentHigh])/rsi[currentHigh]))

Should the above criteria be met then a buffer is populated with a value. When running with the above, all indicator values are blank.

I have tried changing the if statement to something basic such as the below and the indicator values are populated

        int currentLow = shift;
        int currentHigh = GetPriceLastHigh(shift);    
        if(Low[currentLow]>High[currentHigh])

I know the division calculations are causing me an issue but unfortunately after numerous attempts i am unable to resolve.

Any help or pointers in the right direction would be a great help, thank you in advance

 
SJCFX:

Hi all,

So i am building an indicator which stores 2 values in an array which are to be used for the shift function in the High, Low and the standard rsi indicator.

However, i seem to be having an issue calculating the movement between the high and low and the rsi when using the shifts from each array. The movement calculation defined as (low-high)/high.

Below is the code i have tried:

Should the above criteria be met then a buffer is populated with a value. When running with the above, all indicator values are blank.

I have tried changing the if statement to something basic such as the below and the indicator values are populated

I know the division calculations are causing me an issue but unfortunately after numerous attempts i am unable to resolve.

Any help or pointers in the right direction would be a great help, thank you in advance

ok so managed to partially get this working, defining the High, Low and RSI values as double prior to the calculation before the buffer seems to have now fixed the issue, however still no luck on the division calculation in the IF statement - any ideas?

 
SJCFX:

ok so managed to partially get this working, defining the High, Low and RSI values as double prior to the calculation before the buffer seems to have now fixed the issue, however still no luck on the division calculation in the IF statement - any ideas?

this is the code i have added so far, appreciate it needs to be tidied up but for simplicity i have gone the long way about it:


    int currentPeak = shift;
    int currentTrough = GetPriceLastTrough(shift);
    double lowprice = Low[currentTrough], highprice = High[currentPeak];
    double lowvol = rsi[currentTrough], highvol = rsi[currentPeak]; 
    double pricemvmt = MathAbs((highprice-lowprice)/lowprice);   
    double volmvmt = MathAbs((highvol-lowvol)/lowvol);

as above code stands, all values for the indicator go blank/empty, however if i comment out the row "double volmvmt....." the indicator values (buffers) are populated as expected.

When digging into the details i have pulled some data points for context:

highvol = 46.2062

lowvol = 39.4595

Any ideas???