今天和昨天的扩展框
Extend box for today and yesterday
早上好,
我如何将下面脚本中的框扩展到今天和昨天?
我可以让方框出现并全部扩展。但希望可以选择只延长今天和昨天。这可以作为单独的选项。
箱子
全部扩展(看起来很乱,没有实现)
下面我用绘图工具展示了我想展示的内容
// 此源代码受 https://mozilla.org/MPL/2.0/ 的 Mozilla Public 许可证 2.0 条款的约束
// © Frien_dd
//@version=4
study("Asia IB Testing - Delete Me", overlay = true)
AsiaInputColor = input(color.purple, title="Asia", group = "Session Boxes - Settings", inline = "Input 1")
NoBoxIBOutline = input(true, title="Turn IB Box Outline On/Off", group="Session Boxes - Settings")
NoBoxIBBGColor = input(true, title="Turn IB Box Background Colour On/Off", group="Session Boxes - Settings")
BGIBGradiant = input(85,title="Box IB Background color gradiant", group="Session Boxes - Settings")
//#######################################################################################
////////How do I incorperate this, so that the user can select to extend only today IBs/box and yesterdays
//#######################################################################################
isToday = dayofmonth(time) == dayofmonth(timenow)
ExtendOnlyToday = isToday ? extend.right : na
ExtendIBBox = input(false, title="Extend previous and todays Intial Balance Boxes")
ExtendOption = ExtendIBBox ? extend.right : extend.none
Switch = input(true, title="Dotted/Solid Box Outline", group="Session Boxes - Settings")
SolidDotted = Switch ? line.style_solid : line.style_dotted
AsiaBoxIBOutline = NoBoxIBOutline ? AsiaInputColor : na
AsiaBoxIBBGColor = NoBoxIBBGColor ? color.new(AsiaInputColor, BGIBGradiant) : na
//// Asia Initial Balance
AsiaIBOnOff = input(true, title = "", group = 'Session Boxes', inline = "2")
AsiaIBTimeRangeInput = input("0130-0230", "Asia IB Session", input.session, group = 'Session Boxes', inline = "2")
AsiaIBDateRange = ":1234567"
AsiaIBTimeRange = AsiaIBTimeRangeInput+AsiaIBDateRange
AsiaIBinRange = time(timeframe.period, AsiaIBTimeRange)
// AsiaIBTimeRange = input("0130-0230:1234567", type=input.session, title='Asia IB Session', group = 'Session Boxes')
// AsiaIBinRange = (time(timeframe.period, AsiaIBTimeRange))
// First and Last bar in Range
AsiaIBStart = AsiaIBinRange and not AsiaIBinRange[1]
AsiaIBEnd = not AsiaIBinRange and AsiaIBinRange[1]
// Bar Index of Start and End
AsiaIBStartIndex = 0, AsiaIBEndIndex = 0
AsiaIBStartIndex := AsiaIBStart? bar_index : AsiaIBStartIndex[1]
AsiaIBEndIndex := AsiaIBEnd? bar_index : AsiaIBEndIndex[1]
// Calculate Highs and Lows
AsiaIBHigh = 0.0, AsiaIBLow = 0.0
AsiaIBHigh := high >= AsiaIBHigh[1]? high : AsiaIBHigh[1]
AsiaIBLow := low <=AsiaIBLow[1]? low : AsiaIBLow[1]
// Reset at start of range
AsiaIBHigh := AsiaIBStart? high : AsiaIBHigh
AsiaIBLow := AsiaIBStart? low : AsiaIBLow
// Get open and close for range
AsiaIBOpen = 0.0, AsiaIBClose = 0.0
AsiaIBOpen := AsiaIBStart? open : AsiaIBOpen[1]
AsiaIBClose := AsiaIBEnd? close : AsiaIBClose[1]
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, ExtendOption,bgcolor=AsiaBoxIBBGColor)
// Draw current box if currently in range
box AsiaIBBox = na
if AsiaIBinRange and barstate.islast and AsiaIBOnOff
AsiaIBBox := box.new(AsiaIBStartIndex, AsiaIBHigh, bar_index, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, ExtendOption,bgcolor=AsiaBoxIBBGColor)
box.delete(AsiaIBBox[1])
回答如下:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Frien_dd
//@version=4
study("Asia IB Testing - Delete Me", overlay = true)
AsiaInputColor = input(color.purple, title="Asia", group = "Session Boxes - Settings", inline = "Input 1")
NoBoxIBOutline = input(true, title="Turn IB Box Outline On/Off", group="Session Boxes - Settings")
NoBoxIBBGColor = input(true, title="Turn IB Box Background Colour On/Off", group="Session Boxes - Settings")
BGIBGradiant = input(85,title="Box IB Background color gradiant", group="Session Boxes - Settings")
isToday = dayofmonth(time) == dayofmonth(timenow)
ExtendIBTodayBox = input(false, title="Extend todays Intial Balance Boxes")
ExtendIBYesterdayBox = input(false, title="Extend previous days Intial Balance Boxes")
Switch = input(true, title="Dotted/Solid Box Outline", group="Session Boxes - Settings")
SolidDotted = Switch ? line.style_solid : line.style_dotted
AsiaBoxIBOutline = NoBoxIBOutline ? AsiaInputColor : na
AsiaBoxIBBGColor = NoBoxIBBGColor ? color.new(AsiaInputColor, BGIBGradiant) : na
//// Asia Initial Balance
AsiaIBOnOff = input(true, title = "", group = 'Session Boxes', inline = "2")
AsiaIBTimeRangeInput = input("0130-0230", "Asia IB Session", input.session, group = 'Session Boxes', inline = "2")
AsiaIBDateRange = ":1234567"
AsiaIBTimeRange = AsiaIBTimeRangeInput+AsiaIBDateRange
AsiaIBinRange = time(timeframe.period, AsiaIBTimeRange)
// First and Last bar in Range
AsiaIBStart = AsiaIBinRange and not AsiaIBinRange[1]
AsiaIBEnd = not AsiaIBinRange and AsiaIBinRange[1]
// Bar Index of Start and End
AsiaIBStartIndex = 0, AsiaIBEndIndex = 0
AsiaIBStartIndex := AsiaIBStart? bar_index : AsiaIBStartIndex[1]
AsiaIBEndIndex := AsiaIBEnd? bar_index : AsiaIBEndIndex[1]
// Calculate Highs and Lows
AsiaIBHigh = 0.0, AsiaIBLow = 0.0
AsiaIBHigh := high >= AsiaIBHigh[1]? high : AsiaIBHigh[1]
AsiaIBLow := low <=AsiaIBLow[1]? low : AsiaIBLow[1]
// Reset at start of range
AsiaIBHigh := AsiaIBStart? high : AsiaIBHigh
AsiaIBLow := AsiaIBStart? low : AsiaIBLow
// Get open and close for range
AsiaIBOpen = 0.0, AsiaIBClose = 0.0
AsiaIBOpen := AsiaIBStart? open : AsiaIBOpen[1]
AsiaIBClose := AsiaIBEnd? close : AsiaIBClose[1]
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.none,bgcolor=AsiaBoxIBBGColor)
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff and isToday and ExtendIBTodayBox
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.right,bgcolor=AsiaBoxIBBGColor)
// Draw Previous IB Box
isYesterday = dayofmonth(time[1]) == dayofmonth(timenow[1])
PrevAsiaIBHigh = valuewhen(bar_index==AsiaIBEndIndex,AsiaIBHigh,1)
PrevAsiaIBLow = valuewhen(bar_index==AsiaIBEndIndex,AsiaIBLow,1)
if AsiaIBEnd and AsiaIBOnOff and isYesterday and ExtendIBYesterdayBox
AsiaIBBox = box.new(AsiaIBStartIndex[1], PrevAsiaIBHigh, AsiaIBEndIndex[1], PrevAsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.right,bgcolor=AsiaBoxIBBGColor)
// Draw current box if currently in range
box AsiaIBBox = na
if AsiaIBinRange and barstate.islast and AsiaIBOnOff and isToday
AsiaIBBox := box.new(AsiaIBStartIndex, AsiaIBHigh, bar_index, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.none,bgcolor=AsiaBoxIBBGColor)
box.delete(AsiaIBBox[1])
早上好,
我如何将下面脚本中的框扩展到今天和昨天?
我可以让方框出现并全部扩展。但希望可以选择只延长今天和昨天。这可以作为单独的选项。
箱子
全部扩展(看起来很乱,没有实现)
下面我用绘图工具展示了我想展示的内容
//@version=4
study("Asia IB Testing - Delete Me", overlay = true)
AsiaInputColor = input(color.purple, title="Asia", group = "Session Boxes - Settings", inline = "Input 1")
NoBoxIBOutline = input(true, title="Turn IB Box Outline On/Off", group="Session Boxes - Settings")
NoBoxIBBGColor = input(true, title="Turn IB Box Background Colour On/Off", group="Session Boxes - Settings")
BGIBGradiant = input(85,title="Box IB Background color gradiant", group="Session Boxes - Settings")
//#######################################################################################
////////How do I incorperate this, so that the user can select to extend only today IBs/box and yesterdays
//#######################################################################################
isToday = dayofmonth(time) == dayofmonth(timenow)
ExtendOnlyToday = isToday ? extend.right : na
ExtendIBBox = input(false, title="Extend previous and todays Intial Balance Boxes")
ExtendOption = ExtendIBBox ? extend.right : extend.none
Switch = input(true, title="Dotted/Solid Box Outline", group="Session Boxes - Settings")
SolidDotted = Switch ? line.style_solid : line.style_dotted
AsiaBoxIBOutline = NoBoxIBOutline ? AsiaInputColor : na
AsiaBoxIBBGColor = NoBoxIBBGColor ? color.new(AsiaInputColor, BGIBGradiant) : na
//// Asia Initial Balance
AsiaIBOnOff = input(true, title = "", group = 'Session Boxes', inline = "2")
AsiaIBTimeRangeInput = input("0130-0230", "Asia IB Session", input.session, group = 'Session Boxes', inline = "2")
AsiaIBDateRange = ":1234567"
AsiaIBTimeRange = AsiaIBTimeRangeInput+AsiaIBDateRange
AsiaIBinRange = time(timeframe.period, AsiaIBTimeRange)
// AsiaIBTimeRange = input("0130-0230:1234567", type=input.session, title='Asia IB Session', group = 'Session Boxes')
// AsiaIBinRange = (time(timeframe.period, AsiaIBTimeRange))
// First and Last bar in Range
AsiaIBStart = AsiaIBinRange and not AsiaIBinRange[1]
AsiaIBEnd = not AsiaIBinRange and AsiaIBinRange[1]
// Bar Index of Start and End
AsiaIBStartIndex = 0, AsiaIBEndIndex = 0
AsiaIBStartIndex := AsiaIBStart? bar_index : AsiaIBStartIndex[1]
AsiaIBEndIndex := AsiaIBEnd? bar_index : AsiaIBEndIndex[1]
// Calculate Highs and Lows
AsiaIBHigh = 0.0, AsiaIBLow = 0.0
AsiaIBHigh := high >= AsiaIBHigh[1]? high : AsiaIBHigh[1]
AsiaIBLow := low <=AsiaIBLow[1]? low : AsiaIBLow[1]
// Reset at start of range
AsiaIBHigh := AsiaIBStart? high : AsiaIBHigh
AsiaIBLow := AsiaIBStart? low : AsiaIBLow
// Get open and close for range
AsiaIBOpen = 0.0, AsiaIBClose = 0.0
AsiaIBOpen := AsiaIBStart? open : AsiaIBOpen[1]
AsiaIBClose := AsiaIBEnd? close : AsiaIBClose[1]
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, ExtendOption,bgcolor=AsiaBoxIBBGColor)
// Draw current box if currently in range
box AsiaIBBox = na
if AsiaIBinRange and barstate.islast and AsiaIBOnOff
AsiaIBBox := box.new(AsiaIBStartIndex, AsiaIBHigh, bar_index, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, ExtendOption,bgcolor=AsiaBoxIBBGColor)
box.delete(AsiaIBBox[1])
回答如下:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Frien_dd
//@version=4
study("Asia IB Testing - Delete Me", overlay = true)
AsiaInputColor = input(color.purple, title="Asia", group = "Session Boxes - Settings", inline = "Input 1")
NoBoxIBOutline = input(true, title="Turn IB Box Outline On/Off", group="Session Boxes - Settings")
NoBoxIBBGColor = input(true, title="Turn IB Box Background Colour On/Off", group="Session Boxes - Settings")
BGIBGradiant = input(85,title="Box IB Background color gradiant", group="Session Boxes - Settings")
isToday = dayofmonth(time) == dayofmonth(timenow)
ExtendIBTodayBox = input(false, title="Extend todays Intial Balance Boxes")
ExtendIBYesterdayBox = input(false, title="Extend previous days Intial Balance Boxes")
Switch = input(true, title="Dotted/Solid Box Outline", group="Session Boxes - Settings")
SolidDotted = Switch ? line.style_solid : line.style_dotted
AsiaBoxIBOutline = NoBoxIBOutline ? AsiaInputColor : na
AsiaBoxIBBGColor = NoBoxIBBGColor ? color.new(AsiaInputColor, BGIBGradiant) : na
//// Asia Initial Balance
AsiaIBOnOff = input(true, title = "", group = 'Session Boxes', inline = "2")
AsiaIBTimeRangeInput = input("0130-0230", "Asia IB Session", input.session, group = 'Session Boxes', inline = "2")
AsiaIBDateRange = ":1234567"
AsiaIBTimeRange = AsiaIBTimeRangeInput+AsiaIBDateRange
AsiaIBinRange = time(timeframe.period, AsiaIBTimeRange)
// First and Last bar in Range
AsiaIBStart = AsiaIBinRange and not AsiaIBinRange[1]
AsiaIBEnd = not AsiaIBinRange and AsiaIBinRange[1]
// Bar Index of Start and End
AsiaIBStartIndex = 0, AsiaIBEndIndex = 0
AsiaIBStartIndex := AsiaIBStart? bar_index : AsiaIBStartIndex[1]
AsiaIBEndIndex := AsiaIBEnd? bar_index : AsiaIBEndIndex[1]
// Calculate Highs and Lows
AsiaIBHigh = 0.0, AsiaIBLow = 0.0
AsiaIBHigh := high >= AsiaIBHigh[1]? high : AsiaIBHigh[1]
AsiaIBLow := low <=AsiaIBLow[1]? low : AsiaIBLow[1]
// Reset at start of range
AsiaIBHigh := AsiaIBStart? high : AsiaIBHigh
AsiaIBLow := AsiaIBStart? low : AsiaIBLow
// Get open and close for range
AsiaIBOpen = 0.0, AsiaIBClose = 0.0
AsiaIBOpen := AsiaIBStart? open : AsiaIBOpen[1]
AsiaIBClose := AsiaIBEnd? close : AsiaIBClose[1]
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.none,bgcolor=AsiaBoxIBBGColor)
// Draw previous boxes
if AsiaIBEnd and AsiaIBOnOff and isToday and ExtendIBTodayBox
AsiaIBBox = box.new(AsiaIBStartIndex, AsiaIBHigh, AsiaIBEndIndex, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.right,bgcolor=AsiaBoxIBBGColor)
// Draw Previous IB Box
isYesterday = dayofmonth(time[1]) == dayofmonth(timenow[1])
PrevAsiaIBHigh = valuewhen(bar_index==AsiaIBEndIndex,AsiaIBHigh,1)
PrevAsiaIBLow = valuewhen(bar_index==AsiaIBEndIndex,AsiaIBLow,1)
if AsiaIBEnd and AsiaIBOnOff and isYesterday and ExtendIBYesterdayBox
AsiaIBBox = box.new(AsiaIBStartIndex[1], PrevAsiaIBHigh, AsiaIBEndIndex[1], PrevAsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.right,bgcolor=AsiaBoxIBBGColor)
// Draw current box if currently in range
box AsiaIBBox = na
if AsiaIBinRange and barstate.islast and AsiaIBOnOff and isToday
AsiaIBBox := box.new(AsiaIBStartIndex, AsiaIBHigh, bar_index, AsiaIBLow, AsiaBoxIBOutline, 1, SolidDotted, extend.none,bgcolor=AsiaBoxIBBGColor)
box.delete(AsiaIBBox[1])