YungTrader's Ultimate Indicator

  • Thread starter YungTraderFromMontana
  • Start date
YungTraderFromMontana

YungTraderFromMontana

Well-known member
I cooked this up recently combining some of the best indicators I've used in the past year. It includes a truedepth study and a support and resistance study; both of which I've already studied plenty and become familiar with. I just had the time this week to look through all of the scripts I've used as well as made and combine some of the signals that I had come up with. It looks for daily breakouts while minimizing false signals and makes scanning for meaningful breakouts easier. Before making this I'd have to manually look through a bunch of stocks to find ones that this can scan for. That being said I made some of the criteria on the study lenient so nothing slips through the cracks of the scanner, this means it will require limited intuition by the user to select the best signals of the bunch.

I had this mostly completed last night and I was able to take positions in MRNA, ATVI, VIPS DOCU, and JD in yesterdays premarket. All but one of those were winners. Still holding all except docu the loser of the day.

Here are some screenshots of the indicator and I'll break it down.

MRNA lower truedepth daily



MRNA higher truedepth daily



AMZN lower truedepth daily



AMZN higher truedepth daily



On the chart in the pictures it shows the truedepth in grey and the support and resistance in purple and yellow. The arrow plots in the picture represent breaks of a support or resistance that haven't been touched in the inputted amount of time of the truedepth. If you're looking for ath or atl breakouts then use a higher truedepth. If you want arrows even if the stock is ranged then use a lower truedepth input. You have the ability to change the truedepth or lookback. The truedepth controls as discussed, the lookback will control how many candles back the study will look for support and resistance. If you're looking to play around with these go for it.

For anyone who doesn't understand at all what I just said this study is simply a way to scan and identify important support/resistance breakouts.

One last thing I'll add is that you can use it on any timeframe but be warned I didn't design it for other timeframes.


Here is a chart link:
https://tos.mx/FflYFoi

Here is the code
Code:
declare upper;

input LookbackPeriod = 8;
input TimeFrame2 = {"15 MIN", "1 MIN", "2 MIN", "3 MIN", "4 MIN", "5 MIN", "10 MIN", "20 MIN", "30 MIN", "1 HOUR", "2 HOURS", "4 HOURS", DAY, "2 DAYS", "3 DAYS", "4 DAYS", default WEEK, MONTH, "OPT EXP"};
input TimeFrame3 = {"30 MIN", "1 MIN", "2 MIN", "3 MIN", "4 MIN", "5 MIN", "10 MIN", "15 MIN", "20 MIN", "1 HOUR", "2 HOURS", "4 HOURS", DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, default MONTH, "OPT EXP"};
input HideSwings = no;
input HideCurrentTF = no;
input HideTimeFrame2 = no;
input HideTimeFrame3 = no;

def SwingsLagBar = 1;
def BuyEntry = 3;
def SellEntry = 3;

def QB = Highest(high, BuyEntry);
def QS = Lowest(low, SellEntry);
def trueqb = QB[1];
def trueqs = QS[1];
def price = close;
def length = 1;
def displace = 0;
def SMA = Average(price[-displace], length);

#--------------------------------------------------------------
def _highInPeriod1 = Highest(high, LookbackPeriod);
def _lowInPeriod1 = Lowest(low, LookbackPeriod);
#--------------------------------------------------------------
def marketLow1 = if _lowInPeriod1 < _lowInPeriod1[-LookbackPeriod] then _lowInPeriod1 else _lowInPeriod1[-LookbackPeriod];
def _markedLow1 = low == marketLow1;

rec _lastMarkedLow1 = CompoundValue(1, if IsNaN(_markedLow1) then _lastMarkedLow1[1] else if _markedLow1 then low else _lastMarkedLow1[1], low);
#--------------------------------------------------------------
def marketHigh1 = if _highInPeriod1 > _highInPeriod1[-LookbackPeriod] then _highInPeriod1 else _highInPeriod1[-LookbackPeriod];
def _markedHigh1 = high == marketHigh1;

rec _lastMarkedHigh1 = CompoundValue(1, if IsNaN(_markedHigh1) then _lastMarkedHigh1[1] else if _markedHigh1 then high else _lastMarkedHigh1[1], high);
#--------------------------------------------------------------
plot Resistance1 = _lastMarkedHigh1;
plot Support1 = _lastMarkedLow1;
#--------------------------------------------------------------
Resistance1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance1.SetDefaultColor(Color.MAGENTA);
Resistance1.SetHiding(HideCurrentTF);
#--------------------------------------------------------------
Support1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support1.SetDefaultColor(Color.YELLOW);
Support1.SetHiding(HideCurrentTF);
#--------------------------------------------------------------
def LowSwingForw = Lowest(low, SwingsLagBar)[-SwingsLagBar];
def LowSwingBack = Lowest(low, LookbackPeriod)[1];
def SwingLow = if low < LowSwingForw and low <= LowSwingBack then 1 else 0;
plot LowSwing = if SwingLow then low else Double.NaN;
LowSwing.Hide();
#--------------------------------------------------------------
def HighSwingForw = Highest(high, SwingsLagBar)[-SwingsLagBar];
def HighSwingBack = Highest(high, LookbackPeriod)[1];
def SwingHigh = if high > HighSwingForw and high >= HighSwingBack then 1 else 0;
plot HighSwing = if SwingHigh then high else Double.NaN;
HighSwing.Hide();
#--------------------------------------------------------------
HighSwing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
HighSwing.SetLineWeight(5);
HighSwing.SetDefaultColor(Color.MAGENTA);
HighSwing.SetHiding(HideSwings);
LowSwing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
LowSwing.SetLineWeight(5);
LowSwing.SetDefaultColor(Color.YELLOW);
LowSwing.SetHiding(HideSwings);
#--------------------------------------------------------------
Alert(HighSwing, "SupRes : Swing High", Alert.BAR, Sound.Bell);
Alert(LowSwing, "SupRes : Swing Low", Alert.BAR, Sound.Bell);
#--------------------------------------------------------------
AddLabel(HighSwing, "SupRes : Swing High", Color.MAGENTA);
AddLabel(LowSwing, "SupRes : Swing Low", Color.YELLOW);
#--------------------------------------------------------------
def _highInPeriod2 = Highest(high(period = TimeFrame2), LookbackPeriod);
def _lowInPeriod2 = Lowest(low(period = TimeFrame2), LookbackPeriod);
#--------------------------------------------------------------
def marketLow2 = if _lowInPeriod2 < _lowInPeriod2[-LookbackPeriod] then _lowInPeriod2 else _lowInPeriod2[-LookbackPeriod];
def _markedLow2 = low(period = TimeFrame2) == marketLow2;

rec _lastMarkedLow2 = CompoundValue(1, if IsNaN(_markedLow2) then _lastMarkedLow2[1] else if _markedLow2 then low(period = TimeFrame2) else _lastMarkedLow2[1], low(period = TimeFrame2));
#--------------------------------------------------------------
def marketHigh2 = if _highInPeriod2 > _highInPeriod2[-LookbackPeriod] then _highInPeriod2 else _highInPeriod2[-LookbackPeriod];
def _markedHigh2 = high(period = TimeFrame2) == marketHigh2;

rec _lastMarkedHigh2 = CompoundValue(1, if IsNaN(_markedHigh2) then _lastMarkedHigh2[1] else if _markedHigh2 then high(period = TimeFrame2) else _lastMarkedHigh2[1], high(period = TimeFrame2));
#--------------------------------------------------------------
plot Resistance2 = _lastMarkedHigh2;
Resistance2.Hide();
plot Support2 = _lastMarkedLow2;
Support2.Hide();
#--------------------------------------------------------------
Resistance2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance2.SetDefaultColor(Color.MAGENTA);
Resistance2.SetHiding(HideTimeFrame2);
#--------------------------------------------------------------
Support2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support2.SetDefaultColor(Color.YELLOW);
Support2.SetHiding(HideTimeFrame2);
#--------------------------------------------------------------
def _highInPeriod3 = Highest(high(period = TimeFrame3), LookbackPeriod);
def _lowInPeriod3 = Lowest(low(period = TimeFrame3), LookbackPeriod);
#--------------------------------------------------------------
def marketLow3 = if _lowInPeriod3 < _lowInPeriod3[-LookbackPeriod] then _lowInPeriod3 else _lowInPeriod3[-LookbackPeriod];
def _markedLow3 = low(period = TimeFrame3) == marketLow3;

rec _lastMarkedLow3 = CompoundValue(1, if IsNaN(_markedLow3) then _lastMarkedLow3[1] else if _markedLow3 then low(period = TimeFrame3) else _lastMarkedLow3[1], low(period = TimeFrame3));
#--------------------------------------------------------------
def marketHigh3 = if _highInPeriod3 > _highInPeriod3[-LookbackPeriod] then _highInPeriod3 else _highInPeriod3[-LookbackPeriod];
def _markedHigh3 = high(period = TimeFrame3) == marketHigh3;

rec _lastMarkedHigh3 = CompoundValue(1, if IsNaN(_markedHigh3) then _lastMarkedHigh3[1] else if _markedHigh3 then high(period = TimeFrame3) else _lastMarkedHigh3[1], high(period = TimeFrame3));
#--------------------------------------------------------------
plot Resistance3 = _lastMarkedHigh3;
Resistance3.Hide();
plot Support3 = _lastMarkedLow3;
Support3.Hide();
#--------------------------------------------------------------
Resistance3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance3.SetDefaultColor(Color.MAGENTA);
Resistance3.SetHiding(HideTimeFrame3);
#--------------------------------------------------------------
Support3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support3.SetDefaultColor(Color.YELLOW);
Support3.SetHiding(HideTimeFrame3);

def lower_close1 = (SMA crosses below Support1[1]);
def higher_close1 = (SMA crosses above Resistance1[1]);
def lower_close2 = (SMA crosses below Support2[1]);
def higher_close2 = (SMA crosses above Resistance2[1]);
def lower_close3 = (SMA crosses below Support2[1]);
def higher_close3 = (SMA crosses above Resistance2[1]);

def x = (hl2 > trueqb);
def c = (close[1] < trueqb[1]);
def v = (close[2] < trueqb[2]);
def b = x and (c or v);

def y = (close > trueqs);
def w = (close[1] < trueqs[1]);
def e = (close[2] < trueqs[2]);
def r = y and (w or e);

def allbreakdown = lower_close1 or lower_close2 or lower_close3;
def allbreakup =  (higher_close1 or higher_close2 or higher_close3);

input BuyEntry2 = 40;
input SellEntry2 = 40;

def QB2 = Highest(high, BuyEntry2);
def QS2 = Lowest(low, SellEntry2);
plot trueqb2 = QB2[1];
trueqb2.setDefaultColor(GetColor(27));
plot trueqs2 = QS2[1];
trueqs2.setDefaultColor(GetColor(27));
def ath = (((trueqb2 - trueqb2[10]) / 100) < .10);
def atl = (((trueqs2 - trueqs2[10]) / 100) >= -.10);



plot goldenbuy = (allbreakup or  allbreakup[1]) and ((high + close) / 2 > trueqb2) and ath;
goldenbuy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
goldenbuy.setDefaultColor(GetColor(34));

plot goldenshort = (allbreakdown or  allbreakdown[1]) and ((close + low) / 2 < trueqs2) and atl;
goldenshort.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
goldenshort.SetDefaultColor(GetColor(39));
 
Last edited:
YungTraderFromMontana

YungTraderFromMontana

Well-known member
I forgot to make an updated scan after I added a mtf support resistance study. I'll have to make it in 3 parts later today.

For now here's and older version of the scan


Code:
def price = (open + close)/2;
def length = 1;
def displace = 0;
def SMA = Average(price[-displace], length);
def length2 = 180;
def displace2 = 0;
def SMA2 = Average(price[-displace2], length2);


#1

input LookbackPeriod1 = 8;
def FirstBar = BarNumber();
def Highest = fold i = 1
             to LookbackPeriod1 + 1
             with p = 1
             while p
             do high > GetValue(high, -i);
def A = if (FirstBar > LookbackPeriod1
            and high == Highest(high, LookbackPeriod1)
            and Highest)
            then high
            else Double.NaN;
def Lowest = fold j = 1
            to LookbackPeriod1 + 1
            with q = 1
            while q
            do low < GetValue(low, -j);
def B = if (FirstBar > LookbackPeriod1
            and low == Lowest(low, LookbackPeriod1)
            and Lowest)
            then low
            else Double.NaN;
#--------------------------------------------------------------
def _highInPeriod1 = Highest(high, LookbackPeriod1);
def _lowInPeriod1 = Lowest(low, LookbackPeriod1);
#--------------------------------------------------------------
def marketLow1 = if _lowInPeriod1 < _lowInPeriod1[-LookbackPeriod1] then _lowInPeriod1 else _lowInPeriod1[-LookbackPeriod1];
def _markedLow1 = low == marketLow1;
rec _lastMarkedLow1 = CompoundValue(1, if IsNaN(_markedLow1) then _lastMarkedLow1[1] else if _markedLow1 then low else _lastMarkedLow1[1], low);
#--------------------------------------------------------------
def marketHigh1 = if _highInPeriod1 > _highInPeriod1[-LookbackPeriod1] then _highInPeriod1 else _highInPeriod1[-LookbackPeriod1];
def _markedHigh1 = high == marketHigh1;
rec _lastMarkedHigh1 = CompoundValue(1, if IsNaN(_markedHigh1) then _lastMarkedHigh1[1] else if _markedHigh1 then high else _lastMarkedHigh1[1], high);
#--------------------------------------------------------------

def Resistance1 = _lastMarkedHigh1;
def Support1 = _lastMarkedLow1;
def lower_close1 = (sma crosses below Support1[1]);
def higher_close1 = (sma crosses above Resistance1[1]);
#---------------------------------------
def ph1 = Round(A, 2);

def pl1 = Round(B, 2);



def doublebreakup1 = higher_close1;
def doublebreakdown1 = lower_close1;





#2

input LookbackPeriod0 = 6;
def FirstBar0 = BarNumber();
def Highest0 = fold i0 = 1
             to LookbackPeriod0 + 1
             with p0 = 1
             while p0
             do high > GetValue(high, -i0);
def A0 = if (FirstBar0 > LookbackPeriod0
            and high == Highest(high, LookbackPeriod0)
            and Highest0)
            then high
            else Double.NaN;
def Lowest0 = fold j0 = 1
            to LookbackPeriod0 + 1
            with q0 = 1
            while q0
            do low < GetValue(low, -j0);
def B0 = if (FirstBar0 > LookbackPeriod0
            and low == Lowest(low, LookbackPeriod0)
            and Lowest0)
            then low
            else Double.NaN;
#--------------------------------------------------------------
def _highInPeriod10 = Highest(high, LookbackPeriod0);
def _lowInPeriod10 = Lowest(low, LookbackPeriod0);
#--------------------------------------------------------------
def marketLow10 = if _lowInPeriod10 < _lowInPeriod10[-LookbackPeriod0] then _lowInPeriod1 else _lowInPeriod10[-LookbackPeriod0];
def _markedLow10 = low == marketLow10;
rec _lastMarkedLow10 = CompoundValue(1, if IsNaN(_markedLow10) then _lastMarkedLow10[1] else if _markedLow10 then low else _lastMarkedLow10[1], low);
#--------------------------------------------------------------
def marketHigh10 = if _highInPeriod10 > _highInPeriod10[-LookbackPeriod0] then _highInPeriod10 else _highInPeriod10[-LookbackPeriod0];
def _markedHigh10 = high == marketHigh10;
rec _lastMarkedHigh10 = CompoundValue(1, if IsNaN(_markedHigh10) then _lastMarkedHigh10[1] else if _markedHigh10 then high else _lastMarkedHigh10[1], high);
#--------------------------------------------------------------

def Resistance10 = _lastMarkedHigh10;
def Support10 = _lastMarkedLow10;
def lower_close0 = (sma crosses below Support10[1]);
def higher_close0 = (sma crosses above Resistance10[1]);
#---------------------------------------
def ph0 = Round(A, 2);

def pl0 = Round(B, 2);

def doublebreakup2 = higher_close0;
def doublebreakdown2 = lower_close0;



#3

input LookbackPeriod00 = 4;
def FirstBar00 = BarNumber();
def Highest00 = fold i00 = 1
             to LookbackPeriod00 + 1
             with p00 = 1
             while p00
             do high > GetValue(high, -i00);
def A00 = if (FirstBar00 > LookbackPeriod00
            and high == Highest(high, LookbackPeriod00)
            and Highest00)
            then high
            else Double.NaN;
def Lowest00 = fold j00 = 1
            to LookbackPeriod00 + 1
            with q00 = 1
            while q00
            do low < GetValue(low, -j00);
def B00 = if (FirstBar00 > LookbackPeriod00
            and low == Lowest(low, LookbackPeriod00)
            and Lowest00)
            then low
            else Double.NaN;
#--------------------------------------------------------------
def _highInPeriod100 = Highest(high, LookbackPeriod00);
def _lowInPeriod100 = Lowest(low, LookbackPeriod00);
#--------------------------------------------------------------
def marketLow100 = if _lowInPeriod100 < _lowInPeriod100[-LookbackPeriod00] then _lowInPeriod100 else _lowInPeriod100[-LookbackPeriod00];
def _markedLow100 = low == marketLow100;
rec _lastMarkedLow100 = CompoundValue(1, if IsNaN(_markedLow100) then _lastMarkedLow100[1] else if _markedLow100 then low else _lastMarkedLow100[1], low);
#--------------------------------------------------------------
def marketHigh100 = if _highInPeriod100 > _highInPeriod100[-LookbackPeriod00] then _highInPeriod100 else _highInPeriod1[-LookbackPeriod00];
def _markedHigh100 = high == marketHigh100;
rec _lastMarkedHigh100 = CompoundValue(1, if IsNaN(_markedHigh100) then _lastMarkedHigh100[1] else if _markedHigh100 then high else _lastMarkedHigh100[1], high);
#--------------------------------------------------------------

def Resistance100 = _lastMarkedHigh100;
def Support100 = _lastMarkedLow100;
def lower_close00 = (sma crosses below Support100[1]);
def higher_close00 = (sma crosses above Resistance100[1]);
#---------------------------------------
def ph000 = Round(A, 2);

def pl000 = Round(B, 2);



def doublebreakup3 = higher_close00;
def doublebreakdown3 = lower_close00;
def twoathree = doublebreakup1 or doublebreakup2;
def twoofthree2 = doublebreakup1 or doublebreakup3;
def twoathree3 = doublebreakdown1 or doublebreakdown2;
def twoofthree3 = doublebreakdown1 or doublebreakdown3;

def allbreakdown = doublebreakdown1 and doublebreakdown2 and doublebreakdown3;
def twoofthreedown = twoathree3 and twoofthree3;
def slippedthroughthecracksdown = twoofthreedown and (price[1] > support1) and (price < support1);

plot breakdown = allbreakdown or slippedthroughthecracksdown;

#plot breakout = doublebreakup and doublebreakup2 and doublebreakup3;
 
Last edited:
M

mailbagman2000

Member
Thanks looks good, I'll be watching it on Friday. Can't wait to see the new scam set-up?

Keep getting error msg' while scanning. Week and Month not allow. So I removed them from the scan. Still getting lots of errors.
 
Last edited by a moderator:
A

Ahmar824

Member
VIP
is there a way to change the support and resistance line to show only at the max number of close?
 
YungTraderFromMontana

YungTraderFromMontana

Well-known member
Thanks looks good, I'll be watching it on Friday. Can't wait to see the new scam set-up?

Keep getting error msg' while scanning. Week and Month not allow. So I removed them from the scan. Still getting lots of errors.
I'm working on it. Sorry but I'll have one soon.
 
T

Thomas

Active member
Hurry UP!!!!,...hahahaha,......checking out this creation, if whatever scan worked for you to enter the stocks posted, it's not here. I loaded the newer scan and had an error come back, "Week," not allowed, but this concept for support resistance, trend looks good. I have time here Sunday and will flip chart to Black and white and see how it works.....I'm always testing new stuff, sometimes a lightbulb pops...
 
Billions

Billions

Active member
2019 Donor
VIP
@YungTraderFromMontana I'm a little confused which is the current correct code for this study thank you!
 
T

Thomas

Active member
@YungTraderFromMontana I'm a little confused which is the current correct code for this study thank you!
Hey Billion, in the thread the chart is correct, and the second scan is only one working, unless someone comes up with better wheel....for now.....
 
Billions

Billions

Active member
2019 Donor
VIP
Hey Billion, in the thread the chart is correct, and the second scan is only one working, unless someone comes up with better wheel....for now.....
ok thank you
 
H

Hitesh

New member
Thanks for excellent work. Was looking for something like this long time.
 
YungTraderFromMontana

YungTraderFromMontana

Well-known member
Here's the scan!! Make sure you have a second indicator to confirm breakouts with. I'll be posting one here on a different thread labelled truedepth of roc. I think it pairs well.
Code:
input LookbackPeriod = 8;
input TimeFrame2 = "DAY";
input TimeFrame3 = "DAY";
input HideSwings = no;
input HideCurrentTF = no;
input HideTimeFrame2 = no;
input HideTimeFrame3 = no;
input length1 = 8;
input length21 = 40;
input length31 = 4;
input price = close;
input BuyEntry3 = 10;
input SellEntry3 = 10;
def displace2 = 0;



assert(length1 > 0, "'length' must be positive: " + length1);
def ROC = if price[length1] != 0 then (price / price[length1] - 1) * 100 else 0;
assert(length21 > 0, "'length' must be positive: " + length21);
def ROC2 = if price[length21] != 0 then (price / price[length21] - 1) * 100 else 0;
assert(length31 > 0, "'length' must be positive: " + length31);
def ROC3 = if price[length21] != 0 then (price / price[length31] - 1) * 100 else 0;
def xx = roc >= roc2 or roc2 > roc3;
def yy = roc <= roc2 or roc2 < roc3;

def QB3 = Highest(roc, BuyEntry3);
def QS3 = Lowest(roc, SellEntry3);
def trueqb3 = QB3[1];


def trueqs3 = QS3[1];
def SMaoftruedepth= Average(trueqb3-trueqs3[-displace2], length21);
def squeeze = (trueqb3 - trueqs3) < (smaoftruedepth/2);

def bottom = 10;
def top = -10;

def goodlong = squeeze or squeeze[1] or squeeze[2];
def goodshort = roc < trueqb3 or (roc[1] < top);



def SwingsLagBar = 1;
def BuyEntry = 3;
def SellEntry = 3;

def QB = Highest(high, BuyEntry);
def QS = Lowest(low, SellEntry);
def trueqb = QB[1];
def trueqs = QS[1];
def length = 1;
def displace = 0;
def SMA = Average(price[-displace], length);

#--------------------------------------------------------------
def _highInPeriod1 = Highest(high, LookbackPeriod);
def _lowInPeriod1 = Lowest(low, LookbackPeriod);
#--------------------------------------------------------------
def marketLow1 = if _lowInPeriod1 < _lowInPeriod1[-LookbackPeriod] then _lowInPeriod1 else _lowInPeriod1[-LookbackPeriod];
def _markedLow1 = low == marketLow1;

rec _lastMarkedLow1 = CompoundValue(1, if IsNaN(_markedLow1) then _lastMarkedLow1[1] else if _markedLow1 then low else _lastMarkedLow1[1], low);
#--------------------------------------------------------------
def marketHigh1 = if _highInPeriod1 > _highInPeriod1[-LookbackPeriod] then _highInPeriod1 else _highInPeriod1[-LookbackPeriod];
def _markedHigh1 = high == marketHigh1;

rec _lastMarkedHigh1 = CompoundValue(1, if IsNaN(_markedHigh1) then _lastMarkedHigh1[1] else if _markedHigh1 then high else _lastMarkedHigh1[1], high);
#--------------------------------------------------------------
def Resistance1 = _lastMarkedHigh1;
def Support1 = _lastMarkedLow1;

#--------------------------------------------------------------
def LowSwingForw = Lowest(low, SwingsLagBar)[-SwingsLagBar];
def LowSwingBack = Lowest(low, LookbackPeriod)[1];
def SwingLow = if low < LowSwingForw and low <= LowSwingBack then 1 else 0;
def LowSwing = if SwingLow then low else Double.NaN;

#--------------------------------------------------------------
def HighSwingForw = Highest(high, SwingsLagBar)[-SwingsLagBar];
def HighSwingBack = Highest(high, LookbackPeriod)[1];
def SwingHigh = if high > HighSwingForw and high >= HighSwingBack then 1 else 0;
def HighSwing = if SwingHigh then high else Double.NaN;

#--------------------------------------------------------------
def _highInPeriod2 = Highest(high(period = TimeFrame2), LookbackPeriod);
def _lowInPeriod2 = Lowest(low(period = TimeFrame2), LookbackPeriod);
#--------------------------------------------------------------
def marketLow2 = if _lowInPeriod2 < _lowInPeriod2[-LookbackPeriod] then _lowInPeriod2 else _lowInPeriod2[-LookbackPeriod];
def _markedLow2 = low(period = TimeFrame2) == marketLow2;

rec _lastMarkedLow2 = CompoundValue(1, if IsNaN(_markedLow2) then _lastMarkedLow2[1] else if _markedLow2 then low(period = TimeFrame2) else _lastMarkedLow2[1], low(period = TimeFrame2));
#--------------------------------------------------------------
def marketHigh2 = if _highInPeriod2 > _highInPeriod2[-LookbackPeriod] then _highInPeriod2 else _highInPeriod2[-LookbackPeriod];
def _markedHigh2 = high(period = TimeFrame2) == marketHigh2;

rec _lastMarkedHigh2 = CompoundValue(1, if IsNaN(_markedHigh2) then _lastMarkedHigh2[1] else if _markedHigh2 then high(period = TimeFrame2) else _lastMarkedHigh2[1], high(period = TimeFrame2));
#--------------------------------------------------------------
def Resistance2 = _lastMarkedHigh2;
def Support2 = _lastMarkedLow2;
;

#--------------------------------------------------------------
def _highInPeriod3 = Highest(high(period = TimeFrame3), LookbackPeriod);
def _lowInPeriod3 = Lowest(low(period = TimeFrame3), LookbackPeriod);
#--------------------------------------------------------------
def marketLow3 = if _lowInPeriod3 < _lowInPeriod3[-LookbackPeriod] then _lowInPeriod3 else _lowInPeriod3[-LookbackPeriod];
def _markedLow3 = low(period = TimeFrame3) == marketLow3;

rec _lastMarkedLow3 = CompoundValue(1, if IsNaN(_markedLow3) then _lastMarkedLow3[1] else if _markedLow3 then low(period = TimeFrame3) else _lastMarkedLow3[1], low(period = TimeFrame3));
#--------------------------------------------------------------
def marketHigh3 = if _highInPeriod3 > _highInPeriod3[-LookbackPeriod] then _highInPeriod3 else _highInPeriod3[-LookbackPeriod];
def _markedHigh3 = high(period = TimeFrame3) == marketHigh3;

rec _lastMarkedHigh3 = CompoundValue(1, if IsNaN(_markedHigh3) then _lastMarkedHigh3[1] else if _markedHigh3 then high(period = TimeFrame3) else _lastMarkedHigh3[1], high(period = TimeFrame3));
#--------------------------------------------------------------
def Resistance3 = _lastMarkedHigh3;

def Support3 = _lastMarkedLow3;


def lower_close1 = (SMA crosses below Support1[1]);
def higher_close1 = (SMA crosses above Resistance1[1]);
def lower_close2 = (SMA crosses below Support2[1]);
def higher_close2 = (SMA crosses above Resistance2[1]);
def lower_close3 = (SMA crosses below Support2[1]);
def higher_close3 = (SMA crosses above Resistance2[1]);

def x = (close > trueqb);
def c = (close[1] < trueqb[1]);
def v = (close[2] < trueqb[2]);
def b = x and (c or v);

def y = (close > trueqs);
def w = (close[1] < trueqs[1]);
def e = (close[2] < trueqs[2]);
def r = y and (w or e);

def allbreakdown = lower_close1 or lower_close2 or lower_close3;
def allbreakup =  (higher_close1 or higher_close2 or higher_close3);

input BuyEntry2 = 40;
input SellEntry2 = 40;

def QB2 = Highest(high, BuyEntry2);
def QS2 = Lowest(low, SellEntry2);
def trueqb2 = QB2[1];

def trueqs2 = QS2[1];

def ath = (((trueqb2 - trueqb2[3]) / 100) < .10);
def atl = (((trueqs2 - trueqs2[3]) / 100) >= -.10);



plot goldenbuy = (allbreakup or  allbreakup[1]) and ((high) > trueqb2) and ath;

#plot goldenshort = (allbreakdown or  allbreakdown[1]) and ((low) < trueqs2) and atl;
 
Last edited:
YungTraderFromMontana

YungTraderFromMontana

Well-known member
If youre talking about the truedepth length then you can adjust it. Change the buyentry and sellentry
 
A

akykn

Member
does it repaint? or Are you using diff settings? cause im looking at chart that posted (MRNA) arrows that appears onto your chart doesnt match with mines... I just curious maybe y use diff settings ? btw thanks for the thread
 

Similar threads

Top