Highest Close minus Lowest Close for last n periods

Created at 22 Dec 2020, 23:53
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!
80

8089669

Joined 31.07.2019

Highest Close minus Lowest Close for last n periods
22 Dec 2020, 23:53


Hi all,

I am new to C#, could anyone help to write code to find "Highest Close - Lowest Close" for the last n periods.

Many Thanks in advance.


@8089669
Replies

PanagiotisCharalampous
23 Dec 2020, 08:18

Hi 8089669,

You need to explain a bit better what are you trying to do. Your description is not very clear. The OHLC information for bars is stored in the robot's Bars property.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

8089669
24 Dec 2020, 03:35

RE:

PanagiotisCharalampous said:

Hi 8089669,

You need to explain a bit better what are you trying to do. Your description is not very clear. The OHLC information for bars is stored in the robot's Bars property.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis,

As of now I am using "Math.Abs(Bars.ClosePrices.Maximum(Periods) - Bars.ClosePrices.Minimum(Periods))/ Symbol.PipSize;" to get the difference between High Close price and Low Close Price for last n periods.

But I want to exclude Last(1) bar and calculate from Last(2) bar.

Just wonder if there is any way to exclude Last(1) from the above formula?

Many Thanks in advance.


@8089669

PanagiotisCharalampous
24 Dec 2020, 07:52

Hi 8089669,

There is no built-in method for this. You need to write your own code which should not be so complicated.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous