Why always shows the open price???
Why always shows the open price???
27 Jul 2020, 10:25
Hi there,
I'm trying to write a program to trade my DAX30.4H
Here is the problem.
I want to print out the last bar "close price" but it always shows the "open price".
there is the code.
Print("closeprice: " + Bars.ClosePrices);
Please advice, thank you!
Mason
Replies
pankuolung0804
27 Jul 2020, 11:13
RE:
PanagiotisCharalampous said:
Hi pankuolung0804,
Try the below
Print("closeprice: " + Bars.ClosePrices.Last(1));
Best Regards,
Panagiotis
Thanks your info.
It looks work, does the cTrader can't handle the last bar close? it can handle the previous bar close?
Thank you!
@pankuolung0804
PanagiotisCharalampous
27 Jul 2020, 11:14
Hi pankuolung0804,
If you mean the current bar then use Last(0).
Best Regards,
Panagiotis
@PanagiotisCharalampous
pankuolung0804
27 Jul 2020, 11:29
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi pankuolung0804,
If you mean the current bar then use Last(0).
Best Regards,
Panagiotis
Please see the image. if I use the last(0), it always shows the open price? is the backtest setting problem(open price data)?
@pankuolung0804
PanagiotisCharalampous
27 Jul 2020, 11:41
Hi pankuolung0804,
If you use the code in OnBar then this is what you should expect. When the bar opens then the close price is the same with the open price.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
27 Jul 2020, 10:32
Hi pankuolung0804,
Try the below
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous