Dears,
I'm new in Pine Script and looking for your kind help.
I have this beginner-level script that gives (buy signal) when fast MA crossed over slow MA and kept higher than crossing price for 3 days which I call it confirmed bars.
However, I'm not able to generate take profit and stop loss signals.
I need TP signal when X% is generated. For instance, If the buy price is 100, it will be 110 (if x=10%)
the same thing with stop loss when the price is dropped down for a specific percentage.
//@version=4
strategy("MovingAvg Cross", overlay=true)
length = input(100)
confirmBars = input(3)
price = close
ma = sma(price, length)
bcond = price > ma
bcount = 0
bcount := bcond ? nz(bcount[1]) + 1 : 0
if (bcount == confirmBars)
strategy.entry("MACrossLE", strategy.long, comment="MACrossLE")
Pls help me.