#### YungTraderFromMontana

##### Active member

**Warning**: this indicator/strategy will repaint. Do not use unless you know what you’re doing.

Here is what appears to be a fantastic strategy using a Heiken ashi mtf study.

Right now it seems very solid using an aggregation period of 5 min on the 1 min chart, I'd love to see more good combonations.

**Photos**

**Heiken strategy alone**

Code:

```
input compBarsTTM = 6;
input paintBarsTTM = Yes;
plot TrendUp = Double.NaN;
plot TrendDown = Double.NaN;
# Inputs:
input AA = .1;
# Vars:
def CC;
def zeroLine = 0;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;
CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];
def EMA_Signal = EMA – AA * RE8;
plot FREMA_LED = if !IsNaN(close) then 1 else Double.NaN;
FREMA_LED.SetPaintingStrategy(PaintingStrategy.POINTS);
FREMA_LED.DefineColor("OverZero", Color.GREEN);
FREMA_LED.DefineColor("Normal", GetColor(7));
FREMA_LED.DefineColor("UnderZero", Color.RED);
FREMA_LED.AssignValueColor(if EMA_Signal > zeroLine then FREMA_LED.Color("OverZero") else if EMA_Signal < zeroLine then FREMA_LED.Color("UnderZero") else FREMA_LED.Color("Normal"));
FREMA_LED.SetLineWeight(5);
FREMA_LED.HideBubble();
FREMA_LED.HideTitle();
declare hide_on_daily;
input Mult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input paintbars = yes;
def x = close;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (Mult * ATR);
def DN = HL2 + (-Mult * ATR);
def AG = if x < AG[1] then UP else DN;
input compBars = 6;
plot algotrend = AG;
declare hide_on_daily;
algotrend.AssignValueColor(if x < AG then Color.RED else Color.GREEN);
AssignPriceColor(if paintbars and x < AG
then Color.RED
else if paintbars and x > AG
then Color.GREEN
else Color.CURRENT);
#backtesting
def STUP = (x > AG);
def STDN = (x < AG);
plot STUPl = if AG crosses below close then 1 else 0;
plot STDNl = if AG crosses above close then 1 else 0;
def FRUP =(EMA_Signal > zeroLine);
def FRDN =(EMA_Signal < zeroLine);
plot Combo_LED = if !IsNaN(close) then 1 else Double.NaN;
Combo_LED.SetPaintingStrategy(PaintingStrategy.POINTS);
Combo_LED.DefineColor("OverZero", Color.GREEN);
Combo_LED.DefineColor("Normal", GetColor(7)); Combo_LED.DefineColor("UnderZero", Color.RED);
Combo_LED.AssignValueColor(if(STUP is true and FRUP is true and Trendup is true) then Combo_LED.Color("OverZero") else if (STDN is true and FRDN is true and Trenddown is true) then Combo_LED.Color("UnderZero") else Combo_LED.Color("Normal"));
Combo_LED.SetLineWeight(5);
Combo_LED.HideBubble();
Combo_LED.HideTitle();
def v1 = (STUP is true and FRUP is true and Trendup is true) ;
def v3 = (STDN is true and FRDN is true and Trenddown is true);
def va2 = ((STUP is true or FrUP is true) and Trendup is true);
def vb2 = ((STUP is true or Trendup is true) and FRUP is true);
def vc2 = (va2 or vb2 is true);
def va4 = ((STDN is true or FrDN is true) and Trenddown is true);
def vb4 = ((STDN is true or Trenddown is true) and FrDn is true);
def vc4 = (va4 or vb4 is true);
# Bullish Orders
AddOrder(OrderType.BUY_TO_OPEN, condition = v1, price = close, 3000, tickcolor = Color.GREEN, arrowcolor = Color.GREEN);
AddOrder(OrderType.SELL_TO_CLOSE, condition = v3, price = open, 3000, tickcolor = Color.RED, arrowcolor = Color.RED);
# Bearish Orders
AddOrder(OrderType.SELL_TO_OPEN, condition = v3, price = open, 3000, tickcolor = Color.RED, arrowcolor = Color.RED);
AddOrder(OrderType.BUY_TO_CLOSE, condition = v1, price = close, 3000, tickcolor = Color.GREEN, arrowcolor = Color.GREEN);
```

**Heiken strategy with all of Diazlaz's combo paintbar options**

Code:

```
#Strategy using @Diazlaz combo paintbars study.
declare upper;
#INPUTS
input showLabels = yes;
input PaintBars = yes;
input aggregationPeriod = AggregationPeriod.FIVE_MIN;
input threshold = 1;
input enableHA = yes;
input enableHAMTF = yes;
input displace = 0;
#CORE
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Neutral", Color.MAGENTA); #Color.YELLOW
DefineGlobalColor("Off", Color.DARK_GRAY);
DefineGlobalColor("On", Color.GREEN);
DefineGlobalColor("Sync1", Color.YELLOW);
DefineGlobalColor("Sync2", Color.CYAN);
DefineGlobalColor("Up", Color.GREEN);
DefineGlobalColor("Down", Color.RED);
DefineGlobalColor("NUp", Color.DARK_GREEN);
DefineGlobalColor("NDown", Color.DARK_RED);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Neutral2", Color.PLUM);
def h = high;
def l = low;
def o = open;
def c = close;
def h1 = high(period = aggregationPeriod);
def l1 = low(period = aggregationPeriod);
def o1 = open(period = aggregationPeriod);
def c1 = close(period = aggregationPeriod);
def na = Double.NaN;
AddLabel(showLabels, "A trend, momentum and cycle Trading System v2.0", Color.CYAN);
#HeikinAshiCandles
def HA1open;
def HA1high;
def HA1low;
def HA1close;
HA1open = CompoundValue(1, (HA1open[1] + HA1close[1]) / 2, (o[1] + c[1]) / 2);
HA1high = Max(Max(h, HA1open), HA1close[1]);
HA1low = Min(Min(l, HA1open), HA1close[1]);
HA1close = (o + h + l + c) / 4;
def sHA1 = if HA1close > HA1open then 100 else -100;
def sBullish_HA1 = if(enableHA and sHA1 == 100,1,0);
def sBearish_HA1 = enableHA and sHA1 == -100;
AddLabel(showlabels and enableHA, "HA", if IsNan(sHA1) then COLOR.DARK_GRAY else
if sHA1[-displace] > 0 then COLOR.GREEN else
if sHA1[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));
#HeikinAshiCandles MTF
def HA2open;
def HA2high;
def HA2low;
def HA2close;
HA2open = CompoundValue(1, (HA2open[1] + HA2close[1]) / 2, (o1[1] + c1[1]) / 2);
HA2high = Max(Max(h1, HA2open), HA2close[1]);
HA2low = Min(Min(l1, HA2open), HA2close[1]);
HA2close = (o1 + h1 + l1 + c1) / 4;
def sHA2 = if HA2close > HA2open then 100 else -100;
def sBullish_HA2 = if(enableHAMTF and sHA2 == 100,1,0);
def sBearish_HA2 = enableHAMTF and sHA2 == -100;
AddLabel(showlabels and enableHAMTF, "HAMTF", if IsNan(sHA2) then COLOR.DARK_GRAY else
if sHA2[-displace] > 0 then COLOR.GREEN else
if sHA2[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));
#STATE
def sResults = sHA1 + sHA2;
def sBullish = sBullish_HA1 + sBullish_HA2;
def sBearish = sBearish_HA1 + sBearish_HA2 ;
def bullish = if(sBullish >= threshold,1,0);
def bearish = if(sBearish >= threshold,1,0);
def sState = if bullish then 100 else if bearish then -100 else 0;
def sState2 = if sState != 0 then sState else sState2[1];
#COLORBARS
AssignPriceColor(
if PaintBars then
if bullish then COLOR.GREEN else if bearish then COLOR.RED
else
COLOR.GRAY
else COLOR.CURRENT);
AddLabel(showlabels,
if bullish[-displace] then "LONG" else
if bearish[-displace] then "SHORT"
else "HOLD",
if IsNan(c) then COLOR.DARK_GRAY else
if bullish[-displace] then COLOR.GREEN else
if bearish[-displace] then COLOR.RED
else COLOR.GRAY);
#STRATEGY
def SS = if bullish then 100 else if bearish then -100 else 0;
def sBuy = SS crosses above 0;
def sSell = SS crosses below 0;
AddOrder(OrderType.BUY_AUTO, condition = Sbuy
, price = open[-1], 100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BE");
AddOrder(OrderType.SELL_AUTO, condition = sSell
, price = open[-1], 100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SE");
#END OF trend, a momentum and a cycle based indicator for ThinkorSwim V2.0
```

In the thread "Request combining 3 indicators into 1", @HighBredCloud suggested adding this into @diazlaz's combo paintbars indicator. Messing around with that indicator I found it to be very powerful on its own.

I'm posting this hoping to get community feedback on how to best utilize this strategy and to look for improvements, I'll be testing this myself. Thanks all.

Last edited by a moderator: