OnBar() data incorrect / wrong / bad
OnBar() data incorrect / wrong / bad
28 Oct 2019, 09:59
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { // Put your initialization logic here } protected override void OnBar() { int index = MarketSeries.Close.Count - 1; int Bot_IndexLast = index - 1; // Put your core logic here Print("-----------------"); Print("MarketSeries.Close[{0}] = {1}", Bot_IndexLast, MarketSeries.Close[Bot_IndexLast]); Print("MarketSeries.Close[{0}] = {1}", index, MarketSeries.Close[index]); } protected override void OnStop() { // Put your deinitialization logic here } } }
as you can see the last index doesnt match. i havent used cAlgo in a few months (mainly as my last post was never replied to). i come back to today and see new behaviour above. please advise.
Replies
buccinator
30 Oct 2019, 23:51
i see, my bad, thank you for the confirmation. i only raised this because i when i last coded (few months ago) i did not notice this behaviour. it seemed to be that the next/current OnBar() was already closed. i understand now that the next/current OnBar() is not closed until the next cycle. once again, thank you for the confirmation.
@buccinator
PanagiotisCharalampous
29 Oct 2019, 08:51
Hi buccinator,
Your values do not match because you are printing the close value of the current bar which will probably change when the bar closes. See below how you should have implemented this test
Best Regards,
Panagiotis
@PanagiotisCharalampous