Open and Close Bars

Created at 25 Nov 2020, 00:34
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!
MY

MysticDark

Joined 24.11.2020

Open and Close Bars
25 Nov 2020, 00:34


Hi, i've a problem with bars.

i've noted i'm wrong on how i use bars because without lines involving bars the bot do the orders and all.

What is wrong also simply in this? (nothing i write on bars never run)

if (Bars.OpenPrices.LastValue < Bars.ClosePrices.LastValue)

{ 

  bool1 = true; 

}

Don't run at all with OnBars, with OnTick run but watching the backtest = no, the bars interested are both bullish and bearish, when them must be all bullish.


@MysticDark
Replies

MysticDark
25 Nov 2020, 05:35

Don't worry guys: i've solved.

 

The trouble was that if you use OnBar(), open and close price of the last bar will be the same, because is the just opened bar.

You must use the values of the previous bar (example Bars.OpenPrices.Last(1) for the open price).

 


@MysticDark