Lesnewby
Member
How can I convert the two scans/studies into a strategy that allows me to backcheck a bunch of selected stocks with the results in a tos Report.
Make a strategy from a scan: The way I use the scans is to look for two consecutive green candles in Heiken-Ashe Chart, confirm with a 20 day SMA over a 100 day SMA for an up trend and sell a credit spread with a 45 to 60 day expiration. Not all stocks are good candidates, so I wish to use a strategy that sells to open at the close of the second green candle and buy back at the close of the second RED candle. Have used this manual with quite good success.
#2GrnBars
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose > haOpen;
def trendUp = haColor and haColor[1] and !haColor[2];
plot scan = trendUp;
XXXX
#2RedBars
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose < haOpen;
def trendUp = haColor and haColor[1] and !haColor[2];
plot scan = trendUp;
#Template for Strategies
input tradeSize = 100;
def signal = 0;
addOrder(OrderType.BUY_TO_OPEN, signal, open[-1], tradeSize, Color.CYAN, Color.CYAN);
def exit = 0;
addOrder(OrderType.SELL_TO_CLOSE, exit, open[-1], tradeSize, Color.MAGENTA, Color.MAGENTA);
#Template for Lower Studies
declare lower;
plot signal = 0;
plot exit = 0;
Make a strategy from a scan: The way I use the scans is to look for two consecutive green candles in Heiken-Ashe Chart, confirm with a 20 day SMA over a 100 day SMA for an up trend and sell a credit spread with a 45 to 60 day expiration. Not all stocks are good candidates, so I wish to use a strategy that sells to open at the close of the second green candle and buy back at the close of the second RED candle. Have used this manual with quite good success.
#2GrnBars
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose > haOpen;
def trendUp = haColor and haColor[1] and !haColor[2];
plot scan = trendUp;
XXXX
#2RedBars
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose < haOpen;
def trendUp = haColor and haColor[1] and !haColor[2];
plot scan = trendUp;
#Template for Strategies
input tradeSize = 100;
def signal = 0;
addOrder(OrderType.BUY_TO_OPEN, signal, open[-1], tradeSize, Color.CYAN, Color.CYAN);
def exit = 0;
addOrder(OrderType.SELL_TO_CLOSE, exit, open[-1], tradeSize, Color.MAGENTA, Color.MAGENTA);
#Template for Lower Studies
declare lower;
plot signal = 0;
plot exit = 0;
Last edited: