Help needed with Pivot style indicator

 

Hi there


I am trying to modify a Pivot Point indicator which maps pivot points on all timeframes.

The particular methodology I wish to adopt uses values from the prior 3 periods (eg previous 3 weekly bars for Weekly Pivots).


The original code in the pivot indicator (for weekly values) used this to grab previous week's values:


prices[PRICE_HIGH] = iHigh (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_LOW] = iLow (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_OPEN] = iOpen (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_CLOSE] = iClose(NULL,PERIOD_W1,iBarIndex);


I have modified this to the following (I do not use Open Price so remains unchanged):


prices[PRICE_HIGH] = High[iHighest(NULL, PERIOD_W1,MODE_HIGH,3,iBarIndex)];
prices[PRICE_LOW] = Low[iLowest(NULL, PERIOD_W1,MODE_LOW,3,iBarIndex)];
prices[PRICE_OPEN] = iOpen (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_CLOSE] = iClose(NULL,PERIOD_W1,iBarIndex);


With these modification the weekly pivot figures work fine when viewing chart in the Weekly timeframe ONLY. As soon as I switch timeframes the results all become slightly distorted.


I have tried the same approach with modifying several different pivot indicators and the same thing happens. What am I doing wrong?


Have attached indicator I am currently working on modifying.


Thanks

 
stebonachi:

Hi there


I am trying to modify a Pivot Point indicator which maps pivot points on all timeframes.

The particular methodology I wish to adopt uses values from the prior 3 periods (eg previous 3 weekly bars for Weekly Pivots).


The original code in the pivot indicator (for weekly values) used this to grab previous week's values:


prices[PRICE_HIGH] = iHigh (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_LOW] = iLow (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_OPEN] = iOpen (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_CLOSE] = iClose(NULL,PERIOD_W1,iBarIndex);


I have modified this to the following (I do not use Open Price so remains unchanged):


prices[PRICE_HIGH] = High[iHighest(NULL, PERIOD_W1,MODE_HIGH,3,iBarIndex)];
prices[PRICE_LOW] = Low[iLowest(NULL, PERIOD_W1,MODE_LOW,3,iBarIndex)];
prices[PRICE_OPEN] = iOpen (NULL,PERIOD_W1,iBarIndex);
prices[PRICE_CLOSE] = iClose(NULL,PERIOD_W1,iBarIndex);


With these modification the weekly pivot figures work fine when viewing chart in the Weekly timeframe ONLY. As soon as I switch timeframes the results all become slightly distorted.


I have tried the same approach with modifying several different pivot indicators and the same thing happens. What am I doing wrong?


Have attached indicator I am currently working on modifying.


Thanks



Hi Sebonachi

iHighest() etc. return the shift of the highest bar on the timeframe specified (PERIOD_W1), but High[] returns the high for that shift on the current time frame. For example, if iHighest() returns 2, High[2] will be different on different timeframes. Try iHigh() instead of High[], etc. For example:

prices[PRICE_HIGH] = iHigh( NULL, PERIOD_W1, iHighest( NULL, PERIOD_W1, MODE_HIGH,3, iBarIndex ) );

Cheers

Jellybean

 
Jellybean:

Hi Sebonachi

iHighest() etc. return the shift of the highest bar on the timeframe specified (PERIOD_W1), but High[] returns the high for that shift on the current time frame. For example, if iHighest() returns 2, High[2] will be different on different timeframes. Try iHigh() instead of High[], etc. For example:

prices[PRICE_HIGH] = iHigh( NULL, PERIOD_W1, iHighest( NULL, PERIOD_W1, MODE_HIGH,3, iBarIndex ) );

Cheers

Jellybean

You are a lifesaver Jellybean. This worked a treat.


Now off to try and get similar figures for Quarterly and Yearly periods.....is this even possible?


Many thanks

Stebs

 
stebonachi:

You are a lifesaver Jellybean. This worked a treat.


Now off to try and get similar figures for Quarterly and Yearly periods.....is this even possible?


Many thanks

Stebs

Glad to help.

To work out the quarterly and yearly pivots, you should just be able to use the MN timeframe and identify the monthly bars that start and end the period and use those in iHighest() with the monthly period etc.

Cheers

Jellybean

 
stebonachi wrote >>

You are a lifesaver Jellybean. This worked a treat.

Now off to try and get similar figures for Quarterly and Yearly periods.....is this even possible?

Many thanks

Stebs

Hi,

Could you post you Quarterly Pivot Indicator,

I would love to test it out.

Thanks

 
Penna111:

Hi,

Could you post you Quarterly Pivot Indicator,

I would love to test it out.

Thanks

Yeah no problem. Enjoy.