Repaints Pi - Intraday High-Low Predictor For ThinkOrSwim

Repaints

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

https://in.tradingview.com/script/mz2OHJSc-Pi-Intraday-High-Low-Predictor/
Can anyone convert this ,to thinkscript?it is very accurate.
Very helpful.
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © Keanu_ritz
#indicator("Pi - Intraday High-Low Predictor", overlay=true)
# Converted by Sam4Cok@Samer800    - 11/2023

input showHistoricalRanges = yes;    # 'Show Historical Predicted High-Low Range'
input showDayHigh = yes;                # 'Show Predicted-High from Day-Low'
input showDayLow = yes;                 # 'Show Predicted-Low from Day-High'
input OpeningRangePeriod = AggregationPeriod.FIVE_MIN;# "Opening Range period"
input highlightRange = yes;#(true, title='Fill Range Predicted High-Low'

def na = Double.NaN;
def last = isNaN(Close);
def pi = Double.Pi;
def YYYYMMDD = GetYYYYMMDD();
def today = GetDay() == GetLastDay();
def showHDHLR = !last[5] and today;
def is_Newbar = YYYYMMDD!=YYYYMMDD[1];
def ODay = Open(Period = "DAY");
def CDay = Close(Period = "DAY");
def HDay = High(Period = "DAY");
def LDay = Low(Period = "DAY");
def hTF = High(Period = OpeningRangePeriod);
def lTF = low(Period = OpeningRangePeriod);

def Dopen  = if is_Newbar then ODay else Dopen[1];
def Dclose = if is_Newbar then CDay else Dclose[1];
def dhigh = if is_Newbar then HDay else dhigh[1];
def dlow  = if is_Newbar then LDay else dlow[1];
def _High = if is_Newbar then hTF else _High[1];
def _Low  = if is_Newbar then lTF else _Low[1];

def ORHigh  = _High;
def ORLow   = _Low;
def ORange  = ORHigh - ORLow;
def DRange  = ORange * Pi;
def DsRange = DRange / 2;
def DLRange = DRange + DsRange;
def DsrHigh = dlow + DsRange;
def DrHigh  = dlow + DRange;
def DLrHigh = dlow + DLRange;
def DsrLow  = dhigh - DsRange;
def DrLow   = dhigh - DRange;
def DLrLow  = dhigh - DLRange;

def _piDsrHigh; def _piDrHigh; def _piDLrHigh;
if showHistoricalRanges and !last and !today {
    _piDsrHigh = DsrHigh;
    _piDrHigh  = DrHigh;
    _piDLrHigh = DLrHigh;
    } else {
    _piDsrHigh = na;
    _piDrHigh  = na;
    _piDLrHigh = na;
}
def _piDsrLow; def _piDrLow; def _piDLrLow;
if showHistoricalRanges and !last and !today {
    _piDsrLow = DsrLow;
    _piDrLow  = DrLow;
    _piDLrLow = DLrLow;
    } else {
    _piDsrLow = na;
    _piDrLow  = na;
    _piDLrLow = na;
}

plot pDsrHigh = if showDayHigh and showHDHLR then DsrHigh else na;#, title='Small Range - Predicted High'
plot pDrHigh = if showDayHigh and showHDHLR then DrHigh else na;#, title='Range - Predicted High'
plot pDLrHigh = if showDayHigh and showHDHLR then DLrHigh else na;#, title='Large Range - Predicted High'
plot pDsrLow = if showDayLow and showHDHLR then DsrLow else na;#, title='Small Range - Predicted Low'
plot pDrLow = if showDayLow and showHDHLR then  DrLow else na;#;#, title='Range - Predicted Low'
plot pDLrLow = if showDayLow and showHDHLR then DLrLow else na;#, title='Large Range - Predicted Low'

pDsrHigh.SetDefaultColor(Color.DARK_GREEN);
pDrHigh.SetDefaultColor(Color.DARK_GREEN);
pDLrHigh.SetDefaultColor(Color.DARK_GREEN);
pDsrLow.SetDefaultColor(Color.PLUM);
pDrLow.SetDefaultColor(Color.PLUM);
pDLrLow.SetDefaultColor(Color.PLUM);

plot piDsrHigh = _piDsrHigh;
plot piDrHigh  = _piDrHigh;
plot piDLrHigh = _piDLrHigh;
plot piDsrLow  = _piDsrLow;
plot piDrLow   = _piDrLow;
plot piDLrLow  = _piDLrLow;

piDsrHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
piDrHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
piDLrHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
piDsrLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
piDrLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
piDLrLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

piDsrHigh.SetDefaultColor(Color.CYAN);
piDrHigh.SetDefaultColor(Color.CYAN);
piDLrHigh.SetDefaultColor(Color.CYAN);
piDsrLow.SetDefaultColor(Color.MAGENTA);
piDrLow.SetDefaultColor(Color.MAGENTA);
piDLrLow.SetDefaultColor(Color.MAGENTA);

AddCloud(if highlightRange and !last then DrHigh else na, DrLow, Color.DARK_GRAY, Color.DARK_GRAY);


#-- END OF CODE
 
Hi @samer800 ,thank you for this it works great really appreciate it ,just one thing i notice for Futures levels do not match with the one on TV but it does match exactly on any other stock ,SPY,QQQ,SPX ,,,but not futures any thoughts?.
thanks again.
 
Hi @samer800 ,thank you for this it works great really appreciate it ,just one thing i notice for Futures levels do not match with the one on TV but it does match exactly on any other stock ,SPY,QQQ,SPX ,,,but not futures any thoughts?.
thanks again.
I guess this related to extended hours.
Try to uncheck the extended hours from "Futures" tab under "Chart setting"
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
384 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