Last Candle Open and Close?

Created at 17 Mar 2023, 15:52
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!
MJ

mj40kfanatic

Joined 17.03.2023

Last Candle Open and Close?
17 Mar 2023, 15:52


Hi everyone, 

i'm very new to cAlgo, i'm trying to call the Open and Close values  for the candle previous to the current candle on the chart
I have tried many different values and combinations of values for Last but it makes no difference

any help would be greatly appreciated


double lastCandleOpen = Bars.OpenPrices.Last(1);
double lastCandleClose = Bars.ClosePrices.Last(1);

@mj40kfanatic
Replies

PanagiotisChar
17 Mar 2023, 16:49

Hi there,

Try 

double lastCandleOpen = Bars.OpenPrices.Last(0);
double lastCandleClose = Bars.ClosePrices.Last(0);

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

mj40kfanatic
17 Mar 2023, 17:27

RE:

PanagiotisChar said:

Hi there,

Try 

double lastCandleOpen = Bars.OpenPrices.Last(0);
double lastCandleClose = Bars.ClosePrices.Last(0);

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Thanks for the response. I have tried Last(0), Last(1), Last(2) and Last(3). It doesnt change the values for me. The values i get are for the close of the previous candle and the open of the current candle.


@mj40kfanatic