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

利益

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

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

//@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条评论
登录后参与评论

相关文章

来自分类Dev

一些PC游戏由于未知原因而崩溃

来自分类Dev

由于未知原因,一些高位图表类别丢失

来自分类Dev

Rails:Faye为我工作,但由于某些未知原因,控制台中仍然出现一些JS错误,我应该担心吗?

来自分类Dev

由于冲突而无法删除一些未标记的Docker映像

来自分类Dev

由于一些angularjs问题,数据未显示在html文件中

来自分类Dev

OpenAPI的一些未知值

来自分类Dev

一些设计消息未显示

来自分类Dev

一些div背景未显示

来自分类Dev

一些div背景未显示

来自分类Dev

boost :: extension.hpp的原因未为无序容器和其他一些容器定义hash_value()

来自分类Dev

numpy一次绘制一些bernoulli分布

来自分类Dev

一些highcharts类别失踪原因不明

来自分类Dev

CSS在页面末尾有一些空间,原因浮动?

来自分类Dev

一些字形的“实例”消失了-如何查明原因?

来自分类Dev

wordpress拒绝一些mp3-安全原因

来自分类Dev

由于未知原因获取TypeError

来自分类Dev

在x轴上绘制一些数字

来自分类Dev

OpenGL仅从顶点数组绘制一些索引

来自分类Dev

在matlab中绘制一些数据,例如pairs

来自分类Dev

如何拆分数据框并绘制一些列

来自分类Dev

由于某些未知原因,变量未插入另一个变量:将文本转换为二进制

来自分类Dev

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:未知的布局属性'

来自分类Dev

Silverlight应用程序由于未知原因停止工作(未更改服务器或代码)

来自分类Dev

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:未知的布局属性'

来自分类Dev

Github预定提醒-未链接一些松弛提及

来自分类Dev

Swift(一些)UITableViewDelegate方法未执行

来自分类Dev

* RMarkdown的*一些图标题未显示

来自分类Dev

Kibana保留了一些未索引的字段

来自分类Dev

新分支只有一些未提交的更改

Related 相关文章

  1. 1

    一些PC游戏由于未知原因而崩溃

  2. 2

    由于未知原因,一些高位图表类别丢失

  3. 3

    Rails:Faye为我工作,但由于某些未知原因,控制台中仍然出现一些JS错误,我应该担心吗?

  4. 4

    由于冲突而无法删除一些未标记的Docker映像

  5. 5

    由于一些angularjs问题,数据未显示在html文件中

  6. 6

    OpenAPI的一些未知值

  7. 7

    一些设计消息未显示

  8. 8

    一些div背景未显示

  9. 9

    一些div背景未显示

  10. 10

    boost :: extension.hpp的原因未为无序容器和其他一些容器定义hash_value()

  11. 11

    numpy一次绘制一些bernoulli分布

  12. 12

    一些highcharts类别失踪原因不明

  13. 13

    CSS在页面末尾有一些空间,原因浮动?

  14. 14

    一些字形的“实例”消失了-如何查明原因?

  15. 15

    wordpress拒绝一些mp3-安全原因

  16. 16

    由于未知原因获取TypeError

  17. 17

    在x轴上绘制一些数字

  18. 18

    OpenGL仅从顶点数组绘制一些索引

  19. 19

    在matlab中绘制一些数据,例如pairs

  20. 20

    如何拆分数据框并绘制一些列

  21. 21

    由于某些未知原因,变量未插入另一个变量:将文本转换为二进制

  22. 22

    由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:未知的布局属性'

  23. 23

    Silverlight应用程序由于未知原因停止工作(未更改服务器或代码)

  24. 24

    由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:未知的布局属性'

  25. 25

    Github预定提醒-未链接一些松弛提及

  26. 26

    Swift(一些)UITableViewDelegate方法未执行

  27. 27

    * RMarkdown的*一些图标题未显示

  28. 28

    Kibana保留了一些未索引的字段

  29. 29

    新分支只有一些未提交的更改

热门标签

归档