Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 16:34:10 +0000



Change Linewidth and Drawstyle dynamically using code condition

View Count: 907

[2015-10-10 01:04:31]
KhaosTrader - Posts: 128
Hi,
I am trying to figure out how I can change LineWidth value and Drawstyle value using code based on an "if" condition. Can you point me to an example please.

Thanks.
[2015-10-10 01:05:19]
KhaosTrader - Posts: 128
If i cant change drawstyle or linewidth, is it possible to make the drawing invisible on select bars?
[2015-10-10 01:22:51]
KhaosTrader - Posts: 128
Just to clarify, this is what I am trying to build.. porting it from multicharts...

Its a MACD with a BBSqueeze indicator in it. So the dots show up during the squeeze zone and no where else.. So I need to hide the dots when there is no squeeze situation....
imageMACD SQUEEZE.png / V - Attached On 2015-10-10 01:22:05 UTC - Size: 8.66 KB - 285 views
[2015-10-10 03:45:37]
Sawtooth - Posts: 3992
You can do it with the Color Bar Based On Alert Condition study. However, the Bollinger Squeeze study doesn't output a positive number when the dot is green, but the Bollinger Squeeze2 study does, so you'd need to use the latter (the squeeze dots are in the same places.)

Here's how to paint only the green dots:
1) Add the Bollinger Squeeze2 study, if necessary.
-Set the 'Value Format' to 0.00001
-Set the Draw Style of SG2 to Hidden.
--If you want to use the Bollinger Squeeze study instead:
--Hide the Squeeze2 study
--Set the Draw Style of SG2 to Hidden.
2) Add the Line study (to match your example pic)
-Set the Chart Region to the same as the Squeeze study you are using
-Set the Input Value to 0
-Set the color to red
3) Add the Color Bar Based On Alert Condition study.
-Set the 'Based On' to the Bollinger Squeeze2 study
-Set the 'Chart Region' to the same as the Squeeze study you are using
-Set the 'Output When Condition True' to 'Use Input Data'
-Set the 'Input Data' to 'Squeeze Indicator'
-Set the Draw Style to Point, the color to green, and the Width/Size to 4
-Use this formula: =ID1.SG2>0 ,where the Squeeze2 study is ID1, edit as needed

Note: The above 3 studies must be in the same order in the Studies to Graph list.

If you want to precede and succeed the green dots with a red dot as in your example pic, add another instance of the Color Bar Based On Alert Condition study, follow the above steps, set the color to red, and use this formula:
=OR(AND(ID1.SG2[-1]<0,ID1.SG2>0),AND(ID1.SG2[-1]>0,ID1.SG2<0))
[2015-10-10 04:25:17]
Sierra Chart Engineering - Posts: 104368
We have prepared documentation for how to do this in ACSIL here:
https://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#SkippingWithASubgraphDrawStyle
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-10-10 05:34:29]
KhaosTrader - Posts: 128
Thank you the drawZeros works, well I have implemented it.

Regarding the green versus red dots, the green dots show when the BB is equal to the Keltner... I tried to implement this but I am never getting a positive result on the equal condition. I am wondering if its because its a float, and perhaps I need to subtract the values and do an fabs() on it and see if its within a particular threshold or something...

Any ideas on this would be appreciated.

Thanks.
[2015-10-10 05:35:17]
KhaosTrader - Posts: 128
sorry correction red dots means they are equal...
[2015-10-10 06:51:01]
Sierra Chart Engineering - Posts: 104368
You need to use this function:
http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scFormattedEvaluate
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

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

Login

Login Page - Create Account