Support Board
Date/Time: Wed, 14 May 2025 19:54:47 +0000
[User Discussion] - Paintbar 3 closes above/below a study
View Count: 1397
[2016-03-29 14:02:05] |
User95787 - Posts: 18 |
Seems simple enough but still not able to create correctly. Once the 3rd closing bar is above an MA, starts painting green. Once it goes below, the 3rd closing bar starts painting red. I tried =C>C[-3] but that doesnt work, help appreciated |
![]() |
[2016-03-29 14:49:43] |
Sawtooth - Posts: 4214 |
Try this: =AND(C>ID1.SG1[-1],C[-1]>ID1.SG1[-2],C[-2]>ID1.SG1[-3]) where the MA is ID1. This works best on range bars. It does not require up bars. Date Time Of Last Edit: 2016-03-29 14:52:28
|
[2016-03-29 15:01:08] |
User95787 - Posts: 18 |
Will it not work for Volume Per Bar? It doesnt plot for that
|
[2016-03-29 15:18:45] |
User95787 - Posts: 18 |
It works! Thanks tomgilb
|
[2016-03-29 15:24:50] |
User95787 - Posts: 18 |
If the requirement was up bars, what would the code be sir?
|
[2016-03-29 15:55:26] |
Sawtooth - Posts: 4214 |
Assuming you want all 3 of the bars to be up bars: =AND(C>O,C[-1]>O[-1],C[-2]>O[-2],C>ID1.SG1[-1],C[-1]>ID1.SG1[-2],C[-2]>ID1.SG1[-3]) This may not do what you want. If you are expecting to color all subsequent bars after the 3rd up bar closes above the MA, you'll need to use a spreadsheet study so that you can create a persistent TRUE. |
[2016-04-01 16:20:52] |
User95787 - Posts: 18 |
sorry but not to knowledgable in the spreadsheet study and learning a few things now but unable to correctly match to what i need to do yet. I used the following on K3 cell (basically saying the Last Price 3 bars ago >= Open Price 3 bars ago and Last Price 3 bars ago >= my indicator) =AND(ID0.SG4@5>=ID0.SG1@5,ID0.SG4@5>=ID1.SG3@3)- this paints bar green =AND(ID0.SG4@5<=ID0.SG1@5,ID0.SG4@5<=ID1.SG3@3)- this paints bar red Problem is that it does not continue to paint continuously (the black OHLC is the normal color bar) and also in between it will paint the wrong color (I made some notes on the attached chart)..hope you can help tomgilb even if to create a new spreadsheet Even tried =ID0.SG4@5<=ID1.SG3@3 which is LAST <= my indicator 3 BARS AGO which colors all of the bars correctly green up/red down but doesnt fit the criteria of HH/HC or LH/LC |
![]() |
[2016-04-01 18:12:04] |
Sawtooth - Posts: 4214 |
To create a persistent TRUE, use a double IF statement, where the first IF turns it on and repeats until the second IF turns it off, in cell K3: =IF(AND(E3>B3,E3>ID1.SG3@4,E4>ID1.SG3@5,E5>ID1.SG3@6),1,IF(AND(E3<B3,E3<ID1.SG3@4,E4<ID1.SG3@5,E5<ID1.SG3@6),0,K4)) This requires that only the most recent bar be an up bar. Use the same formula in L3, except reverse all of the comparison operators, finishing with L4 instead of K4. With both formulas, every bar will be colored, leaving no black bars. |
[2016-04-01 21:58:15] |
User95787 - Posts: 18 |
So far, so good Tom..the black bars have disappeared but the green bars on the earlier example still colors incorrect (I have updated the screenshot so you may see it) Thank you again for the learning lesson |
![]() |
[2016-04-02 00:06:40] |
Sawtooth - Posts: 4214 |
Please share both of the formulas you are using in the pic in post #9. Please share your exact coloring conditions. My formula was only an example of a persistent TRUE, but it looks like you don't need it to be persistent. I thought you wanted all bars colored the same on each side of the line. |
[2016-04-02 00:55:26] |
User95787 - Posts: 18 |
Attached is the scss sheet. 3 up bars with minimum 3rd close above indicator, green 3 down bars with minimum 3rd close below indicator, red hope that helps Date Time Of Last Edit: 2016-04-02 01:04:16
|
![]() |
[2016-04-02 01:02:55] |
Sawtooth - Posts: 4214 |
I can't see a private file. You can send it to tom@sawtoothtrade.com |
[2016-04-02 01:04:46] |
User95787 - Posts: 18 |
sorry i made it public now
|
[2016-04-02 02:18:27] |
Sawtooth - Posts: 4214 |
Swap the formulas in K3 and L3, and we'll go from there.
|
[2016-04-02 02:40:24] |
User95787 - Posts: 18 |
Thats it! a million thanks Tom
|
To post a message in this thread, you need to log in with your Sierra Chart account: