Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 21:47:48 +0000



[Programming Help] - Outside bar on a Renko chart

View Count: 556

[2023-07-04 02:41:02]
Ticks - Posts: 183
Anyone have alert study code to identify and color the outside bar of a flex renko chart.
with the pullback low of the outside bar needs to have been close becoming a reversal bar itself.
I would like to have the outside bar colored if its within 5 bars of the previous reversal bar.

I have attached a screen shot of what I'm trying to do.
imageoutside bar renko chart.PNG / V - Attached On 2023-07-04 02:40:19 UTC - Size: 6.58 KB - 125 views
[2023-07-04 13:41:07]
Sawtooth - Posts: 4120
Your pic is confusing.
You've marked 4 bars, the first is not an outside bar, and the third is not within 5 bars of a reversal bar.
[2023-07-04 15:26:01]
Ticks - Posts: 183
Hi tomgilb,

I just markered what i would think would be an outside bar. The code would determine if the bar qualified or not.
The number of bars the the outside bar would have to be within would be adjustable by just changing the number of bars to search within.
I did not include this in the post as to keep it simple to start with and not complicate the basic code base.

Im trying to replicate this NT chart indicator.I have included a screen shot.Its the pic with the black chart.

I found a previous post of yours here and been trying to get the code modified to fit what i need.
But no luck so far.

This is the code i have come up with so far.
The code currently marks the reversal bar also and I dont want that marked.

I have a reversal bar indicator that is ID28
AND( AVERAGE( ID28.SG1[0:-6]) >0,
AVERAGE( ID28.SG2[0:-6]) =0,
C>O,C>H[-1],H >H[-1],

OR(L< L[-1] ,L< L[-2] ), OR(L< L[-3] ,L< L[-4])
)
I have included a screen shot of what I have so far.
It is the white chart.
Date Time Of Last Edit: 2023-07-04 15:54:04
imageoutside bar renko chart2.PNG / V - Attached On 2023-07-04 15:31:07 UTC - Size: 164.75 KB - 115 views
imageMy outside bar code renko chart1.PNG / V - Attached On 2023-07-04 15:52:57 UTC - Size: 22.82 KB - 103 views
[2023-07-04 19:01:31]
Sawtooth - Posts: 4120
Try this:

=AND(
AVERAGE( ID28.SG1[0:-6]) >0,
AVERAGE( ID28.SG2[0:-6]) =0,
ID0.SG23[-1] > ID0.SG22[-1],
ID0.SG23 > ID0.SG22,
ID0.SG23 > H[-1],
H >H[-1],
OR(L < L[-1] ,L < L[-2]),
OR(L < L[-3] ,L < L[-4])
)

When dealing with Renko bars, the Open and Close are identified by ID0.SG22 and ID0.SG23 respectively:
Study/Chart Alerts And Scanning: Available Main Price Graph Identifiers/Variables
[2023-07-04 22:10:37]
Ticks - Posts: 183
Thanks tomgilb,

Code is almost there. It seems to miss a few bars i have marked them on the attached screen shot.
I would like the code to identify them, or would those bars not count as outside bars?
imageMy outside bar code renko chart2.PNG / V - Attached On 2023-07-04 22:10:21 UTC - Size: 14.89 KB - 95 views
[2023-07-05 01:12:44]
Sawtooth - Posts: 4120
would those bars not count as outside bars?
An Outside Bar is a bar that has a higher High and a lower Low than those of the previous bar, so yes.

However, with Renko bars, the formula for an Outside Bar is more complex:
=OR(
AND(ID0.SG23>ID0.SG22,
MAX(H,ID0.SG23)>MAX(H[-1],ID0.SG23[-1]),
MIN(L,ID0.SG22)<MIN(L[-1],ID0.SG22[-1])),
AND(ID0.SG23<ID0.SG22,
MAX(H,ID0.SG22)>MAX(H[-1],ID0.SG22[-1]),
MIN(L,ID0.SG23)<MIN(L[-1],ID0.SG23[-1]))
)
[2023-07-05 03:28:27]
Ticks - Posts: 183
Looking better, but the code now paints the reversal bar too.
imageMy outside bar code renko chart3.PNG / V - Attached On 2023-07-05 03:28:20 UTC - Size: 11.37 KB - 94 views
[2023-07-05 04:20:59]
Ticks - Posts: 183
I modified you last code block and I think it is very close to what im looking for.
Screenshot attached.
AND(AVERAGE( ID28.SG1[0:-6]) >0,
AVERAGE( ID28.SG2[0:-6]) =0,
ID0.SG23[-1]> ID0.SG22[-1],
MAX(H,ID0.SG23)>MAX(H[-1],ID0.SG23[-1]),
MIN(L,ID0.SG22)<MIN(L[-1],ID0.SG22[-1])

)
imageMy outside bar code renko chart4.PNG / V - Attached On 2023-07-05 04:20:50 UTC - Size: 15.96 KB - 94 views
[2023-07-05 05:04:03]
Ticks - Posts: 183
tomgilb,

I believe I have what i was looking for.
I have attached a screen shot.
Thanks so much for your help.

To pay it forward. I will post the code for both the Long and Short conditions.

Long condition:

AND(AVERAGE( ID28.SG1[0:-15]) >0,
AVERAGE( ID28.SG2[0:-1]) =0,
ID0.SG23[-1]> ID0.SG22[-1],
MAX(H,ID0.SG23)>MAX(H[-1],ID0.SG23[-1]),
MIN(L,ID0.SG22)<MIN(L[-1],ID0.SG22[-1])
)

Short condition:
AND(AVERAGE( ID28.SG1[0:-1]) =0,
AVERAGE( ID28.SG2[0:-15]) >0,
ID0.SG23[-1]<ID0.SG22[-1],
MAX(H,ID0.SG22)>MAX(H[-1],ID0.SG22[-1]),
MIN(L,ID0.SG23)<MIN(L[-1],ID0.SG23[-1])
)

Date Time Of Last Edit: 2023-07-05 05:04:44
imageMy outside bar code renko chart5.PNG / V - Attached On 2023-07-05 04:54:55 UTC - Size: 13.75 KB - 98 views
[2023-07-05 13:25:04]
Ticks - Posts: 183
One more question tomgilb.
Would it be possible to to determine the length of the pullback bar and if the pullback bar length is within a certain amount of ticks.Have it marked even if it wasnt a true outside bar?
example.
Pullback back is within 10 ticks of being an official outside bar.
Then when the bar closes to continue the trend direction, the alert code marks it as if it was an outside bar.
[2023-07-05 14:36:49]
Sawtooth - Posts: 4120
Would it be possible...?
Most things are possible with Sierra Chart.

Post a pic of pullback bars you want marked, that are not outside bars.
[2023-07-05 15:24:54]
Ticks - Posts: 183
Thanks for providing more of your time.
I have attached a screen shot of the pullback bars.

I would want to be able to change the amount of ticks that the code would consider marking the pullback bar.
Im ok with having to change the amount directly in the alert code.

I`m also thinking maybe added the Horizontal Lines study and possible have the alert code reference a line value maybe something like this:
AVERAGE( ID28.SG2[0:-ID31.SG1]).
Not sure that is workable.
Date Time Of Last Edit: 2023-07-05 15:25:50
imageMy outside bar code renko chart6.PNG / V - Attached On 2023-07-05 15:01:04 UTC - Size: 5.96 KB - 95 views
[2023-07-05 16:01:08]
Sawtooth - Posts: 4120
Both of your examples are the bar after the reversal bar.
Is this always the case?

Would you mark the bar 3 bars to the right of your first example, the bar following the marked outside bar?
[2023-07-05 16:42:16]
Ticks - Posts: 183
Yes, I would like to mark that bar also if it is within the pull back tick range determined by a variable.
[2023-07-06 00:27:43]
Sawtooth - Posts: 4120
This is the basic formula. Tweak as needed:

=OR(
AND(ID0.SG23[-1]>ID0.SG22[-1],ID0.SG23>ID0.SG22,
MAX(H,ID0.SG23)-MIN(L,ID0.SG22)>TICKSIZE*30),
AND(ID0.SG23[-1]<ID0.SG22[-1],ID0.SG23<ID0.SG22,
MAX(H,ID0.SG22)-MIN(L,ID0.SG23)>TICKSIZE*30)
)

This finds Renko bars with a range > 30 ticks, ignoring the reversal bar.
Date Time Of Last Edit: 2023-07-06 00:28:17
[2023-07-06 11:52:45]
Ticks - Posts: 183
tomgilb,
Thank you.
That works perfect.
I tweaked as needed.

Even added the Horizontal Lines study, id of "ID19"
MIN(L,ID0.SG22)>TICKSIZE* ID19.SG1)
It worked.

However this wont work.
AVERAGE( ID28.SG2[0:-ID19.SG2]) >0
I guess the AVERAGE function cant reference another study id.

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

Login

Login Page - Create Account