Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 16:11:44 +0000



[Programming Help] - Candle body size comparison

View Count: 421

[2023-02-02 17:56:57]
DKtrades - Posts: 33
I have a larger formula I'm trying to create, which in part, compares the current candle to the previous candle, in terms of the size of the body (I'm wanting to be alerted when the body size is shrinking and momentum is slowing).

For example, here I want to see that the current candle (which I'm assuming is GREEN with O < C) is smaller in body size than the -1 RED candle (this is just one part of my formula, as this candle may be RED, GREEN or DOJI, but the previous candle here MUST be RED).

I am using:

=AND (O < C, C - O < (O[-1] - C[-1] + (2*TICKSIZE)))

To show that:

* The candle is GREEN (O < C)
and its body is smaller in size than the previous candle ... C - O < (O[-1] - C[-1] + (2*TICKSIZE))

However this is giving me alerts where the -1 candle is SMALLER or equal body size compared to the current candle, and I want it to be BIGGER.

If I can get some help with this part of the formula, I should be able to figure out the rest of it (as I want to also compare the -1 and -2 candles, which both must be RED, and the -2 candle bigger than the -1 candle in body size (OC, ignoring HL tails).

Any help would be very much appreciated. I have searched the forums and was trying to reference another thread I found (Formula for check between H and L of last three bars) but at the moment my alerts are showing some -1 candles that are the same size body or smaller than the current candle, not bigger.
[2023-02-02 19:50:16]
Sawtooth - Posts: 3992
Try this:
=AND (O < C, O[-1] > C[-1], C - O < (O[-1] - C[-1] + (2*TICKSIZE)))
[2023-02-03 14:26:54]
DKtrades - Posts: 33
Thanks Tom. In the end I still had some trouble with (O[-1] - C[-1] + (2*TICKSIZE)) -- but I found that for the rest of the formula, where I use the [-2] candle, I gave that a minimum size (using a number value) and that suits what I need.

Then as the third candle can be red or green (or doji), I wrapped it all up in an OR formula and it's working great. I do love the power and ability of SC to be able to do this kind of thing, even for someone like me without deep knowledge and with the help of someone like you who has it -- very much appreciated!

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account