I just need a piece of code that will keep the labels to just a single bar when all the conditions are met and not repeat until the trend reverses. It should print a label when the EMA>SMA and price closes>open and not repeat for every bar after that is closed>open and while EMA>SMA during bull trend. It should repeat after the EMA<SMA then crosses back above SMA. I will then do the same for bear trends as well. Here's what I have so far:
if maExp>maSimp and close>open
// Make label
buyLabel := label.new(x=bar_index, y=na, yloc=yloc.abovebar,
style=label.style_labeldown, color=color.new(color.green, 0),
text="Buy", textcolor=color.white)
As you can see, I got buy labels for days. Thanks in advance for your help. I look forward to learning more.
Aucun commentaire:
Enregistrer un commentaire