Indicators: Camarilla Level Pivots

 

Camarilla Level Pivots:

Camarilla Level Pivots.

Author: oneoleguy

 

Thanks for posting this.

Re your concerns:

1. The old MT4 (before Build 600) only supported 8 indicators whereas you have used 9. Perhaps the properties listing of only 8 colors is a hangover from the old MT4? (If so this is something for MetaQuotes to fix.)

2. The lines not extending to the last couple of bars is because the indicator as you have it runs for every tick and redraws for the last couple of bars each time. If these did not happen to coincide with a start of day then your if test inside the loop does not ever pass and so yesterday_high, yesterday_low, and yesterday_close remain uninitialized (defaulting to zero), causing the lines to dive to the bottom of the chart.

The fix is simple: make yesterday_high, yesterday_low, and yesterday_close static by adding the keyword static to their declaration in start(), or make then global, so that either way they retain their values between invocations of start().

(If you had compiled in strict mode under Build 600 or later by adding

#property strict

you would have been warned about this mistake by the warnings "possible use of uninitialized variable 'yesterday_high'" etc.)






 

Thanks for posting this.

Re your concerns:

1. The old MT4 (before Build 600) only supported 8 indicators whereas you have used 9. Perhaps the properties listing of only 8 colors is a hangover from the old MT4? (If so this is something for MetaQuotes to fix.)

2. The lines not extending to the last couple of bars is because the indicator as you have it runs for every tick and redraws for the last couple of bars each time. If these did not happen to coincide with a start of day then your if test inside the loop does not ever pass and so yesterday_high, yesterday_low, and yesterday_close remain uninitialized (defaulting to zero), causing the lines to dive to the bottom of the chart.

The fix is simple: make yesterday_high, yesterday_low, and yesterday_close static by adding the keyword static to their declaration in start(), or make then global, so that either way they retain their values between invocations of start().

(If you had compiled in strict mode under Build 600 or later by adding

#property strict

you would have been warned about this mistake by the warnings "possible use of uninitialized variable 'yesterday_high'" etc.)






 

You know very well that

PivotPoint[i] = (yesterday_high + yesterday_low + yesterday_close)/3;

NOT 

PivotPoint[i] = (Resistance1[i] + Support1[i]) / 2;

But you decided to change something that has been around for tens of years for no reason other than not finding a way to code it.

It was actually very simple, my friend, just replace this:

// Calculate yesterday's High, Low and Close
            
            yesterday_close=  Close[i + 1];
            yesterday_high =  iHigh(Symbol(),PERIOD_D1,1);
            yesterday_low  =  iLow(Symbol(),PERIOD_D1,1);

            range          =  yesterday_high - yesterday_low;

with this:

// Calculate yesterday's High, Low and Close

            yesterday_close=  Close[i + 1];
            int dailyfrac = i / (PERIOD_D1/Period());
            yesterday_high =  iHigh(Symbol(),PERIOD_D1,dailyfrac+1);
            yesterday_low  =  iLow(Symbol(),PERIOD_D1,dailyfrac+1);
            range          =  yesterday_high - yesterday_low;

 
Jose Alberto Pupo Pascoa #:

You know very well that

PivotPoint[i] = (yesterday_high + yesterday_low + yesterday_close)/3;

NOT 

PivotPoint[i] = (Resistance1[i] + Support1[i]) / 2;

But you decided to change something that has been around for tens of years for no reason other than not finding a way to code it.

It was actually very simple, my friend, just replace this:

// Calculate yesterday's High, Low and Close
            
            yesterday_close=  Close[i + 1];
            yesterday_high =  iHigh(Symbol(),PERIOD_D1,1);
            yesterday_low  =  iLow(Symbol(),PERIOD_D1,1);

            range          =  yesterday_high - yesterday_low;

with this:

// Calculate yesterday's High, Low and Close

            yesterday_close=  Close[i + 1];
            int dailyfrac = i / (PERIOD_D1/Period());
            yesterday_high =  iHigh(Symbol(),PERIOD_D1,dailyfrac+1);
            yesterday_low  =  iLow(Symbol(),PERIOD_D1,dailyfrac+1);
            range          =  yesterday_high - yesterday_low;

 
Kg las #:
Hello what is that code 4??