Advertisement
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/
- // © Maurizio-Ciullo
- //@version=5
- indicator("Indicatore Daily-Weekly-Candle-Range-In-Price", overlay=true)
- //Inputs
- input_daily_range = input.bool(defval=true)
- input_weekly_range = input.bool(defval=false)
- //Daily sessions and range
- dailySessionDataHigh = request.security(syminfo.tickerid,"D", high)
- dailySessionDataLow = request.security(syminfo.tickerid,"D", low)
- dailyRangeInPrice = dailySessionDataHigh - dailySessionDataLow
- plot(input_daily_range == true ? dailySessionDataHigh : na, title="weeklySessionDataHigh", color=color.blue)
- plot(input_daily_range == true ? dailySessionDataLow : na, title="weeklySessionDataLow", color=color.blue)
- plot(input_daily_range == true ? dailyRangeInPrice : na, style=plot.style_histogram, color=color.blue)
- //Weekly sessions and range
- weeklySessionDataHigh = request.security("","W", high)
- weeklySessionDataLow = request.security("","W", low)
- weeklyRangeInPrice = weeklySessionDataHigh - weeklySessionDataLow
- plot(input_weekly_range == true ? weeklySessionDataHigh : na, title="weeklySessionDataHigh", color=color.blue)
- plot(input_weekly_range == true ? weeklySessionDataLow : na, title="weeklySessionDataLow", color=color.blue)
- plot(input_weekly_range == true ? weeklyRangeInPrice : na, style=plot.style_histogram, color=color.blue)
- label_daily_range_text = input_daily_range == true ? str.tostring(dailyRangeInPrice) : na
- label_daily_range = input_daily_range == true ? label.new(x=bar_index, y=na, yloc=yloc.belowbar, text=label_daily_range_text, style=label.style_label_lower_left, textcolor=color.white, size=size.normal) : na
- label_weekly_range_text = input_weekly_range == true ? str.tostring(weeklyRangeInPrice) : na
- label_weekly_range = input_weekly_range == true ? label.new(x=bar_index, y=na, yloc=yloc.belowbar, text=label_weekly_range_text, style=label.style_label_down, textcolor=color.white, size=size.normal) : na
- // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Code Below For Candle Range And Average LookBack Candles <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
- //Input Settings
- input_bar_range = input.bool(defval=false, tooltip = "All Label Inputs And Periodo Only Work For input_bar_range")
- DistanceBar = input.int(title="/", defval=15, maxval=50, minval=-50, inline="Bar Offset Settings",group="Label Distance from Bar")
- sizeOption = input.string("Normal", options = ["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group="Label Size")
- labelSize = (sizeOption == "Huge") ? size.huge :
- (sizeOption == "Large") ? size.large :
- (sizeOption == "Small") ? size.small :
- (sizeOption == "Tiny") ? size.tiny :
- (sizeOption == "Auto") ? size.auto :
- size.normal
- // Calcolo del range del backtest
- startDate = input.int(title="Start Date",
- defval=17, minval=1, maxval=31, group="Periodo")
- startMonth = input.int(title="Start Month",
- defval=08, minval=1, maxval=12, group="Periodo")
- startYear = input.int(title="Start Year",
- defval=2000, minval=1800, maxval=2100, group="Periodo")
- endDate = input.int(title="End Date",
- defval=01, minval=1, maxval=31, group="Periodo")
- endMonth = input.int(title="End Month",
- defval=01, minval=1, maxval=12, group="Periodo")
- endYear = input.int(title="End Year",
- defval=2121, minval=1800, maxval=2150, group="Periodo")
- inDateRange = (time >= timestamp(syminfo.timezone, startYear,
- startMonth, startDate, 0, 0)) and
- (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
- // Start Hour Range Trading Non Attivo /////////////////////
- //hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
- //hourRangeTrading = time(timeframe.period, hourTrading)
- //Label Colors
- colorLabel = input(title="Label Color", defval=#4169E1, inline="Color Settings",group="Label Colors")
- colorText = input(title="Text Color", defval=color.white, inline="Color Settings",group="Label Colors")
- //Text Only or Label Up or Label Down
- labelType = input.string("Label Up", options =["Text Only", "Label Up"], group="Label Style")
- labelStyle = (labelType == "Text Only") ? label.style_none : (labelType == "Label Up") ? label.style_label_up : label.style_none
- // Calculate Bar Difference
- inLookBack = input.int(title="lookBack", defval=7, maxval=500, minval=-500, inline="lookBack",group="lookBack")
- diff = 0.0
- diffLookBack = 0.0
- if inDateRange
- diff := (high[0] - low[0])
- diffLookBack := math.sum(diff, inLookBack) / inLookBack
- plot(diffLookBack, title="diffLookBack")
- // Label to plot Difference
- labeltext = input_bar_range == true ? str.tostring(diff): na
- label_ = input_bar_range == true ? label.new(bar_index[0], low[0]-DistanceBar, text=labeltext, color=colorLabel, textcolor=colorText, style=labelStyle, size=labelSize) : na
- // Label to plot High/Low Range Bars LookBack
- labeltext2 = input_bar_range == true ? ("range average" + " " + str.tostring(inLookBack ) + " " + "bars" + " " + str.tostring(diffLookBack)) : na
- if barstate.islast
- label_2 = input_bar_range == true ? label.new(bar_index[0], high[0]+DistanceBar, text=labeltext2, color=colorLabel, textcolor=colorText, style=labelStyle, size=labelSize) : na
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement