Get data of 1 candle before when going from daily to Weekly/Monthly Chart.
Created at 06 Jan 2022, 19:10
Get data of 1 candle before when going from daily to Weekly/Monthly Chart.
06 Jan 2022, 19:10
I use my indicator mostly on Daily charts, but when I go from Daily to Weekly/Monthly I have to recalculate because the date is not the same.
Even if I go from H1 to D1 it will happen, because the hour is not the same.
On H4, bar is 24/05/2021 4pm. On D1, bar is 24/05/2021 9pm. On W1, bar is 23/05/2021 9pm or 30/05/2021 9pm. On M1, bar is 31/05/2021
How can tell my indicator to go 1 candle before when I timeframe up?
IconExists = true;
DateTime IconTime2;
if (IconExists)
{
IconTime2 = VWAPIcon2.Time;
}
else
{
IconTime2 = v2.Time;
}
double VWAP_Price = VWAP[Bars.OpenTimes.GetIndexByExactTime(IconTime2)];
double Source_Price = VWAPTPrice[Bars.OpenTimes.GetIndexByExactTime(IconTime2)];
amusleh
07 Jan 2022, 07:21
Hi,
Not sure exactly what you are looking for, but when you change a chart time frame the indicator is re-initialized, so cTrader will call the indicator Initialize method and everything is recalculated.
If you want to get one candle before just minus one the index, if you have date time then first change it to index by using "Bars.OpenTimes.GetIndexByTime" then minus one the result.
@amusleh