Calculating Mid price OHLC
Calculating Mid price OHLC
23 Sep 2020, 13:12
I do not currently use CTrader but I am thinking of moving my algo to the platform
I see from this post that Ctrader uses bid prices to construct candles, i.e. the open, high, low and close of a candle displayed on a 1 hour chart would be the bid price and as far as I can see you can’t display a chart with candles built from ask or mid prices …
https://ctrader.com/forum/cbot-support/24056
I use the mid price as the reference point for my algo
Is it possible in cTrader Automate to programmatically populate a data structure with the values that would make up a 1 hour candle constructed from mid prices, i.e. open mid, high mid, low mid and close mid?
I don’t want to display these values on a chart, I just want to hold them in something like an array.
Is GetTicks() the way to do this, i.e. get all the ticks from e.g. 10:00 am and 0 seconds to 10:59 and 59 seconds, then convert the ticks to mid price using the ask and the bid and then select the open, high, low and close from the mid price ticks to give me 4 values representing a 1 hour candle constructed from mid prices?
Also is GetTicks() able to get every tick in a 1 hour time frame or does it miss ticks, for example in MT4 the on-tick event is triggered by a tick, but if your algo is still processing this tick when the next tick arrives it will miss this next tick.
Thank you
Mark
Replies
marksnsparkle
23 Sep 2020, 15:26
RE:
PanagiotisCharalampous said:
Hi Mark,
Is it possible in cTrader Automate to programmatically populate a data structure with the values that would make up a 1 hour candle constructed from mid prices, i.e. open mid, high mid, low mid and close mid?
Yes this is possible
Is GetTicks() the way to do this, i.e. get all the ticks from e.g. 10:00 am and 0 seconds to 10:59 and 59 seconds, then convert the ticks to mid price using the ask and the bid and then select the open, high, low and close from the mid price ticks to give me 4 values representing a 1 hour candle constructed from mid prices?
Yes you should use GetTicks() for this.
Also is GetTicks() able to get every tick in a 1 hour time frame or does it miss ticks, for example in MT4 the on-tick event is triggered by a tick, but if your algo is still processing this tick when the next tick arrives it will miss this next tick.
This is how it works in cTrader as well but this should not affect historical data. Ticks are stored on the server even if your client does not process them.
Best Regards,
Panagiotis
Thank you for the reply PanagiotisCharalampous ... that's great news!
@marksnsparkle
PanagiotisCharalampous
23 Sep 2020, 14:13
Hi Mark,
Yes this is possible
Yes you should use GetTicks() for this.
This is how it works in cTrader as well but this should not affect historical data. Ticks are stored on the server even if your client does not process them.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous