簡體   English   中英

Plot 在更高的時間范圍內。 安全,可變變量,全局變量,function問題

[英]Plot on higher time frame. Security, mutable variable, global variable, function problem

我也在嘗試將 plot 從 15 分鍾到 Daily 的相同形狀。 這是 plot 的代碼,在 15 分鍾內運行良好;

if crossover(s3K,s3D) and s3K<25 and (s4K-s4D<3 and s4K-s4D>-3) and s4K<35//or s4D-s4K>0 and s4D-s4K<1 and s4K<50 and s1K<40
      rwCross:=true
plotshape(rwCross, style = shape.arrowup, location = location.belowbar, color=color.yellow, size=size.small)

但是我試過每天給 plot ;

rwCrossDaily = security(syminfo.tickerid,'D', rwCross)
plotshape(rwCrossDaily, style = shape.arrowup, location = location.belowbar, color=color.yellow, size=size.small)

這給了我可變變量錯誤。 所以我嘗試使用 function 來繞過它;

rwCross_func() =>
  if crossover(s3K,s3D) and s3K<25 and (s4K-s4D<3 and s4K-s4D>-3) and s4K<35//or s4D-s4K>0 and s4D-s4K<1 and s4K<50 and s1K<40
    rwCross:=true
rwCrossDaily = security(syminfo.tickerid,'D', rwCross_func())

但現在它告訴我“無法修改 function 中的全局變量‘rwCross’。” 請幫忙!

這里最好的解決方案和最干凈的解決方案是以最簡單的形式從您的條件中提取一個布爾值:

rwCross = crossover(s3K,s3D) and s3K<25 and (s4K-s4D<3 and s4K-s4D>-3) and s4K<35//or s4D-s4K>0 and s4D-s4K<1 and s4K<50 and s1K<40

沒有 if,rwCross 自然會變為 true。 這樣我們就不需要有任何可變的東西,盡管對於我們必須的情況有更多的解決方案......

干杯!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM