Can't get Indicator pivot points to match on EA code

Can't get Indicator pivot points to match on EA code

Manage alerts

Loading saved threads...

André Gomes · External communityPost link
External question — Stack Overflow Stack Exchange Author: André Gomes Original post: https://stackoverflow.com/questions/62574455 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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)); }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: André Gomes Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/62574455 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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)); }

Cancel quote

Checking account access…