Price Channels HOLP/LOHP

JamesB

Member
I am wondering if someone has a thinkscript for John Carter's price channels' Holp/Lohp breakout arrows?
 
Solution
#Here is a version that I have been able to develop. But I believe that others may have a better version.


input showBreakoutSignals = yes;
input displace = 0;
input lengthDon = 21;

plot DonLowerBand = if Lowest(low [-displace + 1], lengthDon) then Lowest (low) else Double.NaN;
DonLowerBand.SetDefaultColor(Color.BLUE);
DonLowerBand.HideBubble();
DonLowerBand.SetLineWeight(1);
#DonLowerBand.Hide();

plot DonUpperBand = if Highest(high [-displace + 1], lengthDon) then Highest(high) else Double.NaN;
DonUpperBand.SetDefaultColor(Color.BLUE);
DonUpperBand.HideBubble();
DonUpperBand.SetLineWeight(1);
#DonUpperBand.Hide();
plot centerBand = (DonUpperBand + DonLowerBand) / 2;
centerBand.SetLineWeight(1);
centerBand.HideBubble()...
Try this, let me know how it works out, might need to be tweaked a little bit.

Ruby:
input Length = 20;
def LowLow; def HighBar;
def HighThresh; def Sig;
if Close == lowest(Close,Length) {
    LowLow = lowest(Low,Length);
    if Low == LowLow {
        HighBar = Double.NaN;
        HighThresh = High;
    } else {
        HighBar =
        fold Index = 0 to Length - 1 with Bar while IsNan(Bar) do
        if Low[Index] == LowLow then Index
        else Double.NaN;
        HighThresh = getValue(High,HighBar);
    }
    Sig = Double.NaN;
} else {
    Sig = crosses(High, HighThresh[1], crossingDirection.ABOVE);
    HighThresh = if Sig then Double.NaN else HighThresh[1];
    LowLow = Double.NaN;
    HighBar = Double.NaN;
}
plot Signal = Sig;
Signal.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
plot Threshold = HighThresh;
Threshold.setPaintingStrategy(paintingStrategy.HORIZONTAL);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hi Joshua,

Thanks for your response. This gets part of it some of the time. We need to be able to reverse it for bearish entries/or bullish exits. Second, there are times that it does not record the break of the low bar. And third, I wonder if there is a way to have the arrow shown when the low is equal to the price channel or close to it, then starts to reverse in the opposite direction as the point of the indicator.

Thank you for your time!
 
Joshua, John Carter's indicator HOLP/LOHP is based upon price channels a standard indicator in TOS (some call them Donchain Channels). If you were to put the indicator that you found onto a chart then add TOS price channels adjusting them to a 21 period, you would see that at times the indicator that you found does work for bullish entries. The indicator that you found is based on the low touching the lower price channel (even though your indicator does not plot the lower price channel), then a following price bar's high being greater than that previous bar's high that touched the lower price channel. So you can have additional candlestick lows that are equal to that one that touched the lower price channel or really close to it that would form better entries, yet herein lies the struggle of charting it.
 
#Here is a version that I have been able to develop. But I believe that others may have a better version.


input showBreakoutSignals = yes;
input displace = 0;
input lengthDon = 21;

plot DonLowerBand = if Lowest(low [-displace + 1], lengthDon) then Lowest (low) else Double.NaN;
DonLowerBand.SetDefaultColor(Color.BLUE);
DonLowerBand.HideBubble();
DonLowerBand.SetLineWeight(1);
#DonLowerBand.Hide();

plot DonUpperBand = if Highest(high [-displace + 1], lengthDon) then Highest(high) else Double.NaN;
DonUpperBand.SetDefaultColor(Color.BLUE);
DonUpperBand.HideBubble();
DonUpperBand.SetLineWeight(1);
#DonUpperBand.Hide();
plot centerBand = (DonUpperBand + DonLowerBand) / 2;
centerBand.SetLineWeight(1);
centerBand.HideBubble();
centerBand.Hide();
centerBand.SetStyle(Curve.LONG_DASH);
centerBand.SetDefaultColor(Color.BLUE);



plot DownDonSignal = if (high[1] >= DonUpperBand or high[2] >= DonUpperBand) and ohlc4 < DonUpperBand and low < low[1]
then high else Double.NaN;

plot UpDonSignal = if (low[1] <= DonLowerBand or low[2] <= DonLowerBand) and ohlc4 > DonLowerBand and high > high[1]

then low else Double.NaN;
UpDonSignal.SetHiding(!showBreakoutSignals);
DownDonSignal.SetHiding(!showBreakoutSignals);
UpDonSignal.SetDefaultColor(Color.BLUE);
DownDonSignal.HideBubble();
UpDonSignal.HideBubble();

UpDonSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
DownDonSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
UpDonSignal.SetLineWeight(5);
DownDonSignal.SetDefaultColor(Color.BLUE);
DownDonSignal.SetLineWeight(5);
Alert(UpDonSignal[1], "Don Reversal to North", Alert.BAR, Sound.Ring);
Alert(DownDonSignal[1], "Don Reversal to South", Alert.BAR, Sound.Chimes);
AddVerticalLine (UpDonSignal, "", Color.BLUE);
AddVerticalLine (DownDonSignal, "", Color.BLUE);
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
354 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top