RedK SmoothAndLazyMA For ThinkOrSwim

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

Great post. thank you. I saw in the image another RedK indicator so I looked on Tradingview - do you know if this has been translated to TOS - https://www.tradingview.com/script/JWdrXD3I-RedK-Smooth-And-Lazy-Moving-Average-SALMA/
Here its a conversion to TOS of the RedK SmoothAndLazyMA or RedK SALMA, Enjoy! I work 98% of the time in Daily but 5 min chart is nice too!

Photo
13580[/ATTACH]']
9lUMYAR.png

13582[/ATTACH]']
PmsyVTR.png


TOS Script
Code:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA = wma(wma(cprice, length), smooth);
REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;  
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);
 

Attachments

  • 9lUMYAR.png
    9lUMYAR.png
    201.5 KB · Views: 116
  • PmsyVTR.png
    PmsyVTR.png
    180.8 KB · Views: 120
Here its a conversion to TOS of the RedK SmoothAndLazyMA or RedK SALMA, Enjoy! I work 98% of the time in Daily but 5 min chart is nice too!

Photo
13584[/ATTACH]']
9lUMYAR.png

13586[/ATTACH]']
PmsyVTR.png


TOS Script
Code:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA = wma(wma(cprice, length), smooth);
REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);
I check that this moving average has time delay compared with Hull moving average. Could you we add Hull moving average to your code by changing input matype = {default SMA, EMA, WMA, HULL}; ?
 

Attachments

  • PmsyVTR.png
    PmsyVTR.png
    180.8 KB · Views: 104
  • 9lUMYAR.png
    9lUMYAR.png
    201.5 KB · Views: 106
I check that this moving average has time delay compared with Hull moving average. Could you we add Hull moving average to your code by changing input matype = {default SMA, EMA, WMA, HULL}; ?
Try this version here, I delete the first replay because I prefer to give you the 2 options in 1 indicator so you decide wish to use better

new script
Code:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA, HMA};
input maConfig = {default WMAD, WMAHull};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA;
switch (maConfig) {
    case WMAD:
        REMA = WMA(WMA(cprice, length), smooth);
    case WMAHull:
        REMA = WMA(HullMovingAvg(cprice, length), smooth);
}

REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;  
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
    case HMA:
        type = HullMovingAvg(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);
 
Do you recommend using this with extended hours on or off?
I do not normally mention ways or methods on things that I haven't used or tested while I'm trading. The only I can say is that I saw that in 5 mins it could give you good runs and same for daily candle, especially for Daily in my opinion!
 
I do not normally mention ways or methods on things that I haven't used or tested while I'm trading. The only I can say is that I saw that in 5 mins it could give you good runs and same for daily candle, especially for Daily in my opinion!
Thanks! Could you share your strategy for using this? Buy green, sell red? What does the blue line indicate? Do you tend to use some types more than others? ex; SMA, HULL, etc?
 
Last edited:
Thanks! Could you share your strategy for using this? Buy green, sell red? What does the blue line indicate? Do you tend to use some types more than others? ex; SMA, HULL, etc?
Here a little description by the author!

Here's a quick and simple script that produces yet another Smooth and Lazy Moving Average - SALMA - that helps hide noise caused by extreme price fluctuations to enable better trend visualization and tracking

Concept:
SALMA is based on a simple concept - we calculate a standard deviation channel of a user-selected width - then correct the price value so that it is restricted within the boundaries of the SD channel - effectively adjusting against high-volatility, sudden price moves - which acts as a pre-smoothing of the price values - then we calculate our moving average and apply extra smoothing as needed.

Since only "persistent" price moves will have an effect on the direction of this MA, it will be suitable to use as an additional trend guide with other indicators, and to consider only long positions when the price is above the SALMA, and short positions only when the price is below

Notes:
SALMA can be used with any timeframe. can also be set to a higher timeframe against a lower timeframe chart
 
Try this version here, I delete the first replay because I prefer to give you the 2 options in 1 indicator so you decide wish to use better

new script
Code:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA, HMA};
input maConfig = {default WMAD, WMAHull};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA;
switch (maConfig) {
    case WMAD:
        REMA = WMA(WMA(cprice, length), smooth);
    case WMAHull:
        REMA = WMA(HullMovingAvg(cprice, length), smooth);
}

REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
    case HMA:
        type = HullMovingAvg(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);
Great job. It is much better without time delay when Hull moving average is chosen.
 
Thank you for this. I find it very useful with the current market. Is there anyway to scan for when the REMA line turn from green to red, or vice versa? If not, what about scan for when REMA is true for red (or green)?
 
Here its a conversion to TOS of the RedK SmoothAndLazyMA or RedK SALMA, Enjoy! I work 98% of the time in Daily but 5 min chart is nice too!

Photo
13980[/ATTACH]']
9lUMYAR.png

13982[/ATTACH]']
PmsyVTR.png


TOS Script
Code:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA = wma(wma(cprice, length), smooth);
REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type; 
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);
Great Job!! a quick question, can someone here add candles color with this indicator? like paint the bars with the trend, meaning if the indicador is green paint the bar green and viceversa.. thank you very much or add a arrow for the signals.
 

Attachments

  • 9lUMYAR.png
    9lUMYAR.png
    201.5 KB · Views: 105
  • PmsyVTR.png
    PmsyVTR.png
    180.8 KB · Views: 106
Ruby:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA
# Mobius
# SuperTrend HeikenAshi
input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA, HMA};
input maConfig = {default WMAD, WMAHull};

def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA;
switch (maConfig) {
    case WMAD:
        REMA = WMA(WMA(cprice, length), smooth);
    case WMAHull:
        REMA = WMA(HullMovingAvg(cprice, length), smooth);
}

REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type; 
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
    case HMA:
        type = HullMovingAvg(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);

input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input BubbleOn = no;
input ShowLabel = no;
input AlertOn = no;
input PlotLine = no;

def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close) / 2);
HAhigh = Max(high, close[1]);
HAlow = Min(low, close[1]);
haclose = (HAopen + HAclose[1] + HAlow + close) / 4;
def v = volume;
def bar = barNumber();
def EOD = if SecondsTillTime(1545) == 0 and
             SecondsFromTime(1545) == 0
          then 1
          else 0;
def NotActive = if SecondsFromTime(1545) > 0
                then 1
                else 0;
def ATR = MovingAverage(AvgType, TrueRange(HAhigh, HAclose, HAlow), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1]
         then Round(UP / tickSize(), 0) * tickSize()
         else Round(DN / tickSize(), 0) * tickSize();
plot SuperTrend = ST;
SuperTrend.SetHiding(!PlotLine);
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrend.SetPaintingStrategy(PaintingStrategy.Line);
AssignPriceColor(if PaintBars and close < ST
                 then Color.RED
                 else if PaintBars and close > ST
                      then Color.GREEN
                      else Color.CURRENT);
plot ST_point = if isNaN(close[-1])
                then ST
                else double.nan;
ST_point.SetStyle(Curve.Points);
ST_point.SetLineWeight(3);
ST_point.SetDefaultColor(Color.Yellow);
# End Code SuperTrend HeikenAshi
 



Ruby:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA
#Impulse modified to use RMO Short Term and Long Term in confluence
#ImpulseRMOLST by Tradebyday
#https://usethinkscript.com/threads/trend-magic-indicator-for-thinkorswim.282/

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA, HMA};
input maConfig = {default WMAD, WMAHull};
input length_a = 2;
input rmoLength = 81;
input swingTrdLen = 30;
input showRMO = no;
def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA;
switch (maConfig) {
    case WMAD:
        REMA = WMA(WMA(cprice, length), smooth);
    case WMAHull:
        REMA = WMA(HullMovingAvg(cprice, length), smooth);
}

REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
    case HMA:
        type = HullMovingAvg(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);


def agg = getAggregationPeriod();

def c = close(period = agg);

def h = high(period = agg);

def l = low(period = agg);

def pricedata = hl2(period = agg);

DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));

DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));

input lengthCCI = 50;

input lengthATR = 5;

input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;

def price = c + l + h;

def linDev = LinDev(price, lengthCCI);

def CCI = if linDev == 0

then 0

else (price - Average(price, lengthCCI)) / linDev / 0.015;

def MT1 = if CCI > 0

then Max(MT1[1], pricedata - ATRcci)

else Min(MT1[1], pricedata + ATRcci);

plot data = MT1;

data.AssignValueColor(if c < MT1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

def mva01 = MovingAverage( AverageType.SIMPLE, close, length_a );
def mva02 = MovingAverage( AverageType.SIMPLE, mva01, length_a );
def mva03 = MovingAverage( AverageType.SIMPLE, mva02, length_a );
def mva04 = MovingAverage( AverageType.SIMPLE, mva03, length_a );
def mva05 = MovingAverage( AverageType.SIMPLE, mva04, length_a );
def mva06 = MovingAverage( AverageType.SIMPLE, mva05, length_a );
def mva07 = MovingAverage( AverageType.SIMPLE, mva06, length_a );
def mva08 = MovingAverage( AverageType.SIMPLE, mva07, length_a );
def mva09 = MovingAverage( AverageType.SIMPLE, mva08, length_a );
def mva10 = MovingAverage( AverageType.SIMPLE, mva09, length_a );

def RMO = ( close - ( ( mva01 + mva02 + mva03 + mva04 + mva05 + mva06 + mva07 + mva08 + mva09 + mva10 ) / 10 ) ) / ( Highest( close, 10 ) - Lowest( close, 10 ) );

def Swingtrade = MovingAverage( AverageType.EXPONENTIAL, RMO, rmoLength );
def SwingTrd2 = MovingAverage( AverageType.EXPONENTIAL, RMO, swingTrdLen );
def SwingTrd3 = MovingAverage( AverageType.EXPONENTIAL, SwingTrd2, swingTrdLen );
def ZeroLine = 0;

def buy = if SwingTrd2 crosses above SwingTrd3 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else if SwingTrd3 crosses above 0 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else if SwingTrd2 crosses above 0 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else Double.NaN;

def sell = if SwingTrd2 crosses below SwingTrd3 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else if SwingTrd3 crosses below 0 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else if SwingTrd2 crosses below 0 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else Double.NaN;

def RMO2 = 100 * (close - ((Average(close, 2) +

Average(Average(close, 2), 2) +

Average(Average(Average(close, 2), 2), 2) +

Average(Average(Average(Average(close, 2), 2), 2), 2) +

Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2), 2), 2)) / 10)) /

(Highest(close, 10) - Lowest(close, 10));

def swingtrade4 = ExpAverage(RMO, 81);

def GreenPrice = Swingtrd2 > 0 and swingtrade4 > 0;
def RedPrice = Swingtrd2 < 0 and swingtrade4 < 0;

plot Bullish = GreenPrice;
plot Neutral = !GreenPrice and !RedPrice;
plot Bearish = RedPrice;

Bullish.SetDefaultColor(Color.UPTICK);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bullish.SetLineWeight(3);
Bullish.Hide();
Neutral.SetDefaultColor(Color.BLUE);
Neutral.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Neutral.SetLineWeight(3);
Neutral.Hide();
Bearish.SetDefaultColor(Color.DOWNTICK);
Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bearish.SetLineWeight(3);
Bearish.Hide();

DefineGlobalColor("Bullish", Color.UPTICK);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Bearish", Color.DOWNTICK);
AssignPriceColor(if GreenPrice then GlobalColor("Bullish") else if RedPrice then GlobalColor("Bearish") else GlobalColor("Neutral"));
 



Ruby:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# RedKTrader v5
# RedK SmoothAndLazyMA - SALMA v2.0 converted to TOS by mbarcala
# Corrects price points within specific StdDev band before calculting a smoothed WMA
#Impulse modified to use RMO Short Term and Long Term in confluence
#ImpulseRMOLST by Tradebyday
#https://usethinkscript.com/threads/trend-magic-indicator-for-thinkorswim.282/

input length = 20;
input smooth = 5;
input mult = 0.3;
input sd_len = 1;
input matype = {default SMA, EMA, WMA, HMA};
input maConfig = {default WMAD, WMAHull};
input length_a = 2;
input rmoLength = 81;
input swingTrdLen = 30;
input showRMO = no;
def baseline = wma(close, sd_len);
def dev = mult * StDev(close, sd_len);
def upper = baseline + dev;
def lower = baseline - dev;
def cprice = if close > upper then upper else if close < lower then lower else close;

plot REMA;
switch (maConfig) {
    case WMAD:
        REMA = WMA(WMA(cprice, length), smooth);
    case WMAHull:
        REMA = WMA(HullMovingAvg(cprice, length), smooth);
}

REMA.AssignValueColor(if REMA > REMA[1] then Color.GREEN else Color.RED);
REMA.SetLineWeight(2);

plot type;
switch (matype) {
    case SMA:
        type = SimpleMovingAvg(close, length);
    case EMA:
        type = ExpAverage(close, length);
    case WMA:
        type = wma(close, length);
    case HMA:
        type = HullMovingAvg(close, length);
}
type.SetDefaultColor(Color.BLUE);
type.SetLineWeight(2);


def agg = getAggregationPeriod();

def c = close(period = agg);

def h = high(period = agg);

def l = low(period = agg);

def pricedata = hl2(period = agg);

DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));

DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));

input lengthCCI = 50;

input lengthATR = 5;

input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;

def price = c + l + h;

def linDev = LinDev(price, lengthCCI);

def CCI = if linDev == 0

then 0

else (price - Average(price, lengthCCI)) / linDev / 0.015;

def MT1 = if CCI > 0

then Max(MT1[1], pricedata - ATRcci)

else Min(MT1[1], pricedata + ATRcci);

plot data = MT1;

data.AssignValueColor(if c < MT1 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

def mva01 = MovingAverage( AverageType.SIMPLE, close, length_a );
def mva02 = MovingAverage( AverageType.SIMPLE, mva01, length_a );
def mva03 = MovingAverage( AverageType.SIMPLE, mva02, length_a );
def mva04 = MovingAverage( AverageType.SIMPLE, mva03, length_a );
def mva05 = MovingAverage( AverageType.SIMPLE, mva04, length_a );
def mva06 = MovingAverage( AverageType.SIMPLE, mva05, length_a );
def mva07 = MovingAverage( AverageType.SIMPLE, mva06, length_a );
def mva08 = MovingAverage( AverageType.SIMPLE, mva07, length_a );
def mva09 = MovingAverage( AverageType.SIMPLE, mva08, length_a );
def mva10 = MovingAverage( AverageType.SIMPLE, mva09, length_a );

def RMO = ( close - ( ( mva01 + mva02 + mva03 + mva04 + mva05 + mva06 + mva07 + mva08 + mva09 + mva10 ) / 10 ) ) / ( Highest( close, 10 ) - Lowest( close, 10 ) );

def Swingtrade = MovingAverage( AverageType.EXPONENTIAL, RMO, rmoLength );
def SwingTrd2 = MovingAverage( AverageType.EXPONENTIAL, RMO, swingTrdLen );
def SwingTrd3 = MovingAverage( AverageType.EXPONENTIAL, SwingTrd2, swingTrdLen );
def ZeroLine = 0;

def buy = if SwingTrd2 crosses above SwingTrd3 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else if SwingTrd3 crosses above 0 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else if SwingTrd2 crosses above 0 and SwingTrd3[0] > SwingTrd3[1] and SwingTrd3 > 0 then 1
else Double.NaN;

def sell = if SwingTrd2 crosses below SwingTrd3 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else if SwingTrd3 crosses below 0 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else if SwingTrd2 crosses below 0 and Swingtrade < 0 and Swingtrade[0] < Swingtrade[1] and low[0] < low[1] then 1
else Double.NaN;

def RMO2 = 100 * (close - ((Average(close, 2) +

Average(Average(close, 2), 2) +

Average(Average(Average(close, 2), 2), 2) +

Average(Average(Average(Average(close, 2), 2), 2), 2) +

Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2), 2) +

Average(Average(Average(Average(Average(Average(Average(Average(Average(Average(close, 2), 2), 2), 2), 2), 2), 2), 2), 2), 2)) / 10)) /

(Highest(close, 10) - Lowest(close, 10));

def swingtrade4 = ExpAverage(RMO, 81);

def GreenPrice = Swingtrd2 > 0 and swingtrade4 > 0;
def RedPrice = Swingtrd2 < 0 and swingtrade4 < 0;

plot Bullish = GreenPrice;
plot Neutral = !GreenPrice and !RedPrice;
plot Bearish = RedPrice;

Bullish.SetDefaultColor(Color.UPTICK);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bullish.SetLineWeight(3);
Bullish.Hide();
Neutral.SetDefaultColor(Color.BLUE);
Neutral.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Neutral.SetLineWeight(3);
Neutral.Hide();
Bearish.SetDefaultColor(Color.DOWNTICK);
Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bearish.SetLineWeight(3);
Bearish.Hide();

DefineGlobalColor("Bullish", Color.UPTICK);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Bearish", Color.DOWNTICK);
AssignPriceColor(if GreenPrice then GlobalColor("Bullish") else if RedPrice then GlobalColor("Bearish") else GlobalColor("Neutral"));
@petergluis thank you very much for you help with this amazing indicator, very interesting the changes you have made.. i have one more question, i think the moving average changing color is the REMA i think, can you use that one to assign the bar colors, example when the REMA changes to green for bullish then the bar will be green colors and viceversa, i think will be better then the assign the bar color with the Super Trend, thank you very much in advance.
 
@petergluis thank you very much for you help with this amazing indicator, very interesting the changes you have made.. i have one more question, i think the moving average changing color is the REMA i think, can you use that one to assign the bar colors, example when the REMA changes to green for bullish then the bar will be green colors and viceversa, i think will be better then the assign the bar color with the Super Trend, thank you very much in advance.
It will take a lot of time to do that. Someone else may help you fulfil your requirement.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
553 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