I can create scanners but cannot figure out how to combine the actions I need to take place as confirmations to buy or short.
For anyone that may be interested, This strategy has been working quite well for me. I hope someone can help me out with the proper coding to create a strategy with alerts and plots to buy/sell as well as a scanner that can let me know when any of the stocks on a watchlist will hit the required triggers.
On a 5min chart, I am using SSL with a crossover (The Blue and Yellow Lines). When the blue (smaHigh) or (sslUp) crosses over the yellow (smaLow) or (sslDown) and around the same time the CCI moves above the -100 oversold OR above the 100 overbought (within 5 bars). This is a by signal. and the opposite for a sell or short signal.
BTW, this has also worked pretty well for 1-4 min. charts as well. (I am still trying to decide the best option).
SSL Code:
input period = 13;
input len = 7;
def smaHigh = simpleMovingAvg(high, len);
def smaLow = simpleMovingAvg(low, len);
def Hlv = if close > smaHigh then 1 else if close<smaLow then -1 else Hlv[1];
def sslDown = if Hlv< 0 then smaHigh else smaLow;
def sslUp = if Hlv< 0 then smaLow else smaHigh;
plot up = sslUp;
plot down = sslDown;
up.SetDefaultColor(GetColor(1));
down.SetDefaultColor(GetColor(0));
############################################
CCI Code:
declare lower;
input length = 20;
input over_sold = -100;
input over_bought = 100;
input showBreakoutSignals = no;
def price = close + low + high;
def linDev = lindev(price, length);
plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
plot OverBought = over_bought;
plot ZeroLine = 0;
plot OverSold = over_sold;
plot UpSignal = if CCI crosses above ZeroLine then ZeroLine else Double.Nan;
plot DownSignal = if CCI crosses below ZeroLine then ZeroLine else Double.Nan;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
CCI.setDefaultColor(GetColor(9));
OverBought.setDefaultColor(GetColor(5));
ZeroLine.setDefaultColor(GetColor(5));
OverSold.setDefaultColor(GetColor(5));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
###########################################
What I have so far...
###########################################
input period = 13;
input len = 3;
def smaHigh = SimpleMovingAvg(high, len);
def smaLow = SimpleMovingAvg(low, len);
def Hlv = if close > smaHigh then 1 else if close < smaLow then -1 else Hlv[1];
def sslDown = if Hlv < 0 then smaHigh else smaLow;
def sslUp = if Hlv < 0 then smaLow else smaHigh;
def up = sslUp;
def down = sslDown;
input length = 20;
input over_sold = -100;
input over_bought = 100;
input showBreakoutSignals = no;
def price = close + low + high;
def linDev = LinDev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def OverBought = over_bought;
def ZeroLine = 0;
def OverSold = over_sold;
def UpSignal = if CCI crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal = if CCI crosses below ZeroLine then ZeroLine else Double.NaN;
plot Data = (sslUp > sslDown) and (CCI > over_bought) and (CCI > over_sold);
My Chart
Edited 1 time(s). Last edit at 07/06/2022 01:26PM by Metal.