dap711
Active member
Hi Traders!
This is a spin off of the Moving Average Master strategy and a place to discuss results of the new strategy.
ASAP (SMI) lower study shared link: https://tos.mx/nuGeZqV
ASAP strategy shared link: https://tos.mx/caRLjIg
ASAP (SMI) lower study:
ASAP Strategy Code:
This is a spin off of the Moving Average Master strategy and a place to discuss results of the new strategy.
ASAP (SMI) lower study shared link: https://tos.mx/nuGeZqV
ASAP strategy shared link: https://tos.mx/caRLjIg
ASAP (SMI) lower study:
Ruby:
#Inspired by the IronRod SMI Histogram
#Modified and cleaned up - dap711 -2023
declare lower;
input Length = 20;
def Limit = 20;
def range= 70;
def overbought = Limit;
def oversold = -Limit;
# Stochastic Momentum Index (SMI)
def min_low = Lowest(low, Length+1);
def max_high = Highest(high, Length+1);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, Length), Length);
def avgdiff = ExpAverage(ExpAverage(diff, Length), Length);
def SMI1 = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
plot SMI = reference EhlersSuperSmootherFilter(price = SMI1, "cutoff length" = Length) ;
SMI.DefineColor("Up", CreateColor(0, 153, 51));
SMI.definecolor("Weak", Color.LIGHT_GRAY);
SMI.DefineColor("Down", Color.RED);
SMI.AssignValueColor(if SMI > SMI[1] then SMI.Color("Up") else if SMI < SMI[1] then SMI.Color("Down") else SMI.Color("Weak"));
SMI.SetLineWeight(1);
SMI.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SMI.SetLineWeight(1);
plot rangeband = if IsNaN(close) then Double.NaN else 0;
rangeband.HideBubble();
rangeband.SetLineWeight(2);
rangeband.AssignValueColor(Color.Gray);
def rangelimits = Limit;
plot upper= Limit;
plot lower= -Limit;
# Labels
AddLabel(SMI < -Limit or SMI > Limit, "Market is trending", CreateColor(0,150,200));
AddLabel(SMI > -Limit and SMI < Limit, "Market is Consolidating", Color.ORANGE);
ASAP Strategy Code:
Ruby:
# ASAP (as simple as possible) Author dap711 - 2023
# Q. Why do I share my strategies?
# A. It would be completely and totally silly of me (and you!) to keep them to myself. Who remembers what happen with GameStop? The more people doing the exact same thing at the same time in the market, the more power they have in moving the market in their favor! If we had an army of traders using the same system, oh what power we would have! We (the retail trader) could take the power back from the market makers!
# 1. Adjust the length settings for the best FloatingPL and then let'r rip!
input BackTestTradeSize = 1;
input ShowBackTestPositions = yes;
input Length = 18;
input AlertOnSignal = no;
#Add your indicator code here (if you want to use this as a template) :)
def min_low = Lowest(low, Length+1);
def max_high = Highest(high, Length+1);
def rel_diff = close - (max_high + min_low) / 2;
def range = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, Length), Length );
def avgdiff = ExpAverage(ExpAverage(range, Length), Length);
def SMI1 = if avgdiff != 0 then avgrel / (avgdiff / 2)*10 else 0;
def SMI = reference EhlersSuperSmootherFilter(price = SMI1, "cutoff length" = Length) ;
#Define the signals
def BuyToOpenSignal = SMI >= SMI[1];
def SellToOpenSignal = SMI < SMI[1];
#Open the orders on the chart for back testing and optimizing the setting
AddOrder(OrderType.BUY_AUTO, BuyToOpenSignal and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN, Color.CYAN, "");
AddOrder(OrderType.SELL_AUTO, SellToOpenSignal and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");
#Add the signal labels to the chart
AddLabel(yes, " BUY ", if BuyToOpenSignal[1] crosses above BuyToOpenSignal[2] then CreateColor(153, 255, 153) else Color.White);
AddLabel(yes, " SELL ", if SellToOpenSignal[1] crosses above SellToOpenSignal[2] then CreateColor(255, 102, 102) else Color.White);
#Sound the bell. (If alerts are turn on)
Alert(BuyToOpenSignal[1] crosses above BuyToOpenSignal[2] and AlertOnSignal, "Buy Open Signal", Alert.Bar, Sound.Ding);
Alert(SellToOpenSignal[1] crosses above SellToOpenSignal[2] and AlertOnSignal, "Sell Open Signal", Alert.Bar, Sound.Ding);
#“Make everything as simple as possible, but not simpler.” Albert Einstein.
Last edited: