Is it possible to set alerts when your indicator printed buy and sell?
joshatt
⋅
@TheLewis, I spent a lot of time trying to figure this one out. You can't have alerts on strategies. They have to be on studies. Also, I don't think there's a way to have the strategy.openprofit function recreated in a study. The best you can get is the open/close conditions to trigger an alert with something like this.
long = le ? 1 : 0
plot(long, title="Long")
But I haven't been able to get this to match what the strategy prints as you can see here
@SeaSide420, If you have any suggestions regarding this I'd appreciate it.
joshatt
⋅
Here is the study code for PT Long. Once you have this in there you can set an alert for greater than 0.99.
StopLoss = input(defval=-5000, title="Stop Loss in $", type=float, step=1)
TargetPoint = input(defval=57, title="Target Point in $", type=float, step=1)
price = input(ohlc4, type=source, title="Price data")
leftBars = input(1, title="Pivot LeftBars")
rightBars = input(1, title="Pivot RightBars")
// Checks for pivot high and low
// pivothigh/low returns a number for where the pivot is or NaN
swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice
le = false
le := swh_cond ? true : (le and high > hprice ? false : le)
long = le ? 1 : 0
plot(long, title="Long")
cultycove
⋅
@joshatt, I'm running into the same issue. Did you find a fix?