Login Page - Create Account

Support Board


Date/Time: Sun, 15 Jun 2025 16:38:15 +0000



Post From: ACSIL - Get Candlestick Type (Bull/Bear)

[2025-05-27 18:37:08]
Dennzisme - Posts: 26
Hello,

Thanks for your reply, this solution sadly did not fix my issue. I don't understand how sierra chart is determining a bullish or bearish candle.
I was going by this logic from another forum post:

1. If the close is below the open, then the bar is down.
2. If the close is above the open, then the bar is up.
3. If the close is the same as the open, then we look at the difference between the current close and the prior close. If the current close is below the prior close, then the bar is down. If the current close is above the prior close, the bar is up. If the current close is the same as the prior close, repeat the algorithm using the next previous bar.

And this is the code that I am currently using to trying to replicate sierra charts bullish/bearish candlesticks:
bool bull = false, bear = false;

// Determine bull/bear candle
if (C < O) // close below open → bearish
{
bear = true;
}
else if (C > O) // close above open → bullish
{
bull = true;
}
else // C == O (doji) → look at earlier bars
{
int checkIndex = i - 1;
bool foundDiff = false;

// Walk backwards until we find a bar whose close differs
while (checkIndex >= 0)
{
float priorClose = sc.Close[checkIndex];
if (C < priorClose) // current close lower than a previous → bearish
{
bear = true;
foundDiff = true;
break;
}
else if (C > priorClose) // current close higher than a previous → bullish
{
bull = true;
foundDiff = true;
break;
}
else
{
--checkIndex; // still equal – keep looking further back
}
}

// Still no difference? Default to bullish
if (!foundDiff)
bull = true;
}

But this is sadly not replicating how sierra chart displays bullish/bearish candlesticks (I have added an attachment below ; the green arrow is pointing to the candle that is bearish, but when I run my code it is bullish)

That is why I was wondering if they have a function in ACSIL to determine which candlestick type it is.

Any help would be greatly appreciated.
imageCandlestick.png / V - Attached On 2025-05-27 18:36:40 UTC - Size: 2.57 KB - 90 views