由于未知原因未绘制一些电阻

利益

我完成了支持和抵抗的代码。我添加了上一季度和本月最高和最低的其他条件。它现在绘制的很好,但是在某些情况下它并没有绘制应该存在的阻力,我不知道为什么会这样。绘制支撑和阻力

绿色箭头表示支撑,红色箭头表示阻力。在最右边的两个峰值处,应该绘制阻力红色箭头,因为价格在前一个季度和一个月的低点下方交叉,然后在前一个星期的高点上方交叉,同时保持在前一个季度和一个月的高点下方,但是没有绘制任何内容。

//@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 )

This is your original plot function to plot the resistance. So, your conditions are not only if the price crosses under the previous month and quarter low, but also the upTrend is a condition there.

I suggest we should have a look at not upTrend, isResistance, isResistanceM, isResistanceQ. Note the not upTrend, because your condition is exatly that and not upTrend itself.

Create a new indicator with overlay=false and copy&paste your original code there. Then remove all plot functions and add below code at the end.

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)

All of those variables must be TRUE in order for your indicator to plot the resistance arrow for any given candle. Well, technically, upTrend must be FALSE because you are using not upTrend. What I mean is not upTrend must evaluate to TRUE.

在此处输入图片说明

如果查看信号,您将看到橙色的一个(not upTrend0处于这些点。这就是阻止您的指标绘制阻力的原因。

因此,您应该看看upTrend

我们只能指出导致问题的原因。该修复程序应该来自您,因为它是您的算法,这是您检测上升趋势的方式。

但是,如果您认为的计算存在问题upTrend,那是另一个主题,并且在这里需要另一个问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章