Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This code cannot be compiled or used in other pairs, it only works in BTC!!!

What should I do if I want to use it in other pairs?

( when I use this strategy on other pairs, I see a alarm notification in front of the indicator. If you hover your mouse pointer over this warning sign, you will notice a footnote that warns you that this indicator is not working properly and the information is not processed properly. (please look at to the second picture) ibb.co/zmCCDrm )

And how do I write a warning for that?

//@version=2
//                     simple cross of daily candle close
//
strategy("DailyCandleCross", shorttitle="DCC", overlay=true, calc_on_order_fills= true, calc_on_every_tick=true, default_qty_type=strategy.percent_of_equity, default_qty_value=75, pyramiding=0)
A=security(tickerid, 'D', close)
B=security(tickerid, 'D', close[1])
C=A>B
if(C)
    strategy.entry("Long", strategy.long)
if(not C)
    strategy.entry("Short", strategy.short)

Kind regards.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
552 views
Welcome To Ask or Share your Answers For Others

1 Answer

Updated the code to fix the cross calculation:
This code will print a "Long" label whenever the new daily candle close, cross over the previous daily candle close (That means it will generate a lot of labels!):

//@version=4
//                     simple cross of daily candle close
//
study("DailyCandleCross", shorttitle="DCC", overlay=true)
A=security(syminfo.tickerid, 'D', close)
longCondition = crossover(A , A[1])
shortCondition = crossunder(A , A[1])
if(longCondition)
    label.new(bar_index, low , "Long" ,style = label.style_label_up , color= color.green , textcolor= color.white)
if(shortCondition)
    label.new(bar_index, high , "Short" , color = color.red , textcolor= color.white)

Use the "crossover" function to check if a series crossed the other series.
To be honest I don't know if I understood your goal clearly or not and I don't know what are you trying to achieve with this either.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...