somebritishbloke
New member
Hello,
I'm new and trying to create a watchlist column that changes color from red to green whenever the ATRTrailstop study crosses above or below the price of a stock....the idea being that it's a potential entry/exit point.
I've been using the below watchlist code to trigger for EMA crossovers and it works perfectly... but I'm having difficulty working out the code to get it to take by changing the values from an EMA cross to ATRTrailstop cross. I know there are lots of squared away people on here and I hate bothering anyone... but is there anyone out there who can help fix this?
I can get the study to work just fine in a watchlist by using
I just get it to take and I feel kind of useless... This is what I'm trying to modify:
Thankyou to EVERYONE who has helped with code in the past...this is such a great group!
Malcolm
I'm new and trying to create a watchlist column that changes color from red to green whenever the ATRTrailstop study crosses above or below the price of a stock....the idea being that it's a potential entry/exit point.
I've been using the below watchlist code to trigger for EMA crossovers and it works perfectly... but I'm having difficulty working out the code to get it to take by changing the values from an EMA cross to ATRTrailstop cross. I know there are lots of squared away people on here and I hate bothering anyone... but is there anyone out there who can help fix this?
I can get the study to work just fine in a watchlist by using
Code:
close crosses ATRTrailingStop("atr factor" = 2.5, "average type" = "EXPONENTIAL")
I just get it to take and I feel kind of useless... This is what I'm trying to modify:
Code:
declare lower;
input lookback = 1;
input ema1_len = 10;
input ema2_len = 20;
input averageType = AverageType.EXPONENTIAL;
def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);
def bull_cross = ema1 crosses above ema2;
def bear_cross = ema1 crosses below ema2;
def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);
plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
signal.AssignValueColor(if signal == 2 then Color.Green else if signal == 1 then Color.Red else Color.BLACK);
AssignBackgroundCOlor(if signal == 2 then Color.Green else if signal == 1 then Color.Red else Color.BLACK);
Thankyou to EVERYONE who has helped with code in the past...this is such a great group!
Malcolm
Last edited: