Support Board
Date/Time: Mon, 23 Dec 2024 19:07:07 +0000
Post From: Change Linewidth and Drawstyle dynamically using code condition
[2015-10-10 03:45:37] |
Sawtooth - Posts: 4141 |
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)) |