Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 10:59:36 +0000



[Programming Help] - ACSIL: how to query bar color at runtime

View Count: 916

[2018-11-30 17:47:59]
User525733 - Posts: 126
Hi,

Is there a ACSIL function to retrieve the color of the current bar? ...aka....color at sc.BaseData[sc.Index]

fyi, I am using renko bars if that matters.

thanks
[2018-12-01 02:29:46]
User525733 - Posts: 126
some more clarification: i would like to find the color of the current bar (or a previous bar) using an ACSIL function....i.e whether it is a green (up bar) or red (down bar).

is there a builtin ACSIL function to do this? if not, any recommendation how to go about getting the bar's color?

thanks again
[2018-12-01 22:30:53]
User525733 - Posts: 126
?
[2018-12-02 16:12:21]
bradh - Posts: 854
i would like to find the color of the current bar (or a previous bar) using an ACSIL function....i.e whether it is a green (up bar) or red (down bar).

is there a builtin ACSIL function to do this? if not, any recommendation how to go about getting the bar's color?

Subtract the open price from the close/last price and check to see if the bar has closed. If it is positive, then the bar is up, negative means down.

int BarColor;
if ((sc.BaseDataIn[SC_LAST][sc.Index] - sc.BaseDataIn[SC_OPEN][sc.Index]) >= 0
&& sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
BarColor = 1; // Green

if ((sc.BaseDataIn[SC_LAST][sc.Index] - sc.BaseDataIn[SC_OPEN][sc.Index]) < 0
&& sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
BarColor = 0; // Red

[2018-12-02 16:36:26]
User525733 - Posts: 126
thanks Brad

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

Login

Login Page - Create Account