admin管理员组文章数量:1404349
I'm working on a script that includes a Fibonacci projection to determine the duration and end of the operation, calculating the projection levels by the highest bottom among 20 bars prior to the order entry and using the entry price as a parameter 0.38 of the Fibonacci projection to calculate the other values and ok, I've done that, but I would like the values of the lines not to be changed until the end of the operation. I managed to create the lines, but throughout the operation, they change their original values, ruining the objective. I need to keep these values until the end of a condition that closes the operation. I've tried with Hline and Line.new but I couldn't. this is my code:
var bool longing := false
var float longentryprice := na
var float stoploss := na
var float longbottom := na
var distafibo61a := na
var distafibo100a := na
var distafibo161 := na
longentry = longing== false and ta.crossover(ema21, ema64)
if longentry
longing := true
longentryprice := ta.valuewhen(longentry, close, 0)
longbottom := (ta.lowest(close, 20)[1]
distafibo61a := longbottom + (((longentryprice - longbottom) * 61.8) / 38.2)
distafibo100a := longbottom + (((longentryprice - longbottom) * 100) / 38.2)
distafibo161a := distafibo100a + (((longentryprice - longbottom) * 61.8) / 38.2)
strategy.entry("long") ////make entry long /////
stoploss := longbottom ////define primary stoploss////
plot(distafibo61a, color=color.rgb(186, 255, 88), title="Fibo 61")
plot(distafibo100a,color=color.rgb(81, 188, 84), title="Fibo 100")
plot(longbottom, color=color.rgb(96, 96, 96), title="long bottom")
plot(distafibo161a,color=#54bbad, title="fibo161")
if close > distafibo100a //define firt stopgain//
stoploss := distafibo61a
if close > distafibo161a //define maximum stopgain//
strategy.exit("long") //close operation maximum profit//
if close < stoploss //close operation and reset variables///
longing := false
var bool longing := false
longentryprice := na
stoploss := na
longbottom := na
distafibo61a := na
distafibo100a := na
distafibo161a := na
strategy.exit("long")
enter image description here
本文标签:
版权声明:本文标题:pine script - How can I keep values found with the lowest function without changes until the end of a condition? - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744788194a2625127.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论