calculation of the body size (opening/closing) of an M5 candlestick, resulting in PIPS

Created at 11 Dec 2022, 23:56
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!
TH

thebeinvest

Joined 15.04.2022

calculation of the body size (opening/closing) of an M5 candlestick, resulting in PIPS
11 Dec 2022, 23:56


I need to implement in my algorithm the calculation of the body size (opening/closing) of an M5 candlestick, resulting in PIPS.

Today I run it like this:

(Bars.LastBar.Close - Bars.LastBar.Open)

However, the return of this information is an absolute value.

Example:

(0.80217 - 0.80222) = 0.00005

But I need this result to be in PIPS.

Can someone help me please?


@thebeinvest
Replies

PanagiotisChar
12 Dec 2022, 11:01

Hi there,

Try this

(Bars.LastBar.Close - Bars.LastBar.Open) / Symbol.PipSize

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

thebeinvest
16 Dec 2022, 00:16

RE:

PanagiotisChar said:

Hi there,

Try this

(Bars.LastBar.Close - Bars.LastBar.Open) / Symbol.PipSize

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Thanks for the answer. I love you.

This solved my problem.

I have another question in this context, see if you can help me.

I need this calculation below to be performed only once. I don't want this account running all the time.

That is, every time I open a position, I do this calculation and it is used as a variable in the program, and is no longer recalculated.

var cbodycandlePrevious = pos.TradeType == TradeType.Buy ?
                            ((Bars.Last(1).Open - Bars.Last(1).Close) / Symbol.PipSize)
                            : ((Bars.Last(1).Close - Bars.Last(1).Open) / Symbol.PipSize);


@thebeinvest