Candle body size

Created at 13 Feb 2022, 08:51
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!
VY

vypchela

Joined 22.01.2022

Candle body size
13 Feb 2022, 08:51


Hello, please tell me how to find the size of the body of the candle.
For MT4, I do this: if(int(MathRound((Open[0] - Close[0]) / Point)) >= 70)

How to do it for cTrader,  thanks


@vypchela
Replies

amusleh
14 Feb 2022, 08:43

Hi,

In cTrader automate are available bars on your chart are inside a collection called Bars, you can access each bar with an index integer, example:

var bar = Bars[myBarIndex];
// To use Math functions you have to add using System; on top of your indicator/cBot
// The .NET Math.Abs method gives you the absolute value of a number
var barBodyRange = Math.Abs(bar.Open - bar.Close);

 


@amusleh

vypchela
14 Feb 2022, 10:48 ( Updated at: 15 Feb 2022, 07:52 )

RE: Thanks I will try this.

amusleh said:

Hi,

In cTrader automate are available bars on your chart are inside a collection called Bars, you can access each bar with an index integer, example:

var bar = Bars[myBarIndex];
// To use Math functions you have to add using System; on top of your indicator/cBot
// The .NET Math.Abs method gives you the absolute value of a number
var barBodyRange = Math.Abs(bar.Open - bar.Close);

 


@vypchela

vypchela
15 Feb 2022, 07:56

Body size equal to 10 pips

 

Am I doing it right, I need to find the size of the body equal to 10 pips of a bearish candle
var bar = Bars[1];
var barBodyRange = Math.Abs(bar.Open - bar.Close)/ Symbol.PipSize;
if (barBodyRange  >= 10)
Thanks again.

 


@vypchela

amusleh
15 Feb 2022, 08:29

RE: Body size equal to 10 pips

vypchela said:

 

Am I doing it right, I need to find the size of the body equal to 10 pips of a bearish candle
var bar = Bars[1];
var barBodyRange = Math.Abs(bar.Open - bar.Close)/ Symbol.PipSize;
if (barBodyRange  >= 10)
Thanks again.

 

Hi,

Yes, your calculation is correct.

The 1 bar index means the second bar on your chart from beginning, so be sure to use the correct indices when working with bars.


@amusleh