how to compare candle body size of two previous candles

Created at 26 Jul 2020, 02: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!
SK

Skypips

Joined 12.02.2019

how to compare candle body size of two previous candles
26 Jul 2020, 02:51


Hi,

Need some help with making this condition. Want to calculate body of previous candle compared against the one before.

 

I have got the following code so far but it doesn't do the right calculation

if (candle1Size < candle2Size) 

// then do something

            double candle1Size = Math.Abs(MarketSeries.Open.Last(1) - MarketSeries.Close.Last(1));
            double candle1SizePips = Math.Round(candle1Size / Symbol.PipSize, 3);

            double candle2Size = Math.Abs(MarketSeries.Open.Last(2) - MarketSeries.Close.Last(2));
            double candle2SizePips = Math.Round(candle2Size / Symbol.PipSize, 3);

 

 


@Skypips
Replies

Skypips
26 Jul 2020, 03:07

RE:

Never mind actually worked :D


@Skypips

al-n
10 Jun 2022, 16:41

what deos (...Symbol.Pip.Size, 3)

double candle1SizePips = Math.Round(candle1Size / Symbol.PipSize, 3);

can someone tell me what this lines does? 

 

i mean in this line:
double candle1Size = Math.Abs(MarketSeries.Open.Last(1) - MarketSeries.Close.Last(1));

-> he defines the variable candle1Size. The (1) in brackets represents the first-last candle. ok, that´s logical. but what happens here then?

double candle1SizePips = Math.Round(candle1Size / Symbol.PipSize, 3);

I mean PIP you can only specify in a price range and not for a spot or market price. And most importantly, what does the 3 mean here?

 

Actually I´m trying to program a breakout for the last candle for example 10 pips above the privious candle. would you solve the conditional decalaration this way?

 

thank you


@al-n

amusleh
14 Jun 2022, 09:40

Hi,

This: 

double candle1SizePips = Math.Round(candle1Size / Symbol.PipSize, 3);

Will round the result of "candle1Size / Symbol.PipSize" to three decimal places.

Symbol.PipSize gives you a symbol 1 pip value in absolute price, for example the EURUSD pip size is 0.0001.

Dividing the candle1Size to Symbol.PipSize will give you the exact number of Pips, for example if candle1Size is 0.0008 and the symbol pip size is 0.0001 then:

0.0008 / 0.0001 = 8


@amusleh

facqtx
05 Apr 2024, 22:07 ( Updated at: 07 Apr 2024, 05:23 )

RE: RE:

Skypips said: 

Never mind actually worked :D

 

 


@facqtx