YungTrader's Ultimate Indicator

Status
Not open for further replies.
More selective version from previous. I suggest using it on the 2d. If the signal is triggered after crossing a day before then trade the open of the candle.
Code:
input LookbackPeriod = 2;
input TimeFrame2 = "week";
input TimeFrame3 = "month";
input HideSwings = no;
input HideCurrentTF = no;
input HideTimeFrame2 = no;
input HideTimeFrame3 = no;
input length = 5;
input length21 = 40;
input length1 = 8;

def price = (open + close)/2;
input BuyEntry3 = 10;
input SellEntry3 = 10;
def displace2 = 0;

input buyentry4 = 6;
input sellentry4 = 6;
input lengthw = 4;
def wClosew = (high + low + 2 * close) * 0.25;
def wCRatiow = (wClosew - wClosew[1]) / Min(wClosew, wClosew[1]);
def closeRatiow = 3 * wClosew / Average(Highest(High, 2) - Lowest(Low, 2), lengthw) * AbsValue(wCRatiow);
def volumeRatiow = Volume / Average(Volume, lengthw);
def volumePerClosew = volumeRatiow / exp(Min(88, closeRatiow));
def buyPw;
def sellPw;
if (wCRatiow > 0) {
    buyPw = volumeRatiow;
    sellPw = volumePerClosew;
} else {
    buyPw = volumePerClosew;
    sellPw = volumeRatiow;
}
def buyPresw = if IsNaN(buyPresw[1]) then 0 else ((buyPresw[1] * (lengthw - 1)) + buyPw) / lengthw;
def sellPresw = if IsNaN(sellPresw[1]) then 0 else ((sellPresw[1] * (lengthw - 1)) + sellPw) / lengthw;
def tempDIw;
if ((((sellPresw[1] * (lengthw - 1)) + sellPw) / lengthw - ((buyPresw[1] * (lengthw - 1)) + buyPw) / lengthw) > 0) {
    tempDIw = - if (sellPresw != 0) then buyPresw / sellPresw else 1;
} else {
    tempDIw = if (buyPresw != 0) then sellPresw / buyPresw else 1;
}
plot DMIndxw = if IsNaN(close) then Double.NaN else if tempDIw < 0 then -1 - tempDIw else 1 - tempDIw;

def wClose = (high + low + 2 * close) * 0.25;
def wCRatio = (wClose - wClose[1]) / Min(wClose, wClose[1]);
def closeRatio = 3 * wClose / Average(Highest(High, 2) - Lowest(Low, 2), length) * AbsValue(wCRatio);
def volumeRatio = Volume / Average(Volume, length);
def volumePerClose = volumeRatio / exp(Min(88, closeRatio));
def buyP;
def sellP;
if (wCRatio > 0) {
    buyP = volumeRatio;
    sellP = volumePerClose;
} else {
    buyP = volumePerClose;
    sellP = volumeRatio;
}
def buyPres = if IsNaN(buyPres[1]) then 0 else ((buyPres[1] * (length - 1)) + buyP) / length;
def sellPres = if IsNaN(sellPres[1]) then 0 else ((sellPres[1] * (length - 1)) + sellP) / length;
def tempDI;
if ((((sellPres[1] * (length - 1)) + sellP) / length - ((buyPres[1] * (length - 1)) + buyP) / length) > 0) {
    tempDI = - if (sellPres != 0) then buyPres / sellPres else 1;
} else {
    tempDI = if (buyPres != 0) then sellPres / buyPres else 1;
}
plot DMIndx = if IsNaN(close) then Double.NaN else if tempDI < 0 then -1 - tempDI else 1 - tempDI;

plot ZeroLine = 0;
plot lowe = .4;
plot highe = -.4;

def QB4 = Highest(dmindx, BuyEntry4);
def QS4 = Lowest(dmindx, SellEntry4);
def trueqb4 = QB4[1];
def trueqs4 = QS4[1];



DMIndx.setDefaultColor(GetColor(1));
ZeroLine.SetDefaultColor(GetColor(5));



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 QB3 = Highest(roc, BuyEntry3);
def QS3 = Lowest(roc, SellEntry3);
def trueqb3 = QB3[1];


def trueqs3 = QS3[1];
plot buy4 =  (dmindx > trueqb4) and (roc > trueqs3) and (roc > 1) and (roc > trueqb3);
def optiondos = (dmindxw > .47069);
plot sell4 = (dmindx < trueqs4) and (roc < trueqb3) and (roc < -1);



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];
plot midline = (trueqb + trueqs)/2;
def length78 = 1;
def displace = 0;
def price2 = close;
def SMA = Average(price[-displace], length78);
def SMA2 = Average(price2[-displace], length78);

#--------------------------------------------------------------
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 lower_close12 = (SMA2 crosses below Support1[1]);
def higher_close12 = (SMA2 crosses above Resistance1[1]);
def lower_close22 = (SMA2 crosses below Support2[1]);
def higher_close22 = (SMA2 crosses above Resistance2[1]);
def lower_close32 = (SMA2 crosses below Support2[1]);
def higher_close32 = (SMA2 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);
def allbreakup2 =  (higher_close12 or higher_close22 or higher_close32);
def anyres = resistance1 or resistance2 or resistance3;
def ansup = support1 or support2 or support3;

input BuyEntry2 = 1;
input SellEntry2 = 1;

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));
plot midline2 = (trueqb2 + trueqs2)/2;

def goodcandle = (high - close) < (hl2 - low);
def goodsellcandle = (close - low) < (high - hl2);
def goodcandle2 = ((close - open)/(high - low)) > .82;
def allbreaku = (allbreakup2 and goodcandle2);
def goldenbuy = (allbreakup or allbreaku or allbreakup[1]);

def goldenshort = (allbreakdown) and (((low) < trueqs2) or (close crosses below midline2));


plot goldenbuytesting = goldenbuy and (buy4 or optiondos) and (goodcandle);
goldenbuytesting.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
goldenbuytesting.SetDefaultColor(GetColor(34));
plot goldenshorttesting = goldenshort and (sell4) and (goodsellcandle);
goldenshorttesting.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
goldenshorttesting.SetDefaultColor(GetColor(39));

def resistancebounce = (high[1] >= resistance1[1]) and (close < low[1]);
plot supportbounce = (low[1] <= support1[1]) and (close > midline2) and (low[1] < midline2);

there was wishes to have it trade more quickly off of the bottoms, the shorter lookback on this one should help get in earlier.
 

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

I'm in love with this script. In combination with a couple other indicators I use, it seems like it will work really well for my needs.

Question: I do some crypto trading as well and I'm using TradingView for my charting on that. Is there a way to convert this to pinescript? I thought I would ask here before I tried to find someone to convert it for me (if that's even possible).

Thank you very much

-Gamma
 
Is there a way to have a symbol removed from the scan if the conditions are no longer met? If I have the scan as a watchlist (which I do), it would be awesome to have an alert set up when it gets removed. Good indicator the trade was not a winner, or even better, exit with profit. Not the only way to exit of course but could help if managing many trades.

Let me know if I'm not making sense. Currently I do get an alert if a symbol is added or removed from my watchlist, but I don't believe the script can remove symbols from a watchlist in it's current form (is it even possible?)
 
I'm in love with this script. In combination with a couple other indicators I use, it seems like it will work really well for my needs.

Question: I do some crypto trading as well and I'm using TradingView for my charting on that. Is there a way to convert this to pinescript? I thought I would ask here before I tried to find someone to convert it for me (if that's even possible).

Thank you very much

-Gamma
I'm not familiar with pinescript so I'm not sure.
 
It isn't a scan it modifies the last version. It is more selective and accurate. I suggest the 2 day chart because it limits fakeouts, if a stock hold over resistance for two days the breakout is mostly confirmed.

If you were trying to catch intraday breaks over short term resistance, what time frame chart would you suggest (or is this not a good tool for that)?
 
@YungTraderFromMontana Im trying to set this up for 3 and 5min timeframes and some stocks are perfectly fine and others have Vertical Lines throughout the chart. Dont know how to insert http: pictures to show ya or i would lol. Im certain they are the DMIndxw/DMindx/ZeroLine/Buy4/Sell4/Supportbounce and such. I just dont know how to fix it. That and which buyentry to change.
 
@YungTraderFromMontana Im trying to set this up for 3 and 5min timeframes and some stocks are perfectly fine and others have Vertical Lines throughout the chart. Dont know how to insert http: pictures to show ya or i would lol. Im certain they are the DMIndxw/DMindx/ZeroLine/Buy4/Sell4/Supportbounce and such. I just dont know how to fix it. That and which buyentry to change.
Its because I forgot to to turn off some studies from plotting. If the is under like 5 bucks you'll see lines. Go into settings and turn off the display of plots that aren't named support, resistance, goldenbuytesting, goldenshorttesting, and other varients off that. Turn off names like dmindx and roc.
 
Its because I forgot to to turn off some studies from plotting. If the is under like 5 bucks you'll see lines. Go into settings and turn off the display of plots that aren't named support, resistance, goldenbuytesting, goldenshorttesting, and other varients off that. Turn off names like dmindx and roc.

Ok sweet, i thought that would do it but just didnt want to mess up your indicator. Thanks man! You are killin it with these indicators! Appreciate it!
 
Here is the first finely tuned version.
https://tos.mx/SRMXfTV.
Yellow wedges are old signals (on 2 lookback), arrows are new signals.
When you get to this level of nitpicking of settings certain versions only work well on certain stocks. I'm going to go one by one and look for correlations that will allow me to formulate settings for any stock.
This first version was designed and excels strictly on a AMZN 2d chart on long plays.
Other tickers to come.
I have a watchlist of stocks that carry momentum that I will be making versions for, here's the watchlist. https://tos.mx/FzGbRiU.
Most will be hot stocks for a while, a few are hot because of the current market state (oil, travel, biotech).
Signals are quite rare but if I get a watchlist of around 20 stocks and moniter it I should average like 2-4 long and short plays a week. I'd say so far around 4/5 of signals are accurate and 2/3 would have easily been exited in the green.
 
Last edited:
@yungtrader, the last two days I have had 100% winners. Greatly appreciate your hard work and insight. Will update in 3 weeks to see if trend continues. I know 100% is unrealistic, goal is 80%
 
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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