Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // Β© Keanu_ritz
- //@version=5
- //==================================================================================================================================================================================================================//
- indicator("Pi - Intraday High-Low Predictor", overlay=true)
- //==================================================================================================================================================================================================================//
- //===========================π¦ππΆππ_π πΎπ―π Pi - Intraday High-Low Predictor Code Start - Keanu_RiTz{===========================//
- // ---- Table Settings Start {----//
- ShowpTable = input(title="Show Pi predicted High/Low Levels in a Table", defval=true , group="Pi - Intraday High-Low Predictor")
- max = 120 //Maximum Length
- min = 10 //Minimum Length
- dash_loc = input.session("Top Right","Table Location" ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"] , group="Pi - Intraday High-Low Predictor")
- text_size = input.session('Normal',"Table Size" ,options=["Tiny","Small","Normal","Large"] , group="Pi - Intraday High-Low Predictor")
- bg_col = input.color(color.new(color.blue,90),"Table Background Color", group="Pi - Intraday High-Low Predictor")
- txt_col = input.color(color.new(color.white,45),"Table Text Color", group="Pi - Intraday High-Low Predictor")
- // ---- Table Settings End ----}//
- showDH = input(true, title='Show Predicted-High from Day-Low', group='Pi - Intraday High-Low Predictor')
- showDL = input(true, title='Show Predicted-Low from Day-High', group='Pi - Intraday High-Low Predictor')
- ORtf = input.session(title = "Opening Range period", defval='5', options= ['5','10','15','30','45','60','75','90','120','240'], group='Pi - Intraday High-Low Predictor')
- showHDHLR = input(true, title='Show Historical Predicted High-Low Range', group='Pi - Intraday High-Low Predictor')
- FillsHL = input(true, title='Fill Small range Predicted High-Low', group='Pi - Intraday High-Low Predictor')
- FilllHL = input(true, title='Fill Range Predicted High-Low', group='Pi - Intraday High-Low Predictor')
- FillLHL = input(true, title='Fill Large range Predicted High-Low', group='Pi - Intraday High-Low Predictor')
- HlvlColor = input.color(color.new(#78fa04,45),"Color for High Levels", group="Pi - Intraday High-Low Predictor")
- LlvlColor = input.color(color.new(#fa2f04,45),"Color for Low Levels", group="Pi - Intraday High-Low Predictor")
- HHlvlColor = input.color(color.new(#78fa04,75),"Color for Historical High Levels", group="Pi - Intraday High-Low Predictor")
- HLlvlColor = input.color(color.new(#fa2f04,75),"Color for Historical Low Levels", group="Pi - Intraday High-Low Predictor")
- HTxtColor = input.color(color.new(#78fa04,35),"Color for High Levels Text", group="Pi - Intraday High-Low Predictor")
- LTxtColor = input.color(color.new(#fa2f04,35),"Color for Low Levels Text", group="Pi - Intraday High-Low Predictor")
- phlline_style = input.string("Dotted", options=["Dotted", "Dashed" , "Solid"], title="Line Style", group="Pi - Intraday High-Low Predictor")
- phllabel_size = input.string("small", options=["auto", "tiny", "small", "normal", "large", "huge"], title="Label size", group="Pi - Intraday High-Low Predictor")
- phll_size = phllabel_size == "auto" ? size.auto : phllabel_size == "tiny" ? size.tiny : phllabel_size == "small" ? size.small : phllabel_size == "normal" ? size.normal : phllabel_size == "large" ? size.large : size.huge
- phlposition_labels = input.string("Left", "Labels Position", options=["Left", "Right"], group="Pi - Intraday High-Low Predictor")
- [Dopen, Dclose] = request.security(syminfo.tickerid, 'D', [time, time_close], lookahead=barmerge.lookahead_on)
- [dhigh, dlow] = request.security(syminfo.tickerid, 'D', [high, low], lookahead=barmerge.lookahead_on)
- var phllstyle = ""
- var phll_pos = 0
- if phlline_style == "Dotted"
- phllstyle := line.style_dotted
- else if phlline_style == "Dashed"
- phllstyle := line.style_dashed
- else if phlline_style == "Solid"
- phllstyle := line.style_solid
- if phlposition_labels == "Left"
- phll_pos := Dopen
- else if phlposition_labels == "Right"
- phll_pos := Dclose
- var float ORHigh = 0.00
- var float ORLow = 0.00
- var float ORange = 0.00
- var float DsRange = 0.00
- var float DRange = 0.00
- var float DLRange = 0.00
- var float DsrHigh = 0.00
- var float DrHigh = 0.00
- var float DLrHigh = 0.00
- var float DsrLow = 0.00
- var float DrLow = 0.00
- var float DLrLow = 0.00
- is_Newbar(res) => ta.change(time(res)) != 0
- getBarmergeSeries(tickerid,exp, timeFrame) => request.security(tickerid, timeFrame, exp, barmerge.gaps_off, barmerge.lookahead_on)
- _High = getBarmergeSeries(syminfo.tickerid, ta.valuewhen(is_Newbar('D'), high, 0), ORtf)
- _Low = getBarmergeSeries(syminfo.tickerid, ta.valuewhen(is_Newbar('D'), low, 0), ORtf)
- ORHigh := _High
- ORLow := _Low
- ORange := ORHigh - ORLow
- DRange := ORange * 3.14
- DsRange := DRange / 2
- DLRange := DRange + DsRange
- DsrHigh := dlow + DsRange
- DrHigh := dlow + DRange
- DLrHigh := dlow + DLRange
- DsrLow := dhigh - DsRange
- DrLow := dhigh - DRange
- DLrLow := dhigh - DLRange
- if showDH and timeframe.isintraday
- _piDsrHigh = line.new(Dopen, DsrHigh, Dclose, DsrHigh, xloc.bar_time, color=HlvlColor, style=phllstyle, width=2)
- line.delete(_piDsrHigh[1])
- l_DsrHigh = label.new(phll_pos, DsrHigh, text="Small Range - High ["+str.tostring(DsrHigh, format.mintick)+"]", xloc=xloc.bar_time, textcolor=HTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DsrHigh[1])
- _piDrHigh = line.new(Dopen, DrHigh, Dclose, DrHigh, xloc.bar_time, color=HlvlColor, style=phllstyle, width=2)
- line.delete(_piDrHigh[1])
- l_DrHigh = label.new(phll_pos, DrHigh, text="Range - High ["+str.tostring(DrHigh, format.mintick)+"]", xloc=xloc.bar_time, textcolor=HTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DrHigh[1])
- _piDLrHigh = line.new(Dopen, DLrHigh, Dclose, DLrHigh, xloc.bar_time, color=HlvlColor, style=phllstyle, width=2)
- line.delete(_piDLrHigh[1])
- l_DLrHigh = label.new(phll_pos, DLrHigh, text="Large Range - High ["+str.tostring(DLrHigh, format.mintick)+"]", xloc=xloc.bar_time, textcolor=HTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DLrHigh[1])
- if showDL and timeframe.isintraday
- _DsrLow = line.new(Dopen, DsrLow, Dclose, DsrLow, xloc.bar_time, color=LlvlColor, style=phllstyle, width=2)
- line.delete(_DsrLow[1])
- l_DsrLow = label.new(phll_pos, DsrLow, text="Small Range - Low ["+str.tostring(DsrLow, format.mintick)+"]", xloc=xloc.bar_time, textcolor=LTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DsrLow[1])
- _DrLow = line.new(Dopen, DrLow, Dclose, DrLow, xloc.bar_time, color=LlvlColor, style=phllstyle, width=2)
- line.delete(_DrLow[1])
- l_DrLow = label.new(phll_pos, DrLow, text="Range - Low ["+str.tostring(DrLow, format.mintick)+"]", xloc=xloc.bar_time, textcolor=LTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DrLow[1])
- _DLrLow = line.new(Dopen, DLrLow, Dclose, DLrLow, xloc.bar_time, color=LlvlColor, style=phllstyle, width=2)
- line.delete(_DLrLow[1])
- l_DLrLow = label.new(phll_pos, DLrLow, text="Large Range - Low ["+str.tostring(DLrLow, format.mintick)+"]", xloc=xloc.bar_time, textcolor=LTxtColor, style=label.style_none, size=phll_size)
- label.delete(l_DLrLow[1])
- pDsrHigh = plot(showDH and showHDHLR and timeframe.isintraday ? DsrHigh : na, title='Small Range - Predicted High', color=HHlvlColor, style=plot.style_circles, linewidth=1)
- pDrHigh = plot(showDH and showHDHLR and timeframe.isintraday ? DrHigh : na, title='Range - Predicted High', color=HHlvlColor, style=plot.style_circles, linewidth=1)
- pDLrHigh = plot(showDH and showHDHLR and timeframe.isintraday ? DLrHigh : na, title='Large Range - Predicted High', color=HHlvlColor, style=plot.style_circles, linewidth=1)
- pDsrLow = plot(showDL and showHDHLR and timeframe.isintraday ? DsrLow : na, title='Small Range - Predicted Low', color=HLlvlColor, style=plot.style_circles, linewidth=1)
- pDrLow = plot(showDL and showHDHLR and timeframe.isintraday ? DrLow : na, title='Range - Predicted Low', color=HLlvlColor, style=plot.style_circles, linewidth=1)
- pDLrLow = plot(showDL and showHDHLR and timeframe.isintraday ? DLrLow : na, title='Large Range - Predicted Low', color=HLlvlColor, style=plot.style_circles, linewidth=1)
- fill(pDsrHigh, pDsrLow, color=FillsHL ? color.new(color.white,97) : na)
- fill(pDrHigh, pDrLow, color=FilllHL ? color.new(color.white,97) : na)
- fill(pDLrHigh, pDLrLow, color=FillLHL ? color.new(color.white,97) : na)
- //-------------- Table code Start {-------------------//
- //---- Table Position & Size code start {----//
- var ptable_position = dash_loc == 'Top Left' ? position.top_left :
- dash_loc == 'Bottom Left' ? position.bottom_left :
- dash_loc == 'Middle Right' ? position.middle_right :
- dash_loc == 'Bottom Center' ? position.bottom_center :
- dash_loc == 'Top Right' ? position.top_right : position.bottom_right
- var ptable_text_size = text_size == 'Tiny' ? size.tiny :
- text_size == 'Small' ? size.small :
- text_size == 'Normal' ? size.normal : size.large
- var pt = table.new(ptable_position,14,math.abs(max-min)+2,
- frame_color=color.new(#000000,0),
- frame_width=1,
- border_color=color.new(#000000,0),
- border_width=1)
- //---- Table Position & Size code end ----}//
- if ShowpTable and (barstate.islast) and timeframe.isintraday
- table.cell(pt,1,0,'Intraday High-Low',text_color=txt_col,text_size=ptable_text_size,bgcolor=bg_col)
- table.cell(pt,2,0,'Predictor using Pi',text_color=txt_col,text_size=ptable_text_size,bgcolor=bg_col)
- table.cell(pt,1,1,ticker.standard(syminfo.ticker),text_color=txt_col,text_size=ptable_text_size,bgcolor=bg_col)
- table.cell(pt,2,1,'Values',text_color=txt_col,text_size=ptable_text_size,bgcolor=bg_col)
- table.cell(pt,1,2, "1st "+str.tostring(ORtf)+" Minutes Range",text_color=txt_col,text_size=ptable_text_size,bgcolor=bg_col)
- table.cell(pt,2,2, str.tostring(ORange, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,3, 'Small range High',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,3, str.tostring(DsrHigh, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,4, 'Range High',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,4, str.tostring(DrHigh, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,5, 'Large range High',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,5, str.tostring(DLrHigh, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,6, 'Small range Low',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,6, str.tostring(DsrLow, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,7, 'Range Low',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,7, str.tostring(DrLow, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,1,8, 'Large range Low',text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- table.cell(pt,2,8, str.tostring(DLrLow, format.mintick),text_color=txt_col,text_size=ptable_text_size, bgcolor=bg_col)
- //-------------- Table code end -------------------}//
- //===========================π¦ππΆππ_π πΎπ―π Pi - Intraday High-Low Predictor Code End - Keanu_RiTz===========================}//
- //==================================================================================================================================================================================================================//
Advertisement
Add Comment
Please, Sign In to add comment