Repaints NSDT HAMA Candles + SSL Channel For ThinkOrSwim

Repaints

samer800

Moderator - Expert
VIP
Lifetime

Ver 1.2
* added RSI filter, Background Color, some signal enhancement.



Code:
#study("NSDT HAMA Candles", overlay=true)
#//The follow gradient code is taken from the Pinecoders Gradient Framework example.
#//https://www.tradingview.com/script/hqH4YIFa-Color-Gradient-Framework-PineCoders/
#https://www.tradingview.com/script/k7nrF2oI-NSDT-HAMA-Candles/
# included SSL Channel https://www.tradingview.com/script/6y9SkpnV-SSL-Channel/
# Youtube strategy https://www.youtube.com/watch?v=YJrELewfIrU
#Converted by Sam4Cok @ 07/2022
#Ver 1.1 by Sam4Cok @ 07/2022  -- Added Filters (ADX / TDFI / Range Indicator and options to Show/Hide indicators
#Ver 1.2 by Sam4COK @ 07/2022 -- Added Background Color, RSI Filter, signal enhancment.

#//INPUTS
input ColorBar   = no;
input showArrow  = yes;
input BackgroundColor = no;
### NSDT ###
input TrendSource = close;
input HAMALength  = 69;
input HAMAType    = {default EMA, WMA, SMA, HMA};
input HAMABar     = yes;
input HAMAMa      = yes;
#//MA INFO
input OpenLength  = 25;                      #"Length Open"
input OpenType    = {default EMA, SMA, WMA}; #"Type Open"
input HighLength  = 20;                      #"Length High"
input HighType    = {default EMA, SMA, WMA}; #"Type High"
input LowLength   = 20;                      #"Low"
input LowType     = {default EMA, SMA, WMA}; #"Type Low"
input CloseLength = 20;                     #"Length Close"
input CloseType   = {default EMA, SMA, WMA}; #"Close"
### SSL1Source ###
input ShowSSL   = yes; #(true, "Highlight State ?")
input SSLWicks  = no;#(false, "Take Wicks into Account ?")
input SSLType   = {WMA, default SMA, EMA, HMA};
input SSL_MaLength = 69; #"MA "Channel ?
### RSI ###
input RSIFilter = no;
input RSILength = 30;
input RSIMovAvg = 200;
### TDFI ###
input TDFIFilter = no;
input TDFIPeriod =  11;   # "Lookback"
input TDFIAbove  =  0.03; # "Filter High"
input TDFIBelow  = -0.03; # "Filter Low"
### ADX ###
input ADXFilter = no;
input ADXLength = 11;
input ADXLimit  = 20;
### Range Indicator
input RangeIndicatorFilter = no;
input RILength       = 11;
input RangeLimit     = 20;
input RangeSmoothing = 5;
##################
def na = Double.NaN;
########## Colors ########
DefineGlobalColor("Bull"        , CreateColor(38, 166, 154)); # HAMA GREEN - Teal
DefineGlobalColor("Bear"        , CreateColor(239, 83, 80));  # HAMA Red
DefineGlobalColor("WeakBull"    , CreateColor(204, 204, 0));  # HAMA DARK Yellow  
DefineGlobalColor("WeakBear"    , CreateColor(255, 128, 0));  # HAMA Orange
DefineGlobalColor("Neutral"     , CreateColor(255, 255, 0));  # HAMA Yellow

DefineGlobalColor("BullBar"     , CreateColor(0, 255, 0));    # GREEN
DefineGlobalColor("WeakBullBar" , CreateColor(0, 128, 0));    # Dark GREEN
DefineGlobalColor("BearBar"     , CreateColor(255, 0, 0));    # Red
DefineGlobalColor("WeakBearBar" , CreateColor(128, 0, 0));   # DARK RED
DefineGlobalColor("NeutralBar"  , CreateColor(255, 255, 0));  # yellow

DefineGlobalColor("BGBull"      , CreateColor (153, 255, 153));
DefineGlobalColor("BGBear"      , CreateColor (255, 153, 153));
#////////////////////////////////////////////////////////////////////////////////
#mat(source, length, type) =>
script mat {
    input source = close;
    input length = 69;
    input type   = "EMA";
    def mat;
    mat =
    if type == "SMA" then SimpleMovingAvg(source, length) else
    if type == "EMA" then ExpAverage(source, length) else
    if type == "WMA" then WMA(source, length) else
    if type == "HMA" then WMA(2 * WMA(source, length / 2) - WMA(source, length), Round(Sqrt(length)))
       else Double.NaN;
    plot result = mat;
}

def ma = WMA(TrendSource, HAMALength);

#//GRADIENT AREA
def center  = ExpAverage(ma, 3);
def xUp     = ma crosses above center;
def xDn     = ma crosses below center;
def chg     = ma - ma[1];
def up      = chg > 0;
def dn      = chg < 0;
def srcBull = ma > center;
def srcBear = ma < center;

#### TREND####
def StrongUP = srcBull and up;
def WeakUp   = srcBull and dn;
def StrongDN = srcBear and dn;
def WeakDN   = srcBear and up;
def Neutral  = xUp or xDn or !StrongUP and !StrongDN and !WeakUp and !WeakDN;

def SourceClose = (open + high + low + close) / 4;
def LengthClose = CloseLength;

def SourceOpen = CompoundValue(1, (SourceOpen[1] + SourceClose[1]) / 2, SourceClose) ;
def LengthOpen = OpenLength;

def SourceHigh = Max(Max(high, SourceOpen), SourceClose);
def LengthHigh = HighLength;

def SourceLow = Min(Min(low, SourceOpen), SourceClose);
def LengthLow = LowLength;

#funcCalcMA1(type1, src1, len1) =>
script funcCalcMA1 {
    input type1 = "EMA";
    input src1  = close;
    input len1  = 0;
    def funcCalcMA1;
    funcCalcMA1 = if type1 == "SMA" then SimpleMovingAvg(src1, len1) else
                  if type1 == "EMA" then ExpAverage(src1, len1) else WMA(src1, len1);
    plot result = funcCalcMA1;
}
#funcCalcOpen(TypeOpen, SourceOpen, LengthOpen) =>
script funcCalcOpen {
    input TypeOpen   = "EMA";
    input SourceOpen = close;
    input LengthOpen = 0;
    def funcCalcOpen;
    funcCalcOpen = if TypeOpen == "SMA" then SimpleMovingAvg(SourceOpen, LengthOpen) else
                   if TypeOpen == "EMA" then ExpAverage(SourceOpen, LengthOpen) else WMA(SourceOpen, LengthOpen);
    plot result = funcCalcOpen;
}
#funcCalcHigh(TypeHigh, SourceHigh, LengthHigh) =>
script funcCalcHigh {
    input TypeHigh   = "EMA";
    input SourceHigh = close;
    input LengthHigh = 0;
    def funcCalcHigh;
    funcCalcHigh = if TypeHigh == "SMA" then SimpleMovingAvg(SourceHigh, LengthHigh) else
                   if TypeHigh == "EMA" then ExpAverage(SourceHigh, LengthHigh) else WMA(SourceHigh, LengthHigh);
    plot result = funcCalcHigh;
}
#funcCalcLow(TypeLow, SourceLow, LengthLow) =>
script funcCalcLow {
    input TypeLow   = "EMA";
    input SourceLow = close;
    input LengthLow = 0;
    def funcCalcLow;
    funcCalcLow = if TypeLow == "SMA" then SimpleMovingAvg(SourceLow, LengthLow) else
                  if TypeLow == "EMA" then ExpAverage(SourceLow, LengthLow) else WMA(SourceLow, LengthLow);
    plot result = funcCalcLow;
}
#funcCalcClose(TypeClose, SourceClose, LengthClose) =>
script funcCalcClose {
    input TypeClose   = "EMA";
    input SourceClose = close;
    input LengthClose = 0;
    def funcCalcClose;
    funcCalcClose = if TypeClose == "SMA" then SimpleMovingAvg(SourceClose, LengthClose) else
                    if TypeClose == "EMA" then ExpAverage(SourceClose, LengthClose) else WMA(SourceClose, LengthClose);
    plot result = funcCalcClose;
}

# Plot the new Chart
def CandleOpen  = funcCalcOpen(OpenType, SourceOpen, LengthOpen);
def CandleHigh  = funcCalcHigh(HighType, SourceHigh, LengthHigh);
def CandleLow   = funcCalcLow(LowType, SourceLow, LengthLow);
def CandleClose = funcCalcClose(CloseType, SourceClose, LengthClose);

def MAValue  = funcCalcMA1(HAMAType, TrendSource, HAMALength);

plot MALine = if HAMAMa then MAValue else na;
MALine.SetStyle(Curve.FIRM);
MALine.AssignValueColor( if StrongUP then GlobalColor("Bull")     else
                         if WeakUp   then GlobalColor("WeakBull") else
                         if StrongDN then GlobalColor("Bear")     else
                         if WeakDN   then GlobalColor("WeakBear") else GlobalColor("Neutral"));
MALine.SetLineWeight(1);

# Plot STRONG UP
def UpO1;
def UpH1;
def UpL1;
def UpC1;
if StrongUP and HAMABar
then {
    UpO1 = if CandleOpen < CandleClose then CandleClose else CandleOpen;
    UpH1 = if CandleHigh > CandleClose then CandleClose else CandleHigh;
    UpL1 = if CandleLow  < CandleOpen  then CandleOpen  else CandleLow;
    UpC1 = if CandleOpen < CandleClose then CandleOpen  else CandleClose;
} else
{
    UpO1 = na;
    UpH1 = na;
    UpL1 = na;
    UpC1 = na;
}
# Plot WEAK UP
def UpO;
def UpH;
def UpL;
def UpC;
if WeakUp and HAMABar
then {
    UpO = if CandleOpen < CandleClose then CandleClose else CandleOpen;
    UpH = if CandleHigh > CandleClose then CandleClose else CandleHigh;
    UpL = if CandleLow  < CandleOpen  then CandleOpen else CandleLow;
    UpC = if CandleOpen < CandleClose then CandleOpen else CandleClose;
} else
{
    UpO = na;
    UpH = na;
    UpL = na;
    UpC = na;
}
# Plot WEAK DOWN
def DnO;
def DnH;
def DnL;
def DnC;
if WeakDN and HAMABar
then {
    DnO = if CandleOpen < CandleClose then CandleClose else CandleOpen;
    DnH = if CandleHigh > CandleOpen then CandleOpen else CandleHigh;
    DnL = if CandleLow  < CandleClose then CandleClose else CandleLow;
    DnC = if CandleOpen < CandleClose then CandleOpen else CandleClose;
} else
{
    DnO = na;
    DnH = na;
    DnL = na;
    DnC = na;
}
# Plot STRONG DOWN
def DnO1;
def DnH1;
def DnL1;
def DnC1;
if StrongDN and HAMABar
then {
    DnO1 = if CandleOpen < CandleClose then CandleClose else CandleOpen;
    DnH1 = if CandleHigh > CandleOpen then CandleOpen else CandleHigh;
    DnL1 = if CandleLow  < CandleClose then CandleClose else CandleLow;
    DnC1 = if CandleOpen < CandleClose then CandleOpen else CandleClose;
} else
{
    DnO1 = na;
    DnH1 = na;
    DnL1 = na;
    DnC1 = na;
}
# Plot Neutral
def NuO;
def NuH;
def NuL;
def NuC;
if Neutral and HAMABar
then {
    NuO = if CandleOpen < CandleClose then CandleClose else CandleOpen;
    NuH = if CandleHigh > CandleOpen then CandleOpen else CandleHigh;
    NuL = if CandleLow  < CandleClose then CandleClose else CandleLow;
    NuC = if CandleOpen < CandleClose then CandleOpen else CandleClose;
} else
{
    NuO = na;
    NuH = na;
    NuL = na;
    NuC = na;
}
# Plot the new Chart
AddChart(high = UpH1, low = UpL1, open = UpO1, close = UpC1,
         type = ChartType.CANDLE, growcolor =  GlobalColor("Bull"));
AddChart(high = UpH , low = UpL , open = UpO,  close = UpC,
         type = ChartType.CANDLE, growcolor =  GlobalColor("WeakBull"));

AddChart(high = DnH1, low = DnL1, open = DnO1, close = DnC1,
         type = ChartType.CANDLE, growcolor =  GlobalColor("Bear"));
AddChart(high = DnH , low = DnL , open = DnO,  close = DnC,
         type = ChartType.CANDLE, growcolor =  GlobalColor("WeakBear"));

AddChart(high = NuH , low = NuL , open = NuO,  close = NuC,
         type = ChartType.CANDLE, growcolor =  GlobalColor("Neutral"));
########
#indicator("SSL Channel", by MissTricky)
#https://www.tradingview.com/script/6y9SkpnV-SSL-Channel/
def ma1 = mat(high,SSL_MaLength, SSLType);
def ma2 = mat(low ,SSL_MaLength, SSLType);

def Hlv1 = if (if SSLWicks then high else close) > ma1 then 1 else
           if (if SSLWicks then low  else close) < ma2 then -1 else Hlv1[1];
def Hlv = Hlv1;

def sslUp   = if Hlv < 0 then ma2 else ma1;
def sslDown = if Hlv < 0 then ma1 else ma2;

def SSLBull = Hlv1 > 0 and Hlv1[1] < 0;
def SSLBear = Hlv1 < 0 and Hlv1[1] > 0;

plot highLine = if ShowSSL then sslUp else na;
plot lowLine  = if ShowSSL then sslDown else na;

highLine.AssignValueColor(if Hlv > 0 then Color.GREEN else color.RED);
lowLine.AssignValueColor( if Hlv > 0 then Color.GREEN else color.RED);

highLine.AssignValueColor(if Hlv > 0 then Color.GREEN else Color.RED);
lowLine.AssignValueColor( if Hlv > 0 then Color.GREEN else Color.RED);

AddCloud (highLine, lowLine, Color.DARK_GREEN, Color.DARK_RED, no);

##### RSI
def RSIup   = WildersAverage(Max(close - close[1], 0), rsiLength);
def RSIdown = WildersAverage(-Min(close - close[1], 0), rsiLength);
def RSIvalue = if RSIdown == 0 then 100 else if RSIup == 0 then 0 else 100 - (100 / (1 + RSIup / RSIdown));
def RSIAvg   = SimpleMovingAvg(RSIvalue, RSIMovAvg);
def RSI = if RSIvalue > RSIAvg then  1 else
          if RSIvalue < RSIAvg then -1 else na;

##### TDFI
def mma  = ExpAverage(close * 1000, TDFIPeriod);
def smma = ExpAverage(mma, TDFIPeriod);
def impetmma  = mma - mma[1];
def impetsmma = smma - smma[1];
def divma = AbsValue(mma - smma);
def averimpet = (impetmma + impetsmma) / 2;
def tdf  = Power(divma, 1) * Power(averimpet, 3);
def TDFIvalue = tdf / Highest(AbsValue(tdf), TDFIPeriod * 3);
def TDFI = if TDFIvalue > TDFIAbove then  1 else
           if TDFIvalue < TDFIBelow then -1 else na;

###### ADX Filter
def ADXvalue = DMI(ADXLength, AverageType.WILDERS).ADX;
def ADX      = if ADXvalue >= ADXlimit then 1 else na;

###### Range Indicator
def data = TrueRange(high, close, low) / if close > close[1] then (close - close[1]) else 1;
def hData = Highest(data, RILength);
def lData = Lowest(data, RILength);
def range = 100 * (data - lData) / if hData > lData then (hData - lData) else 1;
def RIvalue = ExpAverage(range, RangeSmoothing);
def RI = if RIvalue >= Rangelimit then 1 else na;

### Signal###
def UpOpen = if CandleOpen < CandleClose then CandleClose else CandleOpen;
def UpHigh = if CandleHigh > CandleClose then CandleClose else CandleHigh;
def UpLow  = if CandleLow  < CandleOpen  then CandleOpen  else CandleLow;
def UpClose= if CandleOpen < CandleClose then CandleOpen  else CandleClose;

def DnOpen = if CandleOpen < CandleClose then CandleClose else CandleOpen;
def DnHigh = if CandleHigh > CandleOpen then CandleOpen else CandleHigh;
def DnLow  = if CandleLow  < CandleClose then CandleClose else CandleLow;
def DnClose= if CandleOpen < CandleClose then CandleOpen else CandleClose;

def HAMAHigh = close > CandleLow;
def HAMALow  = low < DnLow;

def SigUp    = if TDFIFilter then (SSLBull and close > MAValue and HAMAHigh and TDFI > 0)
                             else (SSLBull and close > MAValue and HAMAHigh);
def SigUp1   = if ADXFilter then SigUp and ADX else SigUp;
def SigUp2   = if RangeIndicatorFilter then SigUp1 and RI else SigUp1;
def SignalUp = if RSIFilter then SigUp2 and RSI > 0 else SigUp2;

def SigDN = if TDFIFilter then (SSLBear and close < MAValue and HAMALow and TDFI < 0)
                          else (SSLBear and close < MAValue and HAMALow);
def SigDn1 = if ADXFilter then SigDn and ADX else SigDn;
def SigDn2 = if RangeIndicatorFilter then SigDn1 and RI else SigDn1;
def SignalDn = if RSIFilter then SigDn2 and RSI < 0 else SigDn2;

plot Arrow_Up = if showArrow and SignalUp then low  else na;
plot Arrow_Dn = if showArrow and SignalDn then high else na;

Arrow_Up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Arrow_Up.SetDefaultColor(Color.WHITE);
Arrow_Up.SetLineWeight(3);

Arrow_Dn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Arrow_Dn.SetDefaultColor(Color.YELLOW);
Arrow_Dn.SetLineWeight(3);

##### Background & Price Color
AssignPriceColor(if ColorBar  then
                  if Neutral  then GlobalColor("NeutralBar")  else
                  if StrongUP and close < UpHigh then GlobalColor("WeakBullBar") else
                  if StrongUP and close > UpHigh then GlobalColor("BullBar")     else
                  if StrongDN and close < DnLow  then GlobalColor("BearBar")     else
                  if StrongDN and close > DnLow then GlobalColor("WeakBearBar")  else
                                                 Color.DARK_ORANGE else Color.CURRENT);

AssignBackgroundColor(if BackgroundColor then
                  if StrongUP and close > UpHigh then GlobalColor("BGBull") else
                  if StrongDN and close < DnLow  then GlobalColor("BGBear") else
                    Color.CURRENT else Color.CURRENT);

### ENd ####
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Can one of the coders on this forum show me how to create an watchlist/alert for this strat? Will be greatly appreciated. I just did some testing of this strat and I am actually excited to see it in action. Check out the 2min chart. worked really well.

@a1cturner, Would you be interested in creating or helping me create a flexgrid chart like you did for the JT strategy, to work with the HAMA Strategy above. This strategy has been working the best of all strategies I have tried so far. I am using it to scalp stocks and options. (The FlexGrid is awesome. Really better than alerts/watchlist.) I would greatly appreciate any help you may offer. I would like for the flex Grid charts to go GREEN when the price goes over the HAMA and other conditions are met as well as the chart to go RED as the Price goes below the HAMA and other conditions are met. @BenTen Maybe you could shed some light on this one.
 
Can one of the coders on this forum show me how to create an watchlist/alert for this strat? Will be greatly appreciated. I just did some testing of this strat and I am actually excited to see it in action. Check out the 2min chart. worked really well.

@METAL this script uses the unsupported AddChart() function.
The ToS platform does not support the use of the AddChart() function in scans, watchlists, or conditional orders.
 
Last edited:
@a1cturner, Would you be interested in creating or helping me create a flexgrid chart like you did for the JT strategy, to work with the HAMA Strategy above. This strategy has been working the best of all strategies I have tried so far. I am using it to scalp stocks and options. (The FlexGrid is awesome. Really better than alerts/watchlist.) I would greatly appreciate any help you may offer. I would like for the flex Grid charts to go GREEN when the price goes over the HAMA and other conditions are met as well as the chart to go RED as the Price goes below the HAMA and other conditions are met. @BenTen Maybe you could shed some light on this one.
@METAL Here is the FlexGrid you requested. http://tos.mx/WVMOq0v
 
Last edited:
@METAL this script uses the unsupported AddChart() function.
The ToS platform does not support the use of the AddChart() function in scans, watchlists, or conditional orders.
Which script has an addchart function? The HAMA one?

Which script has an addchart function? The HAMA one?
@MerryDay I found it. Darn. So there isn't any way to get some sort of signal/alert when the conditions listed above happens?
 
Last edited by a moderator:
tried to copy the strategy as seen on YouTube. You may paper trade it or you can use HAMA candles as indicator.

@samer800 ,
Just wanted to let you know that this strategy is crazy good. I have so much confidence when using it. I have profited every single trade with the exception of 1 and that was all my fault. I was using an OCO order and made a mistake and used the wrong one which was a trailing stop I created and it was too close. I was in an option trade and I lost only $35.00. I would have profited that trade if I didn't make a mistake. Thanks again for sharing this. I believe you created this script based off of the video. If so, Do you know if there is any way to create any type of alert, scan. or something to help locate the stocks at optimal times? I will do my best to come up with something. I am not a coder so I will be digging deep into this. I will let you know if I am able to come up with something. @MerryDay informed me that the AddChart() script will not allow an watchlist or scan but I am hoping there is a work around. Any of you coders out there have any suggestions or ideas, please help.
 
@samer800 ,
Just wanted to let you know that this strategy is crazy good. I have so much confidence when using it. I have profited every single trade with the exception of 1 and that was all my fault. I was using an OCO order and made a mistake and used the wrong one which was a trailing stop I created and it was too close. I was in an option trade and I lost only $35.00. I would have profited that trade if I didn't make a mistake. Thanks again for sharing this. I believe you created this script based off of the video. If so, Do you know if there is any way to create any type of alert, scan. or something to help locate the stocks at optimal times? I will do my best to come up with something. I am not a coder so I will be digging deep into this. I will let you know if I am able to come up with something. @MerryDay informed me that the AddChart() script will not allow an watchlist or scan but I am hoping there is a work around. Any of you coders out there have any suggestions or ideas, please help.
happy to hear that you are benefit from it. I am not a coder nor trader, i just learning. will try to find a work around to do the scan if possible
 
@samer800 ,
Just wanted to let you know that this strategy is crazy good. I have so much confidence when using it. I have profited every single trade with the exception of 1 and that was all my fault. I was using an OCO order and made a mistake and used the wrong one which was a trailing stop I created and it was too close. I was in an option trade and I lost only $35.00. I would have profited that trade if I didn't make a mistake. Thanks again for sharing this. I believe you created this script based off of the video. If so, Do you know if there is any way to create any type of alert, scan. or something to help locate the stocks at optimal times? I will do my best to come up with something. I am not a coder so I will be digging deep into this. I will let you know if I am able to come up with something. @MerryDay informed me that the AddChart() script will not allow an watchlist or scan but I am hoping there is a work around. Any of you coders out there have any suggestions or ideas, please help.
Hi, do you have the studies/strategy for this strategy for TOS??? Thanks and would love to try them out please.
 
This looks good I used a momentum keltner chanel with heikeneshi smoth and looks good . A code combining everything will be great . Can someone good in programing do it do it thanks

UPDATE:
use the hybrid ssi is better. is on this site
 
Last edited by a moderator:
This looks good I used a momentum keltner chanel with heikeneshi smoth and looks good . A code combining everything will be great . Can someone good in programing do it do it thanks
Yeah. This is the best scalping strat I have used. I am really new at this so there may be others that are way better but this one seems to be a homerun. The only downside is catching the cross at a reasonable time and that is why I was wandering if any alert/scan or something could be implemented.
 
This really is an incredible study. I'm currently using it on a 2000 and 987 Tick chart with tremendous results. The only area I'm struggling with is when do you take a reversal?

1.) I've tried when my candles break out of the SSL (Thick Bands that switch from Green to Red) with limited success

2.) I've tried when the SSL (using the NNFX version) clears the NSDT SSL...that usually doesn't work

The only other thing I can think of is when the HAMA candles clear the SSL. If I've missed this in the videos regarding this indicator or if anyone has any advice I'd appreciate it
 
use the hybrid ssi is better. is on this site
Okay. Will give it a try.
This really is an incredible study. I'm currently using it on a 2000 and 987 Tick chart with tremendous results. The only area I'm struggling with is when do you take a reversal?

1.) I've tried when my candles break out of the SSL (Thick Bands that switch from Green to Red) with limited success

2.) I've tried when the SSL (using the NNFX version) clears the NSDT SSL...that usually doesn't work

The only other thing I can think of is when the HAMA candles clear the SSL. If I've missed this in the videos regarding this indicator or if anyone has any advice I'd appreciate it
Rich, So far I have just been taking profit where I feel like it. I have been testing lower indicators to help me get out at the best time. I also run a 1 min chart with a ssl indicator which triggers really fast. I use that to give me an idea when to exit. It has given false signals before and I would have profited more but was happy getting the profit. My biggest issue is getting in on time as I have to keep searching stock after stock to see if one meets the criteria.
 
Last edited by a moderator:
Okay. Will give it a try.

Rich, So far I have just been taking profit where I feel like it. I have been testing lower indicators to help me get out at the best time. I also run a 1 min chart with a ssl indicator which triggers really fast. I use that to give me an idea when to exit. It has given false signals before and I would have profited more but was happy getting the profit. My biggest issue is getting in on time as I have to keep searching stock after stock to see if one meets the criteria. That is why I was hoping one of the coder would be able to help.
Here is the SSL I use. I set period to 13 and length to 7.

# Blue Magik SSL
# I assume this is based on the popular SSL indicator
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/i85H2tZ8-blue-magik/

input period = 10;
input len = 10;

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));
 
@a1cturner If it isn't too much to explain, What code make the chart go solid color. I also want to make one for a simple ADX indicator. I want it to also change from green to red depending on if the ADX is above or below the 20. I was trying to write the code but failed miserably.
assignbackgroundcolor(if "ADX > 20" then color.green else if "ADX < 20" then color.red else color.current);

Obviously substitute the quoted sections with the actual criteria you need to be met.

I also add an input like:
input backgroundcolor = no;

I then add that to my code so I can turn it off on settings on my main chart.

assignbackgroundcolor(if backgroundcolor and "ADX > 20" then color.green else if backgroundcolor and "ADX < 20" then color.red else color.current);
 


This trading indicator is great. Thank you very much. In addition to adding adx code, this revised code's input parameters differ from the initial code posted on July 11 2022 when you started this thread, in my observation. I was just curious if there was a purpose for changing the input settings and if the modified code had a higher win rate than the previous one?. As far as I can tell, the older code is more in line with the Trading View code (https://www.tradingview.com/script/k7nrF2oI-NSDT-HAMA-Candles) than the more recent code. Thank you


original code


input TrendLength = 55;
input TrendType = {default WMA, SMA, EMA, HMA};

script mat {
input source = close;
input length = 0;
input type = "WMA";
def mat;
mat =
if type == "SMA" then SimpleMovingAvg(source, length) else
if type == "EMA" then ExpAverage(source, length) else
if type == "WMA" then WMA(source, length) else
if type == "HMA" then WMA(2 * WMA(source, length / 2) - WMA(source, length), Round(Sqrt(length)))
else Double.nan;
plot result = mat;
}



Revised code


input HAMALength = 69;
input HAMAType = {WMA, SMA,default EMA, HMA};

script mat {
input source = close;
input length = 69;
input type = "EMA";
def mat;
mat =
if type == "SMA" then SimpleMovingAvg(source, length) else
if type == "EMA" then ExpAverage(source, length) else
if type == "WMA" then WMA(source, length) else
if type == "HMA" then WMA(2 * WMA(source, length / 2) - WMA(source, length), Round(Sqrt(length)))
else Double.nan;
plot result = mat;
}
 
@METAL Are you trading with custom settings on the flex grid or the strategy or running exactly how it is posted? I am wanting to test this on futures so i have changed the ticks on the flex grid

Also, I see the arrows and sorry for the noob question but is there any way to have an alarm when an arrow appears? Sorry, not a coder yet
 
assignbackgroundcolor(if "ADX > 20" then color.green else if "ADX < 20" then color.red else color.current);

Obviously substitute the quoted sections with the actual criteria you need to be met.

I also add an input like:
input backgroundcolor = no;

I then add that to my code so I can turn it off on settings on my main chart.

assignbackgroundcolor(if backgroundcolor and "ADX > 20" then color.green else if backgroundcolor and "ADX < 20" then color.red else color.current);
@a1cturner I tried using this FlexGrid and it doesn't color. Is there something I need to do to get it to color Red/Green depending on the conditions met. I was hoping to get it to work like your other FlexGrid (Which is awesome BTW). It just makes the search much easier.
 
Thread starter Similar threads Forum Replies Date
C Confirmation Candles Indicator For ThinkorSwim Strategies & Chart Setups 2602

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
435 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top