Basic Bars & Moving Average Question
Basic Bars & Moving Average Question
17 Jul 2020, 03:22
I am writing a bot that looks at Renko candles in combination with a moving average. I have a basic question which is not answered anywhere in the docs and although I think I know the answer to my question, I'll ask it anyway in order to get a certain/definitive answer. For example, so see if the price of the last candle has overlapped the moving average value, I do this:
var bar = Bars.Last(1);
var maCurr = ma.Result.Last(1);
return maCurr >= bar.Low && maCurr <= bar.High;
Now, my question is this (specifically for Renko charts, but my guess is that the answer should apply to all chart types):
Does "Bars.Last(0)" return the currently active bar (ie: the bar which is still being painted/altered (for the case of Renko, the candle which has still not completed a move across the Renko pip size)) or does it return the latest closed/completed bar? Does the same logic hold for accessing moving-average values?
Another way of asking this: is my above code correct if I wish to check the value of the last closed/completed bar against the last completed MA value?
Thank you & sorry for asking such a bonehead question, I'm just looking for a canonical answer. Either way, it might be good to add a statement clarifying this to the docs.
Replies
rgasch
17 Jul 2020, 11:45
RE:
Thank you for your confirmation ...
PanagiotisCharalampous said:
Hi rgasch,
Does "Bars.Last(0)" return the currently active bar (ie: the bar which is still being painted/altered (for the case of Renko, the candle which has still not completed a move across the Renko pip size))
Yes this is the case.
Does the same logic hold for accessing moving-average values?
Yes
is my above code correct if I wish to check the value of the last closed/completed bar against the last completed MA value?
Yes
Best Regards,
Panagiotis
@rgasch
PanagiotisCharalampous
17 Jul 2020, 08:32
Hi rgasch,
Yes this is the case.
Yes
Yes
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous