由于某些未知原因,一些阻力没有被绘制出来
Some resistance is not plotted for some unknown reason
我完成了支撑和阻力的代码。我为上一季度和一个月的高点和低点添加了额外的条件。它现在绘制得很好,但在某些情况下它没有绘制应该存在的阻力,我不明白为什么会这样。
绿色箭头代表支撑,红色箭头代表阻力。
在右侧的 2 个峰值处,应该绘制阻力红色箭头,因为价格穿过前一季度和一个月的低点,然后向上穿过前一周的高点,同时保持在前一季度和一个月的高点下方,但没有绘制任何东西.
//@version=4
//By Juros
// Resistance is not plotted 100% accurate, some are missing.
//-------------------------------
// support
// If the price crosses above the previous quarter high and previous month high, and then crosses down the previous week low, the close becomes a support.
//As long as the price stays then below the previous week high, each close becomes a support. The condition remains as long as the prices do not cross
//below previous quarter low OR previous month low, then support also stops.
//-------------------------------
// resistance
// If the price crosses below the previous quarter low and previous month low, and then crosses up the previous week high, the close becomes a resistance.
// As long as the price stays then above the previous week low, each close becomes a support. The condition remains as long as the price does not cross
// above previous quarter high OR previous month high, then resistance also stops.
study(title="Universal support and resistance", shorttitle="Univ sup & res", overlay=true, precision=8)
prevwkH = input(true, title="Show previous week high")
prevwkL = input(true, title="show previous week low?")
prevMH = input(true, title= "Show previous month high")
prevML = input(true, title= "Show previous month low")
prevQH = input(true, title= "Show previous quarter high")
prevQL = input(true, title= "Show previous quarter low")
//previous week high and low
prevWeekHigh = security(syminfo.tickerid, 'W', high[1], lookahead=true)
prevWeekLow = security(syminfo.tickerid, 'W', low[1], lookahead=true)
//previous Week Plots
plot(prevwkH and prevWeekHigh ? prevWeekHigh : na, title="Prev Week High", style=plot.style_stepline, linewidth=1, color=color.fuchsia,transp=20)
plot(prevwkL and prevWeekLow ? prevWeekLow : na, title="Prev Week Low", style=plot.style_stepline, linewidth=1, color=color.fuchsia,transp=20)
//-------------------------------------------------------
// Previous month high and low
prevMonthHigh = security(syminfo.tickerid, 'M', high[1], lookahead=true)
prevMonthLow = security(syminfo.tickerid, 'M', low[1], lookahead=true)
plot(prevMH and prevMonthHigh ? prevMonthHigh : na, title="Prev Month High", style=plot.style_stepline, linewidth=1, color=color.orange, transp=40)
plot(prevML and prevMonthLow ? prevMonthLow : na, title="Prev Month Low", style=plot.style_stepline, linewidth=1, color=color.orange, transp=40)
//-------------------------------------------------------------
//Previous quarter high and low
prevQuarterHigh = security(syminfo.tickerid, '3M', high[1], lookahead=true)
prevQuarterLow = security(syminfo.tickerid, '3M', low[1], lookahead=true)
plot(prevQH and prevQuarterHigh ? prevQuarterHigh : na, title="Prev Quarter High", style=plot.style_stepline, linewidth=1, color=color.aqua, transp=0)
plot(prevQL and prevQuarterLow ? prevQuarterLow : na, title="Prev Quarter Low", style=plot.style_stepline, linewidth=1, color=color.aqua, transp=0)
//-------------------------------------------------------------
upTrend = false
upTrend := (not upTrend[1] and crossover(close, prevQuarterHigh)) or (upTrend[1] and not crossunder(low, prevQuarterLow) or (not upTrend[1] and crossover(high, prevMonthHigh)) or upTrend[1] and not crossunder(low, prevMonthLow))
//-------------------------------------------------------------
// weekly support and resistance
var isSupport = false
var isResistance = false
if (crossunder(low, prevWeekLow))
isSupport := true
isResistance := false
if (crossover(high, prevWeekHigh))
isSupport := false
isResistance := true
//-------------------------------------------------------------
// Monthly support
var isSupportM = false
if (crossunder(low, prevMonthLow))
isSupportM := false
if (crossover(high, prevMonthHigh))
isSupportM := true
//-------------------------------------------------------------
// Quarterly support
var isSupportQ = false
if (crossunder(low, prevQuarterLow))
isSupportQ := false
if (crossover(high, prevQuarterHigh))
isSupportQ := true
//-------------------------------------------------------------
// Monthly resistance
var isResistanceM = false
if (crossunder(low, prevMonthLow))
isResistanceM := true
if (crossover(high, prevMonthHigh))
isResistanceM := false
//-------------------------------------------------------------
// Quarterly resistance
var isResistanceQ = false
if (crossunder(low, prevQuarterLow))
isResistanceQ := true
if (crossover(high, prevQuarterHigh))
isResistanceQ := false
//plot support & resistance
plotshape (upTrend and isSupport and isSupportM and isSupportQ ? close: na, style=shape.arrowup, location=location.belowbar, color=color.green, size=size.normal, transp=0 )
plotshape (not upTrend and isResistance and isResistanceM and isResistanceQ ? close: na, style=shape.arrowdown, location=location.abovebar, color=color.red, size= size.normal, transp=0 )
让我们看看绘制一些重要信号的情况。
plotshape (not upTrend and isResistance and isResistanceM and isResistanceQ ? close: na, style=shape.arrowdown, location=location.abovebar, color=color.red, size= size.normal, transp=0 )
这是您绘制阻力的原始绘图函数。因此,您的条件不仅是价格低于前一个月和前一季度的低点,而且 upTrend
也是一个条件。
我建议我们应该看看 not upTrend
、isResistance
、isResistanceM
、isResistanceQ
。请注意 not upTrend
,因为您的情况正是这样,而不是 upTrend
本身。
使用 overlay=false
创建一个新指标,然后复制并粘贴您的原始代码。然后删除所有绘图功能并在最后添加以下代码。
plot(series=not upTrend ? 1:0, title="not upTrend", color=color.orange, linewidth=2)
plot(series=isResistance ? 1:0, title="isResistance", color=color.green, linewidth=2)
plot(series=isResistanceM ? 1:0, title="isResistanceM", color=color.red, linewidth=2)
plot(series=isResistanceQ ? 1:0, title="isResistanceQ", color=color.blue, linewidth=2)
所有这些变量都必须 TRUE
以便您的指标绘制任何给定蜡烛的阻力箭头。好吧,从技术上讲,upTrend
必须是 FALSE
,因为您使用的是 not upTrend
。我的意思是 not upTrend
必须评估为 TRUE
.
如果您查看信号,您会发现橙色信号 (not upTrend
) 在这些点上是 0
。这就是阻止您的指标绘制阻力的原因。
所以,你应该看看 upTrend
。
我们只能指出导致问题的原因。修复应该来自您,因为它是您的算法,是您检测上升趋势的方式。
但是,如果您认为 upTrend
的计算有问题,那是另一个话题,需要在这里提出另一个问题。
我完成了支撑和阻力的代码。我为上一季度和一个月的高点和低点添加了额外的条件。它现在绘制得很好,但在某些情况下它没有绘制应该存在的阻力,我不明白为什么会这样。
绿色箭头代表支撑,红色箭头代表阻力。 在右侧的 2 个峰值处,应该绘制阻力红色箭头,因为价格穿过前一季度和一个月的低点,然后向上穿过前一周的高点,同时保持在前一季度和一个月的高点下方,但没有绘制任何东西.
//@version=4
//By Juros
// Resistance is not plotted 100% accurate, some are missing.
//-------------------------------
// support
// If the price crosses above the previous quarter high and previous month high, and then crosses down the previous week low, the close becomes a support.
//As long as the price stays then below the previous week high, each close becomes a support. The condition remains as long as the prices do not cross
//below previous quarter low OR previous month low, then support also stops.
//-------------------------------
// resistance
// If the price crosses below the previous quarter low and previous month low, and then crosses up the previous week high, the close becomes a resistance.
// As long as the price stays then above the previous week low, each close becomes a support. The condition remains as long as the price does not cross
// above previous quarter high OR previous month high, then resistance also stops.
study(title="Universal support and resistance", shorttitle="Univ sup & res", overlay=true, precision=8)
prevwkH = input(true, title="Show previous week high")
prevwkL = input(true, title="show previous week low?")
prevMH = input(true, title= "Show previous month high")
prevML = input(true, title= "Show previous month low")
prevQH = input(true, title= "Show previous quarter high")
prevQL = input(true, title= "Show previous quarter low")
//previous week high and low
prevWeekHigh = security(syminfo.tickerid, 'W', high[1], lookahead=true)
prevWeekLow = security(syminfo.tickerid, 'W', low[1], lookahead=true)
//previous Week Plots
plot(prevwkH and prevWeekHigh ? prevWeekHigh : na, title="Prev Week High", style=plot.style_stepline, linewidth=1, color=color.fuchsia,transp=20)
plot(prevwkL and prevWeekLow ? prevWeekLow : na, title="Prev Week Low", style=plot.style_stepline, linewidth=1, color=color.fuchsia,transp=20)
//-------------------------------------------------------
// Previous month high and low
prevMonthHigh = security(syminfo.tickerid, 'M', high[1], lookahead=true)
prevMonthLow = security(syminfo.tickerid, 'M', low[1], lookahead=true)
plot(prevMH and prevMonthHigh ? prevMonthHigh : na, title="Prev Month High", style=plot.style_stepline, linewidth=1, color=color.orange, transp=40)
plot(prevML and prevMonthLow ? prevMonthLow : na, title="Prev Month Low", style=plot.style_stepline, linewidth=1, color=color.orange, transp=40)
//-------------------------------------------------------------
//Previous quarter high and low
prevQuarterHigh = security(syminfo.tickerid, '3M', high[1], lookahead=true)
prevQuarterLow = security(syminfo.tickerid, '3M', low[1], lookahead=true)
plot(prevQH and prevQuarterHigh ? prevQuarterHigh : na, title="Prev Quarter High", style=plot.style_stepline, linewidth=1, color=color.aqua, transp=0)
plot(prevQL and prevQuarterLow ? prevQuarterLow : na, title="Prev Quarter Low", style=plot.style_stepline, linewidth=1, color=color.aqua, transp=0)
//-------------------------------------------------------------
upTrend = false
upTrend := (not upTrend[1] and crossover(close, prevQuarterHigh)) or (upTrend[1] and not crossunder(low, prevQuarterLow) or (not upTrend[1] and crossover(high, prevMonthHigh)) or upTrend[1] and not crossunder(low, prevMonthLow))
//-------------------------------------------------------------
// weekly support and resistance
var isSupport = false
var isResistance = false
if (crossunder(low, prevWeekLow))
isSupport := true
isResistance := false
if (crossover(high, prevWeekHigh))
isSupport := false
isResistance := true
//-------------------------------------------------------------
// Monthly support
var isSupportM = false
if (crossunder(low, prevMonthLow))
isSupportM := false
if (crossover(high, prevMonthHigh))
isSupportM := true
//-------------------------------------------------------------
// Quarterly support
var isSupportQ = false
if (crossunder(low, prevQuarterLow))
isSupportQ := false
if (crossover(high, prevQuarterHigh))
isSupportQ := true
//-------------------------------------------------------------
// Monthly resistance
var isResistanceM = false
if (crossunder(low, prevMonthLow))
isResistanceM := true
if (crossover(high, prevMonthHigh))
isResistanceM := false
//-------------------------------------------------------------
// Quarterly resistance
var isResistanceQ = false
if (crossunder(low, prevQuarterLow))
isResistanceQ := true
if (crossover(high, prevQuarterHigh))
isResistanceQ := false
//plot support & resistance
plotshape (upTrend and isSupport and isSupportM and isSupportQ ? close: na, style=shape.arrowup, location=location.belowbar, color=color.green, size=size.normal, transp=0 )
plotshape (not upTrend and isResistance and isResistanceM and isResistanceQ ? close: na, style=shape.arrowdown, location=location.abovebar, color=color.red, size= size.normal, transp=0 )
让我们看看绘制一些重要信号的情况。
plotshape (not upTrend and isResistance and isResistanceM and isResistanceQ ? close: na, style=shape.arrowdown, location=location.abovebar, color=color.red, size= size.normal, transp=0 )
这是您绘制阻力的原始绘图函数。因此,您的条件不仅是价格低于前一个月和前一季度的低点,而且 upTrend
也是一个条件。
我建议我们应该看看 not upTrend
、isResistance
、isResistanceM
、isResistanceQ
。请注意 not upTrend
,因为您的情况正是这样,而不是 upTrend
本身。
使用 overlay=false
创建一个新指标,然后复制并粘贴您的原始代码。然后删除所有绘图功能并在最后添加以下代码。
plot(series=not upTrend ? 1:0, title="not upTrend", color=color.orange, linewidth=2)
plot(series=isResistance ? 1:0, title="isResistance", color=color.green, linewidth=2)
plot(series=isResistanceM ? 1:0, title="isResistanceM", color=color.red, linewidth=2)
plot(series=isResistanceQ ? 1:0, title="isResistanceQ", color=color.blue, linewidth=2)
所有这些变量都必须 TRUE
以便您的指标绘制任何给定蜡烛的阻力箭头。好吧,从技术上讲,upTrend
必须是 FALSE
,因为您使用的是 not upTrend
。我的意思是 not upTrend
必须评估为 TRUE
.
如果您查看信号,您会发现橙色信号 (not upTrend
) 在这些点上是 0
。这就是阻止您的指标绘制阻力的原因。
所以,你应该看看 upTrend
。
我们只能指出导致问题的原因。修复应该来自您,因为它是您的算法,是您检测上升趋势的方式。
但是,如果您认为 upTrend
的计算有问题,那是另一个话题,需要在这里提出另一个问题。