Making sense of Camarilla Indicator Pivots

 

Hi guys,


I've been messing around with the Camarilla Indicator and I wanted to get the main pivot values for my EA, can I use iCustom() for that? or should I just pass the code to the EA? but where exactly would I place it? I tried to place it on the onTick() but with a condition of only calculating the pivots when there is a new daily candle, but the values most of the times don't match.


void OnTick()
  {
  
static datetime today;

if (today != iTime (Symbol(), PERIOD_D1, 0))
   {
   today = iTime (Symbol(), PERIOD_D1, 0);
  int    counted_bars=IndicatorCounted();
//---- TODO: add your code here

int cnt=720;

//---- exit if period is greater than daily charts
if(Period() > 1440)
{
Print("Error - Chart period is greater than 1 day.");

}

//---- Get new daily prices & calculate pivots
 day_high=0;
 day_low=0;
 yesterday_open=0;
 today_open=0;
 cur_day=0;
 prev_day=0;

while (cnt!= 0)
{
        if (TimeDayOfWeek(Time[cnt]) == 0)
        {
     cur_day = prev_day;
        }
        else
        {
     cur_day = TimeDay(Time[cnt]- (GMTshift*3600));
        }
        
        if (prev_day != cur_day)
        {
                yesterday_close = Close[cnt+1];
                today_open = Open[cnt];
                yesterday_high = day_high;
                yesterday_low = day_low;

                day_high = High[cnt];
                day_low  = Low[cnt];

                prev_day = cur_day;
        }
   
   if (High[cnt]>day_high)
   {
      day_high = High[cnt];
   }
   if (Low[cnt]<day_low)
   {
      day_low = Low[cnt];
   }
        
        cnt--;

}



H3 = ((yesterday_high - yesterday_low)* D3) + yesterday_close;
H4 = ((yesterday_high - yesterday_low)* D4) + yesterday_close;
L3 = yesterday_close - ((yesterday_high - yesterday_low)*(D3));
L4 = yesterday_close - ((yesterday_high - yesterday_low)*(D4));  
L5 = yesterday_close - (H5 - yesterday_close);
H5 = (yesterday_high/yesterday_low)*yesterday_close;

Print ("H3: " + DoubleToStr(H3));
Print ("H4: " + DoubleToStr(H4));
Print ("H5: " + DoubleToStr(H5));
Print ("L3: " + DoubleToStr(L3));
Print ("L4: " + DoubleToStr(L4));
Print ("L5: " + DoubleToStr(L5));

}
 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
Thank you and sorry for that
 
angomes:

Hi guys,


I've been messing around with the Camarilla Indicator and I wanted to get the main pivot values for my EA, can I use iCustom() for that? or should I just pass the code to the EA? but where exactly would I place it? I tried to place it on the onTick() but with a condition of only calculating the pivots when there is a new daily candle, but the values most of the times don't match.


I solved this by using ObjectGet() and get the values from the lines drawn in the chart by the indicator
Reason: