Arrow entry signals for prior high and low bars


0
0

The price channel study that is already in TOS I’m wanting to add arrows for entry for either a long or short.

I’ve changed the default length from 20 to 21. This is irrelevant on how many days you choose but for this example and code, I’m using the 21.

I’m looking to add a red arrow when the high bar of the channel is broke down below. When a candle (depending on time frame, this example is a Daily) closes below the low of the high bar of the channel.

I’m looking to add a green arrow when the high of the low bar is broke above.

The attached photo shows the arrows where this example would be met. I’ve added white lines to show the low/high of the bars I’m talking about. I hope I explained this properly

Attachments:
Marked as spam
Posted by (Questions: 20, Answers: 45)
Asked on September 9, 2019 8:08 am
22 views
How about the second to the last bar on your screenshot? is that a valid "close below the low of the high bar"? The price channel made a lower high there. So I'm not sure if you intend that to be a valid signal. There are hidden complexities here and I'm not sure I'll be able to complete a solution for this within the time I allow for free assistance in the Q&A Forum.
( at September 9, 2019 10:17 am)
Yes, the bar you referenced would've been a short signal as well. I've started on the arrows. Just need to define everything. input displace = 0; input length = 21; plot LowerBand = Lowest(low[-displace + 1], length); LowerBand.SetDefaultColor(GetColor(1)); plot UpperBand = Highest(high[-displace + 1], length); UpperBand.SetDefaultColor(GetColor(1)); #def LongTrigger; #def ShortTrigger; #plot LongTrigger = #plot ShortTrigger = #LongTrigger.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); #LongTrigger.SetLineWeight(3); #LongTrigger.SetDefaultColor(Color.GREEN); #LongTrigger.HideBubble(); #LongTrigger.HideTitle(); #ShortTrigger.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); #ShortTrigger.SetLineWeight(3); #ShortTrigger.SetDefaultColor(Color.RED); #ShortTrigger.HideBubble(); #ShortTrigger.HideTitle();
( at September 9, 2019 2:41 pm)
0
Private answer

I think this should do the trick. Screenshot below shows the result.

input displace = 0;
input length = 21;
plot lowerBand = Lowest(low[-displace + 1], length);
lowerBand.SetDefaultColor(GetColor(1));
plot upperBand = Highest(high[-displace + 1], length);
upperBand.SetDefaultColor(GetColor(1));
rec trackLowOfHighBar = if high[1] == upperBand then low[1] else trackLowOfHighBar[1];
rec trackHighOfLowBar = if low[1] == lowerBand then high[1] else trackHighOfLowBar[1];
rec trackLongTrigger = if low[1] == lowerBand then 0 else if close[1] > trackHighOfLowBar[1] then 1 else trackLongTrigger[1];
rec trackShortTrigger = if high[1] == upperBand then 0 else if close[1] > trackLowOfHighBar[1] then 1 else trackShortTrigger[1];
plot longTrigger = trackLongTrigger[1] == 0 and close[1] < trackHighOfLowBar[1] and close > trackHighOfLowBar;
plot shortTrigger = trackShortTrigger[1] == 0 and close[1] > trackLowOfHighBar[1] and close < trackLowOfHighBar;
longTrigger.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
longTrigger.SetLineWeight(3);
longTrigger.SetDefaultColor(Color.GREEN);
longTrigger.HideBubble();
longTrigger.HideTitle();
shortTrigger.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
shortTrigger.SetLineWeight(3);
shortTrigger.SetDefaultColor(Color.RED);
shortTrigger.HideBubble();
shortTrigger.HideTitle();

Attachments:
Marked as spam
Posted by (Questions: 36, Answers: 2022)
Answered on September 10, 2019 11:59 am
You're the best! This is great. Thank you.
( at September 10, 2019 12:09 pm)