Refrencing Daily candle in a 5 minute bot

Created at 27 Dec 2020, 12:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AN

analogpermutations

Joined 27.12.2020

Refrencing Daily candle in a 5 minute bot
27 Dec 2020, 12:13


How do I reference the previous days candle on a cBot???

Right now i have 

 

private Bars daily;
daily = MarketData.GetBars(TimeFrame.Daily);

double yHigh = daily.HighPrices.Last(1);

I expect this to give me the last days high price, instead...I get this.

 

26/11/2020 00:00:00.000 | Backtesting started
26/11/2020 00:00:00.000 | Crashed in OnStart with NullReferenceException: Object reference not set to an instance of an object.
26/11/2020 00:00:00.000 | Backtesting was stopped


I also tried

 

double yHigh = daily.HighPrices.Last(daily.Count - 1);

To see if maybe I was referencing the wrong side of the array, but it still crashes.

Whats the issue here?

 

 

Please help me reference the previous day candle within my 5 Minute bot.

 


@analogpermutations
Replies

analogpermutations
28 Dec 2020, 00:24 ( Updated at: 28 Dec 2020, 00:25 )

I cant believe nobody knows how to do this??  

Like why does it seem like it should be so simple, yet isn't.

Ive now tried this as well.

 

private MarketSeries daily;

protected override void OnStart(){
  daily = MarketData.GetSeries(Symbol, TimeFrame.Daily);
}

protected override void OnTick(){
   Print(daily.High.LastValue);
}


Still get this error

17/08/2020 00:00:00.162 | Backtesting started
17/08/2020 00:00:00.162 | Crashed in OnStart with NullReferenceException: Object reference not set to an instance of an object.
17/08/2020 00:00:00.162 | Backtesting was stopped

WHY!!??


@analogpermutations

PanagiotisCharalampous
28 Dec 2020, 09:49

Hi analogpermutations,

Please provide the complete cBot code, cBot parameters and steps to reproduce the problem.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous