Strategy Based on EMAs, TSI, MACD, and Premarket Highs/Lows For ThinkOrSwim

a1cturner --thanks for all the time and effort you put into your testing and scripts!
I loaded the 2nd code script for the watchlist indicator into my watchlist as you instructed -- results are a NO GO in the watchlist. Please see the following recording of what I did: https://www.screencast.com/t/K3UUGlX7q
Did I do something wrong?
 
a1cturner --thanks for all the time and effort you put into your testing and scripts!
I loaded the 2nd code script for the watchlist indicator into my watchlist as you instructed -- results are a NO GO in the watchlist. Please see the following recording of what I did: https://www.screencast.com/t/K3UUGlX7q
Did I do something wrong?
You will only get a signal on the chart and the watchlist between 8:35 A.M. CST and 2:55 P.M. CST as mentioned in the instruction.
 
This is what I do instead of a scan.

BDt0hOg.png
I echo @MerryDay comments, this is amazing work. I've read every line to this point carefully and I am not fully understanding the tan and blue candles and blue label on the macd above. It could be fine, but I checked a few of my watchlists with the Flexgrid and I am not getting any tan and blue showing. I'b be grateful if you could expand on these a bit. Thank you!
 
I echo @MerryDay comments, this is amazing work. I've read every line to this point carefully and I am not fully understanding the tan and blue candles and blue label on the macd above. It could be fine, but I checked a few of my watchlists with the Flexgrid and I am not getting any tan and blue showing. I'b be grateful if you could expand on these a bit. Thank you!
This flex grid has since changed (surely I didn’t forget to update the link). I’ll take a look at it tomorrow and see what I get. It should have been updated to green for long or red for short. There was never a tan though…? Gray however means that not all criteria for long or short have been met
 
I added another visual change. This will be called Version 7b and it is already posted in Post #1 along with an updated link.

I added the below code so you would get a background color change where you would also get a "Long", "Short", "Sell", or "Tk Pft" Bubble.

The default setting is off and I personally will only be using this on my Flex Grid, hence the name above the code.

Code:
##################################################################
#                BACKGROUND COLOR FOR FLEX GRID                  #
##################################################################
#BACKGROUND
input ShowFlexGridBackgroundColor = no;

AssignBackgroundColor(if ShowFlexGridBackgroundColor and CallBuyBub then GlobalColor("OpenLongPosition") else color.current);
AssignBackgroundColor(if ShowFlexGridBackgroundColor and PutBuyBub then GlobalColor("OpenShortPosition") else color.current);
AssignBackgroundColor(if ShowFlexGridBackgroundColor and (CallSellBub or PutSellBub) then GlobalColor("SellPosition") else color.current);
AssignBackgroundColor(if ShowFlexGridBackgroundColor and (TkPftBubCall or TkPftBubPut) then color.light_red else color.current);
Is there a way to make the background more opaque? I cannot see the candles with this on. Heaped accolades in previous posts, forgoing from here. (y)
 
This flex grid has since changed (surely I didn’t forget to update the link). I’ll take a look at it tomorrow and see what I get. It should have been updated to green for long or red for short. There was never a tan though…? Gray however means that not all criteria for long or short have been met
Thanks, here is what I am seeing, could be the 5min chart on long weekend. Here is what I thought was Tan:
mh0BX3y.jpg
AVHMecv.jpg
 

Attachments

  • mh0BX3y.jpg
    mh0BX3y.jpg
    55.2 KB · Views: 313
Last edited:
Is there a way to make the background more opaque? I cannot see the candles with this on. Heaped accolades in previous posts, forgoing from here. (y)
Not that I am aware of. My intent was for the background change to be like a flashing light (look over here!!) so that i could then look closer at that ticker on my main chart. I have noticed that the flex grid is faster and more accurate than a watchlist indicator. Not using the flex grid for anything other than an alternative to a watchlist column.
 
Thanks, here is what I am seeing, could be the 5min chart on long weekend. Here is what I thought was Tan:
mh0BX3y.jpg
AVHMecv.jpg
I need to update the flex grid link i guess. That color is dark yellow and I am not using that anymore. All I did to create it was turn all visual aspects of the code off and turn background color on. Here is the new link. I will also add to post 1

http://tos.mx/duZrCez
 

Attachments

  • mh0BX3y.jpg
    mh0BX3y.jpg
    55.2 KB · Views: 307
Current Version 10.4 - 05/31/2022

Strategy Link: http://tos.mx/P3mxTl4 (Click Setup, Open Shared Item, Paste the Link)

Alternatively, to use the strategy code below (not the link above) click on the charts tab, studies button, edit studies, strategies tab, create, copy and paste the first code in and change the name at the top to your liking, click ok. Make sure to follow the rules on the first post regarding time frame, extended hours etc.

Watchlist Indicator: http://tos.mx/KDtke7m (Click Setup, Open Shared Item, Paste the Link)

For the watchlist custom indicator (again, the code is below not the link above) click the gear icon on your watchlist, customize, type in “custom”, click the small scroll looking icon to the left of an unused custom study, paste the second code in and change the name to your liking (something short), change the “D” to “5m” and check extended hours, click ok.

Flexible Grid Link: http://tos.mx/duZrCez

This is just the preview. More detailed instructions below.

dCW8nQm.png


I WILL ADD ALL UPDATES HERE! This strategy is changing and I don’t want to confuse anyone with comments from previous versions in the post below!!!

This is months of trial and error with different strategies and indicators. This is what I have found that works best as of today. I am continually updating this strategy to refine it and/or find better entries and exits. All updates will be posted here on Post #1.

This strategy USES two EMAs (5EMA, 12EMA), MACD, TSI, and Pre-Market High/Low. The EMAs are arranged in a cloud (5EMA / 12EMA). This strategy also INCLUDES but does not USE the 34EMA, 50EMA, and Yesterdays High/Low. These can be turned on and off to your liking.

The triggers I am using are:
  • Buy Signal only between 8:35 A.M. CST until 2:00 P.M. CST (This can be changed to fit your needs)
  • EMAs Bullish (5EMA>12EMA) or EMAs Bearish (5EMA<12EMA)
  • MACD Trending Up or MACD Trending Down
  • TSI >10 and trending up or TSI <-10 and trending down
  • Low > the Pre-Market High or High < the Pre-Market Low
Again, subject to change.

Of note, I use this for options so the wording I use in the strategy is geared towards that.
  • Gray Candles - Criteria Not Met
  • Red Candle - Put Buy or Sell to Open (Short) (Entry is on the 5EMA or When you get the Buy Bubble)
  • Light Red Candle - Put Hold or Short Hold
  • Green Candle - Call Buy or Buy to Open (Long) (Entry is on 5EMA or when you get the Buy Bubble)
  • Light Green Candle - Call Hold or Long Hold
Candle colors can be changed using the gear icon, scrolling to the very bottom and changing the "globals" settings.

Very basic instructions...
  • If you FOMO in at the beginning of the day without a buy signal, which you shouldn't, and you get a Pink Boolean Arrow than GET OUT! The price is too extended from the EMA and you are just asked for a knife candle to kill your profits.
  • If you were patient and waited on the Buy Signal (white arrow) then get in on that 5EMA (green dashed line) or better. Alternatively, if you missed your entry, then try to get in at least on the white dash or better. This was the entry point from the previous candle.
    • You should not get a Buy Signal unless the price is already within the defined range of the 5EMA.
    • If you are confident in your order placing abilities and the spread isn't too wide you can even set a trailing stop buy order to try to get the best price.
  • If you get a Pink Boolean Arrow then again, really think about taking profits.
    • This is a great spot for a trailing stop depending on the spread!
  • If you get a Grey Candle than get ready to close your trade at the open of the next bar. Don't get in a hurry though because sometimes the candle will repaint and continue with your trend.
  • Rinse and Repeat. Don't Get Fancy! Let It work or move on to a stock that is working!
The difference in my trading waiting on that 5EMA entry was a game changer. In options, if I rushed into a trade that gave me a buy signal before it came back to the 5EMA I might be down 50% within seconds before maybe recovering. However, if I wait on that 5 EMA entry I may never be down or at worst 15%-20% before becoming profitable.

I added labels to the top of the chart for each criteria this strategy is looking for. This will help you "get ready" to buy. If they are all red then get ready to go short or buy puts on that 5EMA. If they are all green than again, get ready to go long or buy calls on that 5EMA.

I THINK the labels should go green/blue from left to right if the stock cooperates. I have noticed that the biggest thing holding up the entry is MACD direction and price at the 5EMA at the same time but then again, that is what makes it mostly* dependable.

Once you are in the trade you can stop looking at the labels. At that point you are just waiting for the grey candle or pink boolean arrow for your exit.

WIth that being said, be careful with options and this study! I chose my stocks based on my 2+ years of trading experience and look at support/resistance to chose the right strike. I am excited about this strategy because every single backtest I ran on every ticker on my watchlist was profitable over the past 10 days when trading 100 shares at a time.

Few Rules:
  • To be used on 5 minute charts. That is all I have tested it on.
  • Must have Extended Hours on and I prefer 3 Day / 5 Min zoomed in.
  • Copy the code and paste it as a STRATEGY not study.
  • If you so choose, turn on the "Over Ext Clouds". That is a take profit spot where you would get the pink boolean arrow.
There is no scanner yet but some users are trying to create one that works (one or two are floating around the comments now). I use a flexible grid with 16 charts and load the tickers that I am looking at that particular day. This allows for the fastest response for me personally. Link at the top.

BDt0hOg.png


Code:
#JT Newest Strategy Based on EMAs, TSI, Premarket Highs/Lows, and MACD
#VERSION 10.4 - 05/31/2022

#Notes

Declare Upper;

##################################################################
#                                OPTIONS                         #
##################################################################
input ShowTestBubbles = no;
input ShowFlexGridBackgroundColor = no;
input ShowColorDefLabels = yes;
input AlertOn = yes;
input Show200EMA = no;
input ShowFastEMALines = no;
input ShowFastEMACloud = no;
input ShowSlowEMALines = no;
input ShowSlowEMACloud = no;
input ShowPreMarketLines = no;
input ShowPreMarketCloud = no;
input ShowPreMarketLabel = yes;
input ShowPrevDayLines = no;
input ShowPrevDayCloud = no;
input ShowPrevHighLowLabel = no;
input ShowBuySellBubbles = no;
input ShowArrows = yes;
input ShowSquares = yes;
input ShowDashes = yes;
input ShowBooleanArrows = yes;
input ShowOverExtCloud = no;
input ShowTkPftBubble = no;
input ShowOrders = no;
input ShowTkPftOrders = no;

##################################################################
#                                COLORS                          #
##################################################################
DefineGlobalColor("200EMA", createcolor (255, 255, 255));
DefineGlobalColor("CloudUp", createcolor (102, 255, 102));
DefineGlobalColor("CloudDown", createcolor (255, 102, 102));
DefineGlobalColor("OpenLongPosition", createcolor (0, 255, 0));
DefineGlobalColor("OpenShortPosition", createcolor (255, 0, 0));
DefineGlobalColor("HoldLongPosition", createcolor (153, 255, 153));
DefineGlobalColor("HoldShortPosition", createcolor (255, 153, 153));
DefineGlobalColor("SellPosition", createcolor (255, 0, 0));
DefineGlobalColor("TakeProfit", createcolor (255, 0, 255));
DefineGlobalColor("CriteriaNotMet", createcolor (102, 102, 102)); #(255, 255, 0)

##################################################################
#                                 TIMES                          #
##################################################################
#START AND END TIMES
input TimeFrame = {default "5-Min", "1-Min", "10-Min", "15-Min", "30-Min", "1-Hour"};
input PreMarketStart = 0700; #EST
input PreMarketEnd = 0929; #EST
input StartTime = 0930; #EST
input BuySignalDelay = 0;
input EndTime = 1600; #EST
input BuySignalStop = 60; #Minutes Before End of Day
def LastCandleStop; #Last Candle is Sell Candle

        switch (TimeFrame) {
        case "1-min": LastCandleStop = 1;
        case "10-Min": LastCandleStop = 10;
        case "15-Min": LastCandleStop = 15;
        case "30-Min": LastCandleStop = 30;
        case "1-Hour": LastCandleStop = 60;
        default: LastCandleStop = 5;
        }

def TradingDayStart= SecondsFromTime(StartTime);
def BuySignalDelaySeconds = BuySignalDelay * 60;
def SignalStart = TradingDayStart > BuySignalDelaySeconds;
def TradingDayEnd = SecondsTillTime(EndTime);
def EndSignalDelaySeconds = BuySignalStop * 60;
def SignalEnd = TradingDayEnd > EndSignalDelaySeconds;
def TradingDay = SignalStart and SignalEnd; #10:00EST - 1500EST
def LastStopDelaySeconds = LastCandleStop * 60;
def EndDay = TradingDayEnd == LastStopDelaySeconds; #1550EST
def TradingDayExt = TradingDayEnd > LastStopDelaySeconds;

##################################################################
#                              INDICATORS                        #
##################################################################
#200 EMA
plot EMA200 = ExpAverage(HL2, 200);
EMA200.SetDefaultColor(globalcolor("200EMA"));
EMA200.HideBubble();
EMA200.sethiding(!Show200EMA);

#EMAS
input Ema1Length = 5;
input Ema2Length = 12;
input Ema3Length = 34;
input Ema4Length = 50;

plot EMA1 = ExpAverage(close, Ema1Length);
EMA1.SetStyle(Curve.Short_Dash);
EMA1.SetDefaultColor(globalcolor("CloudUp"));
EMA1.HideBubble();
#EMA1.sethiding(!ShowFastEMALines);
plot EMA2 = ExpAverage(close, Ema2Length);
EMA2.SetDefaultColor(globalcolor("CloudDown"));
EMA2.HideBubble();
EMA2.sethiding(!ShowFastEMALines);
AddCloud(if ShowFastEMACloud then EMA1 else double.nan, if ShowFastEMACloud then EMA2 else double.nan, globalcolor("CloudUp"), globalcolor("CloudDown"));
plot EMA3 = ExpAverage(close, Ema3Length);
EMA3.SetDefaultColor(globalcolor("CloudUp"));
EMA3.HideBubble();
EMA3.sethiding(!ShowSlowEMALines);
plot EMA4 = ExpAverage(close, Ema4Length);
EMA4.SetDefaultColor(globalcolor("CloudDown"));
EMA4.HideBubble();
EMA4.sethiding(!ShowSlowEMALines);
AddCloud(if ShowSlowEMACloud then EMA3 else double.nan, if ShowSlowEMACloud then EMA4 else double.nan, globalcolor("CloudUp"), globalcolor("CloudDown"));

    #EMAS BULLISH OR BEARISH
    def EMABullish = EMA1 > EMA2;
    def EMABearish = EMA1 < EMA2;

        #EMA PERCENT SEPERATION
        def EMAPctBull = ((EMA1 / EMA2) * 100) - 100; #Distance Between EMA1 and EMA2
        def EMAPctBullRound = Round(EMAPctBull, 2);
        def EMAPctBear = ((EMA2 / EMA1) * 100) - 100; #Distance Between EMA2 and EMA1
        def EMAPctBearRound = Round(EMAPctBear, 2);

        #FAST EMA PERCENT SEPERATION BUY SIGNAL
        def EMASepThrHld;
        switch (TimeFrame) {
        case "1-min": EMASepThrHld = 0.1;
        case "10-Min": EMASepThrHld = 0.25;
        case "15-Min": EMASepThrHld = 0.25;
        case "30-Min": EMASepThrHld = 0.3;
        case "1-Hour": EMASepThrHld = 0.3;
        default: EMASepThrHld = 0.2;
        }

        def EMAPctBullish = EMAPctBullRound > EMASepThrHld and EMAPctBullRound >= EMAPctBullRound[1];
        def EMAPctBearish = EMAPctBearRound > EMASepThrHld and EMAPctBearRound >= EMAPctBearRound[1];
        #TESTING
        addchartbubble(ShowTestBubbles and EMAPctBullish, High * 1.005, EMAPctBullRound, color.dark_green, yes);
        addchartbubble(ShowTestBubbles and EMAPctBearish, Low * 0.995, EMAPctBearRound, color.dark_red, no);

            #EMA SELL SIGNALS
            def EMACrossDown = EMA1 crosses below EMA2;
            def EMACrossUp = EMA1 crosses above EMA2;

#TSI
input TSILongLength = 25;
input TSIShortLength = 13;
input TSISignalLength = 8;

def TSIDiff = close - close[1];
def DoubleSmoothedAbsDiff = ExpAverage(ExpAverage(AbsValue(TSIDiff), TSILongLength), TSIShortLength);
def TSIRound = Round((100 * (ExpAverage(ExpAverage(TSIDiff, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiff), 2);

    #TSI BUY SIGNAL
    def TSIBull = (TSIRound > TSIRound[2]); #(TSIRound > 10)
    def TSIBear = (TSIRound < TSIRound[2]); #(TSIRound < -10)

        #TSI SELL SIGNAL
        def TSICrossDown = TSIRound < (TSIRound[1] * 0.91);
        def TSICrossUp = TSIRound > (TSIRound[1] * 0.91);

#MACD
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;

def MACDValue = ExpAverage(close, MACDFast) - ExpAverage(close, MACDSlow);
def MACDAverage = ExpAverage(MACDValue, MACDLength);
def MACDDiff = MACDValue - MACDAverage;
def ZeroLine = 0;

    #MACD BUY SIGNAL
    def MACDBull = TSIRound > MACDAverage; #(MACDAverage > MACDAverage[1]) within 3 bars;
    def MACDBear = TSIRound < MACDAverage; #(MACDAverage < MACDAverage[1]) within 3 bars;

#TSI AND MACD SELL SIGNAL
def TSIMACDLongSell = TSIRound crosses below MACDAverage;
def TSIMACDShortSell = TSIRound crosses above MACDAverage;

##################################################################
#                          PREMARKET                             #
##################################################################
#PREMARKET HIGHS AND LOWS
def PreMarketTimeRange = secondsFromTime(PreMarketStart) >= 0 and secondsTillTime(PreMarketEnd) >= 0;
def PreMarket = PreMarketTimeRange and !PremarketTimeRange[1];
def Pre_Market_High = compoundValue(1, if((high > Pre_Market_High[1] and PremarketTimeRange) or PreMarket, high, Pre_Market_High[1]), high);
def Pre_Market_Low = compoundValue(1, if((low < Pre_Market_Low[1] and PremarketTImeRange) or PreMarket, low, Pre_Market_Low[1]), low);

plot PreMarketHigh = Pre_Market_High;
PreMarketHigh.SetStyle(curve.short_dash);
PreMarketHigh.SetDefaultColor(color.light_gray);
PreMarketHigh.Sethiding(!ShowPreMarketLines);
plot PreMarketLow = Pre_Market_Low;
PreMarketLow.SetStyle(curve.short_dash);
PreMarketLow.SetDefaultColor(color.light_gray);
PreMarketLow.Sethiding(!ShowPreMarketLines);
AddCloud(if ShowPreMarketCloud then PreMarketHigh else double.nan, if ShowPreMarketCloud then PreMarketLow else double.nan, color.light_gray, color.light_gray);

AddLabel(if ShowPreMarketLabel then yes else no, "   ", color.black);
AddLabel(if ShowPreMarketLabel then yes else no, " PM High - $" + PreMarketHigh + " ", color.gray);
AddLabel(if ShowPreMArketLabel then yes else no, " PM Low - $" + PreMarketLow + " ", color.gray);

    #PREMARKET HIGH/LOW BUY SIGNAL
    def PreMarketBull = close > Pre_Market_High;
    def PreMarketBear = close < Pre_Market_Low;

        #PREMARKET HIGH/LOW SELL SIGNAL
        def PreMarketBullSell = PreMarketBull[1] and low < Pre_Market_High;
        def PreMarketBearSell = PreMarketBear[1] and high > Pre_Market_Low;

##################################################################
#                      YESTERDAY HIGH/LOW                        #
##################################################################
plot PrevHigh = high(period = "day")[1];
PrevHigh.SetStyle(curve.medium_dash);
PrevHigh.SetDefaultColor(Color.GREEN);
PrevHigh.Sethiding(!ShowPrevDayLines);
plot PrevLow = low(period = "day")[1];
PrevLow.SetStyle(curve.medium_dash);
PrevLow.SetDefaultColor(Color.GREEN);
PrevLow.Sethiding(!ShowPrevDayLines);
AddCloud(if ShowPrevDayCloud then PrevHigh else double.nan, if ShowPrevDayCloud then PrevLow else double.nan, color.light_gray, color.light_gray);

AddLabel(if ShowPrevHighLowLabel then 1 else 0, "   ", color.black);
AddLabel(if ShowPrevHighLowLabel then 1 else 0, "Prev High " + "$ " + PrevHigh + " ", color.gray);
AddLabel(if ShowPrevHighLowLabel then 1 else 0, "Prev Low " + "$ " + PrevLow + " ", color.gray);

##################################################################
#                               SIGNALS                          #
##################################################################
#INDICATOR BUY SIGNALS
def LongBuyInd = TradingDay and EMABullish and EMAPctBullish and MACDBull and TSIBull and PreMarketBull;
def ShortBuyInd = TradingDay and EMABearish and EMAPctBearish and MACDBear and TSIBear and PreMarketBear;

plot LongEntryLine = if (LongBuyInd[1] or LongBuyInd[2]) and ShowDashes and LongBuyInd then EMA1[1] * 1.0025 else double.nan;
LongEntryLine.SetPaintingStrategy(PaintingStrategy.Dashes);
LongEntryLine.SetDefaultColor(color.white);
LongEntryLine.SetLineWeight(3);
plot ShortEntryLine = if (ShortBuyInd[1] or ShortBuyInd[2]) and ShowDashes and ShortBuyInd then EMA1[1] * 0.9975 else double.nan;
ShortEntryLine.SetPaintingStrategy(PaintingStrategy.Dashes);
ShortEntryLine.SetDefaultColor(color.white);
ShortEntryLine.SetLineWeight(3);

#INDICATOR ENTRY SIGNALS
def LongEntryInd = (LongBuyInd[1] or LongBuyInd[2]) and LongBuyInd and low <= (EMA1 * 1.0025);
def ShortEntryInd = (ShortBuyInd[1] or ShortBuyInd[2]) and ShortBuyInd and high >= (EMA1 * 0.9975);

#INDICATOR HOLD SIGNALS
def LongHoldInd = TradingDayExt and PreMarketBull and (LongBuyInd[1] or LongHoldInd[1]);
def ShortHoldInd = TradingDayExt and PreMarketBear and (ShortBuyInd[1] or ShortHoldInd[1]);

##################################################################
#         ADDED FAST EMA PCT HERE BASED OFF BUY SIGNAL           #
##################################################################
            def EMAPctAtLongBuy = if LongEntryInd then EMAPctBullRound else EMAPctAtLongBuy[1];
            def EMAPctAtShortBuy = if ShortEntryInd then EMAPctBearRound else EMAPctAtShortBuy[1];

                #FAST EMA CLOUD SELL TRIGGER BASED OFF BUY INDICATOR
                input EMAPctDecFromBuy = 0.6;
                def LongEMAPctSell = EMAPctBullRound < (EMAPctAtLongBuy * EMAPctDecFromBuy);
                def ShortEMAPctSell = EMAPctBearRound < (EMAPctAtShortBuy * EMAPctDecFromBuy);

##################################################################
#                         SIGNALS CONT.                          #
##################################################################
    #SELL SIGNALS
    def LongPriceActSell = low < low[4];
    def ShortPriceActSell = high > high[4];
    def LongSellInd = TradingDayExt and (close < open) and close < EMA1 and LongPriceActSell and close < EMA2 and (EMACrossDown or TSICrossDown or LongEMAPctSell or TSIMACDLongSell);
    def ShortSellInd = TradingDayExt and (close > open) and close > EMA1 and ShortPriceActSell and close > EMA2 and (EMACrossUp or TSICrossUp or ShortEMAPctSell or TSIMACDShortSell);
        #TESTING
        addchartbubble(ShowTestBubbles and TSICrossDown, High * 1.005, "T-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and TSICrossUp, Low * 0.995, "T-Up", color.dark_red, no);
        addchartbubble(ShowTestBubbles and EMACrossDown, High * 1.005, "E-X-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and EMACrossUp, Low * 0.995, "E-X-Up", color.dark_red, no);
        addchartbubble(ShowTestBubbles and LongEMAPctSell, High * 1.005, "E-Pct-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and SHortEMAPctSell, Low * 0.995, "E-Pct-Up", color.dark_red, no);

    #HOLD SIGNALS
    def LongHoldInd2 = LongHoldInd and !LongSellInd;
    def ShortHoldInd2 = ShortHoldInd and !ShortSellInd;

##################################################################
#                                 BARS                           #
##################################################################
AssignPriceColor(if LongBuyInd then GlobalColor("OpenLongPosition") else if ShortBuyInd then GlobalColor("OpenShortPosition") else if LongHoldInd2 then GlobalColor("HoldLongPosition") else if ShortHoldInd2 then GlobalColor("HoldShortPosition") else GlobalColor("CriteriaNotMet"));

##################################################################
# EMA TAKE PROFIT CLOUD (IDENTIFY IF PRICE IS EXTENDED FROM EMAS)#
##################################################################
            def OvrExtUp1 = if ShowOverExtCloud and SignalStart and TradingDayExt and (LongEntryInd or LongHoldInd2) then EMA1 * 1.01 else Double.NaN;
            def OvrExtUp2 = if ShowOverExtCloud and SignalStart and TradingDayExt and (LongEntryInd or LongHoldInd2) then EMA1 * 1.02 else Double.NaN;
            AddCloud(OvrExtUp1, OvrExtUp2, color.light_green, color.light_green);
            def OvrExtDn1 = if ShowOverExtCloud and SignalStart and TradingDayExt and (ShortEntryInd or ShortHoldInd2) then EMA1 * 0.99 else Double.NaN;
            def OvrExtDn2 = if ShowOverExtCloud and SignalStart and TradingDayExt and (ShortEntryInd or ShortHoldInd2) then EMA1 * 0.98 else Double.NaN;
            AddCloud(OvrExtDn1, OvrExtDn2, color.light_green, color.light_green);

##################################################################
#                                LABELS                          #
##################################################################
#LABELS
AddLabel(yes, "     ", color.black);
AddLabel(yes, "PREMKT", if PreMarketBull then GlobalColor("OpenLongPosition") else if PreMarketBear then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "CLOUD", if EMABullish then GlobalColor("OpenLongPosition") else if EMABearish then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "EMA SEP", if EMAPctBullish then GlobalColor("OpenLongPosition") else if EMAPctBearish then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "TSI", if TSIBull then GlobalColor("OpenLongPosition") else if TSIBear then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "MACD", if MACDBull then GlobalColor("OpenLongPosition") else if MACDBear then GlobalColor("OpenShortPosition") else color.gray);

##################################################################
#               CHART BUBBLES/POINTS FOR BUY/SELL                #
##################################################################
#BUY
def LongBuyBub = LongEntryInd;
addchartbubble(ShowBuySellBubbles and LongBuyBub, High * 1.005, "Long", color.green, yes);
def ShortBuyBub = ShortEntryInd;
addchartbubble(ShowBuySellBubbles and ShortBuyBub, Low * 0.995, "Short", color.red, no);

plot LongBuyPoint = if ShowArrows and LongBuyBub then EMA1[1] else double.nan;
LongBuyPoint.SetDefaultColor(color.white);
LongBuyPoint.SetPaintingStrategy(PaintingStrategy.Arrow_Up);
LongBuyPoint.SetLineWeight(5);
LongBuyPoint.HideBubble();
plot ShortBuyPoint = if ShowArrows and ShortBuyBub then EMA1[1] else double.nan;
ShortBuyPoint.SetDefaultColor(color.white);
ShortBuyPoint.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
ShortBuyPoint.SetLineWeight(5);
ShortBuyPoint.HideBubble();

#SELL
def LongSellBub = (LongEntryInd[1] or LongHoldInd2[1]) and (LongEntryInd[2] or LongHoldInd2[2]) and LongSellInd;
addchartbubble(ShowBuySellBubbles and LongSellBub, High * 1.005, "Sell", color.red, yes);
def ShortSellBub = (ShortEntryInd[1] or ShortHoldINd2[1]) and (ShortEntryInd[2] or ShortHoldINd2[2]) and ShortSellInd;
addchartbubble(ShowBuySellBubbles and ShortSellBub, Low * 0.995, "Sell", color.green, no);

plot LongSellPoint = if ShowSquares and LongSellBub then Close else double.nan;
LongSellPoint.SetDefaultColor(color.red);
LongSellPoint.SetPaintingStrategy(PaintingStrategy.Squares);
LongSellPoint.SetLineWeight(5);
LongSellPoint.HideBubble();
plot ShortSellPoint = if ShowSquares and ShortSellBub then Close else double.nan;
ShortSellPoint.SetDefaultColor(color.green);
ShortSellPoint.SetPaintingStrategy(PaintingStrategy.Squares);
ShortSellPoint.SetLineWeight(5);
ShortSellPoint.HideBubble();

#TAKE PROFIT
def LongTkPftBub = TradingDayExt and (LongEntryInd or LongHoldInd2) and high > EMA1 * 1.01;
addchartbubble(ShowTkPftBubble and LongTkPftBub, high * 1.001, "Tk Pft", GlobalColor("TakeProfit"), yes);
def ShortTkPftBub = TradingDayExt and (ShortEntryInd or ShortHoldInd2) and low < EMA1 * 0.99;
addchartbubble(ShowTkPftBubble and ShortTkPftBub, low * 0.999, "Tk Pft", GlobalColor("TakeProfit"), no);

plot LongTkPftPoint = if ShowBooleanArrows and LongTkPftBub then High else double.nan;
LongTkPftPoint.SetDefaultColor(GlobalColor("TakeProfit"));
LongTkPftPoint.SetPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
LongTkPftPoint.SetLineWeight(5);
LongTkPftPoint.HideBubble();
plot ShortTkPftPoint = if ShowBooleanArrows and ShortTkPftBub then Low else double.nan;
ShortTkPftPoint.SetDefaultColor(GlobalColor("TakeProfit"));
ShortTkPftPoint.SetPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
ShortTkPftPoint.SetLineWeight(5);
ShortTkPftPoint.HideBubble();

##################################################################
#                             STOP LOSS                          #
##################################################################
def longstop = if (open < close) then open else close;
def shortstop = if (open > close) then open else close;
addlabel(if (LongBuyInd or LongHoldInd2) then yes else no, "STOP $ " + longstop[4] + " ", color.white);
addlabel(if (ShortBuyInd or ShortHoldInd2) then yes else no, "STOP $ " + shortstop[4] + " ", color.white);

##################################################################
#                                ORDERS                          #
##################################################################
def orderQuantity = Round(10000 / open, 0);

#BUY ORDERS
AddOrder(OrderType.BUY_TO_OPEN, ShowOrders and LongEntryInd, EMA1 * 1.0025, 100, Color.GREEN, Color.LIGHT_GREEN);
AddOrder(OrderType.SELL_TO_OPEN, ShowOrders and ShortEntryInd, EMA1 * 0.9975, 100, Color.GREEN, Color.LIGHT_GREEN);

#SELL ORDERS
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and ShowTkPftOrders and LongTkPftBub, high * 0.999, 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and (LongSellInd or EndDay[-1]), open[-1], 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.BUY_TO_CLOSE, ShowOrders and ShowTkPftOrders and ShortTkPftBub, low * 1.001, 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.BUY_TO_CLOSE, ShowOrders and (ShortSellInd or EndDay[-1]), open[-1], 100, Color.RED, Color.LIGHT_RED);
##################################################################
#                                ALERTS                          #
##################################################################
Alert(AlertOn and (LongSellBub or ShortSellBub or LongTkPftBub or ShortTkPftBub), "SELL" + GetSymbol(), Alert.BAR, Sound.Bell);
Alert(AlertOn and (LongBuyInd or ShortBuyInd), "BUY" + GetSymbol(), Alert.BAR, Sound.Chimes);

##################################################################
#                       CANDLE COLOR LABEL                       #
##################################################################
AddLabel(if ShowColorDefLabels == 1 then yes else no, "     ", color.black);
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Long Ind", GlobalColor("OpenLongPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Long Hld", GlobalColor("HoldLongPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Short Ind", GlobalColor("OpenShortPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Short Hld", GlobalColor("HoldShortPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "No Criteria", GlobalColor("CriteriaNotMet"));

##################################################################
#                BACKGROUND COLOR FOR FLEX GRID                  #
##################################################################
AssignBackgroundColor(if ShowFlexGridBackgroundColor and LongBuyInd then GlobalColor("OpenLongPosition") else if ShowFlexGridBackgroundColor and ShortBuyInd then GlobalColor("OpenShortPosition") else if ShowFlexGridBackgroundColor and (LongTkPftBub or ShortTkPftBub) then GlobalColor("TakeProfit") else color.current);

And last but not least, my watchlist indicator. I only use this to visually tell me when to take a closer look at a stock. I have whittled down my watchlist to ones that I know move and have plenty of options flow. Make sure your watchlist study is set to 5 Min and Extended Hours are turned On.

The numbers mean nothing. It is just my way of sorting. You can change the labels to whatever you want in the bottom of the code under “Label”

You will only get a signal on the chart and the watchlist between 8:35 A.M. CST and 2:55 P.M. CST.

Code:
#JT Newest Strategy Based on EMAs, TSI, Premarket Highs/Lows, and MACD
#VERSION 10.3 - 05/26/2022

#Notes

##################################################################
#                                 TIMES                          #
##################################################################
#START AND END TIMES
def PreMarketStart = 0700; #EST
def PreMarketEnd = 0929; #EST
def StartTime = 0930; #EST
def BuySignalDelay = 0;
def EndTime = 1600; #EST
def BuySignalStop = 60; #Minutes Before End of Day
def LastCandleStop = 5; #Last Candle is Sell Candle


def TradingDayStart= SecondsFromTime(StartTime);
def BuySignalDelaySeconds = BuySignalDelay * 60;
def SignalStart = TradingDayStart > BuySignalDelaySeconds;
def TradingDayEnd = SecondsTillTime(EndTime);
def EndSignalDelaySeconds = BuySignalStop * 60;
def SignalEnd = TradingDayEnd > EndSignalDelaySeconds;
def TradingDay = SignalStart and SignalEnd; #10:00EST - 1500EST
def LastStopDelaySeconds = LastCandleStop * 60;
def EndDay = TradingDayEnd == LastStopDelaySeconds; #1550EST
def TradingDayExt = TradingDayEnd > LastStopDelaySeconds;

##################################################################
#                              INDICATORS                        #
##################################################################
#200 EMA
def EMA200 = ExpAverage(HL2, 200);

#EMAS
def Ema1Length = 5;
def Ema2Length = 12;

def EMA1 = ExpAverage(close, Ema1Length);
def EMA2 = ExpAverage(close, Ema2Length);

    #EMAS BULLISH OR BEARISH
    def EMABullish = EMA1 > EMA2;
    def EMABearish = EMA1 < EMA2;

        #EMA PERCENT SEPERATION
        def EMAPctBull = ((EMA1 / EMA2) * 100) - 100; #Distance Between EMA1 and EMA2
        def EMAPctBullRound = Round(EMAPctBull, 2);
        def EMAPctBear = ((EMA2 / EMA1) * 100) - 100; #Distance Between EMA2 and EMA1
        def EMAPctBearRound = Round(EMAPctBear, 2);

        def EMAPctBullish = EMAPctBullRound > 0.2 and EMAPctBullRound >= EMAPctBullRound[1];
        def EMAPctBearish = EMAPctBearRound > 0.2 and EMAPctBearRound >= EMAPctBearRound[1];

            #EMA SELL SIGNALS
            def EMACrossDown = EMA1 crosses below EMA2;
            def EMACrossUp = EMA1 crosses above EMA2;

#TSI
def TSILongLength = 25;
def TSIShortLength = 13;
def TSISignalLength = 8;

def TSIDiff = close - close[1];
def DoubleSmoothedAbsDiff = ExpAverage(ExpAverage(AbsValue(TSIDiff), TSILongLength), TSIShortLength);
def TSIRound = Round((100 * (ExpAverage(ExpAverage(TSIDiff, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiff), 2);

    #TSI BUY SIGNAL
    def TSIBull = (TSIRound > TSIRound[2]); #(TSIRound > 10)
    def TSIBear = (TSIRound < TSIRound[2]); #(TSIRound < -10)

        #TSI SELL SIGNAL
        def TSICrossDown = TSIRound < (TSIRound[1] * 0.91);
        def TSICrossUp = TSIRound > (TSIRound[1] * 0.91);

#MACD
def MACDFast = 10;
def MACDSlow = 22;
def MACDLength = 8;

def MACDValue = ExpAverage(close, MACDFast) - ExpAverage(close, MACDSlow);
def MACDAverage = ExpAverage(MACDValue, MACDLength);
def MACDDiff = MACDValue - MACDAverage;
def ZeroLine = 0;

    #MACD BUY SIGNAL
    def MACDBull = TSIRound > MACDAverage; #(MACDAverage > MACDAverage[1]) within 3 bars;
    def MACDBear = TSIRound < MACDAverage; #(MACDAverage < MACDAverage[1]) within 3 bars;

#TSI AND MACD SELL SIGNAL
def TSIMACDLongSell = TSIRound crosses below MACDAverage;
def TSIMACDShortSell = TSIRound crosses above MACDAverage;

##################################################################
#                          PREMARKET                             #
##################################################################
#PREMARKET HIGHS AND LOWS
def PreMarketTimeRange = secondsFromTime(PreMarketStart) >= 0 and secondsTillTime(PreMarketEnd) >= 0;
def PreMarket = PreMarketTimeRange and !PremarketTimeRange[1];
def Pre_Market_High = compoundValue(1, if((high > Pre_Market_High[1] and PremarketTimeRange) or PreMarket, high, Pre_Market_High[1]), high);
def Pre_Market_Low = compoundValue(1, if((low < Pre_Market_Low[1] and PremarketTImeRange) or PreMarket, low, Pre_Market_Low[1]), low);

def PreMarketHigh = Pre_Market_High;
def PreMarketLow = Pre_Market_Low;

    #PREMARKET HIGH/LOW BUY SIGNAL
    def PreMarketBull = close > Pre_Market_High;
    def PreMarketBear = close < Pre_Market_Low;

        #PREMARKET HIGH/LOW SELL SIGNAL
        def PreMarketBullSell = PreMarketBull[1] and low < Pre_Market_High;
        def PreMarketBearSell = PreMarketBear[1] and high > Pre_Market_Low;

##################################################################
#                               SIGNALS                          #
##################################################################
#INDICATOR BUY SIGNALS
def LongBuyInd = TradingDay and EMABullish and EMAPctBullish and MACDBull and TSIBull and PreMarketBull;
def ShortBuyInd = TradingDay and EMABearish and EMAPctBearish and MACDBear and TSIBear and PreMarketBear;

#INDICATOR ENTRY SIGNALS
def LongEntryInd = (LongBuyInd[1] or LongBuyInd[2]) and LongBuyInd and low <= (EMA1 * 1.0025);
def ShortEntryInd = (ShortBuyInd[1] or ShortBuyInd[2]) and ShortBuyInd and high >= (EMA1 * 0.9975);

#INDICATOR HOLD SIGNALS
def LongHoldInd = TradingDayExt and PreMarketBull and (LongBuyInd[1] or LongHoldInd[1]);
def ShortHoldInd = TradingDayExt and PreMarketBear and (ShortBuyInd[1] or ShortHoldInd[1]);

##################################################################
#         ADDED FAST EMA PCT HERE BASED OFF BUY SIGNAL           #
##################################################################
            def EMAPctAtLongBuy = if LongEntryInd then EMAPctBullRound else EMAPctAtLongBuy[1];
            def EMAPctAtShortBuy = if ShortEntryInd then EMAPctBearRound else EMAPctAtShortBuy[1];

                #FAST EMA CLOUD SELL TRIGGER BASED OFF BUY INDICATOR
                def LongEMAPctSell = EMAPctBullRound < (EMAPctAtLongBuy * 0.6);
                def ShortEMAPctSell = EMAPctBearRound < (EMAPctAtShortBuy * 0.6);

##################################################################
#                         SIGNALS CONT.                          #
##################################################################
    #SELL SIGNALS
    def LongPriceActSell = low < low[4];
    def ShortPriceActSell = high > high[4];
    def LongSellInd = TradingDayExt and (close < open) and (EMACrossDown or TSICrossDown or LongEMAPctSell or LongPriceActSell or TSIMACDLongSell);
    def ShortSellInd = TradingDayExt and (close > open) and (EMACrossUp or TSICrossUp or ShortEMAPctSell or ShortPriceActSell or TSIMACDShortSell);

    #HOLD SIGNALS
    def LongHoldInd2 = LongHoldInd and !LongSellInd;
    def ShortHoldInd2 = ShortHoldInd and !ShortSellInd;

##################################################################
#               CHART BUBBLES/POINTS FOR BUY/SELL                #
##################################################################
#TAKE PROFIT
def LongTkPftBub = TradingDayExt and (LongEntryInd or LongHoldInd2) and high > EMA1 * 1.01;
def ShortTkPftBub = TradingDayExt and (ShortEntryInd or ShortHoldInd2) and low < EMA1 * 0.99;

##################################################################
#                        WATCHLIST INDICATOR                     #
##################################################################

#LABEL
AddLabel(yes, if LongBuyInd then "1. LONG" else if LongHoldInd2 then "4. LONG HOLD" else if ShortBuyInd then "2. SHORT" else if ShortHoldInd2 then "5. SHORT HOLD" else if LongTkPftBub or ShortTkPftBub then "3. TAKE PROFIT" else "6. NO GO");

#BACKGROUND
AssignBackgroundColor(if LongBuyInd then createcolor (0, 255, 0) else if LongHoldInd2 then createcolor (153, 255, 153) else if ShortBuyInd then createcolor (255, 0, 0) else if ShortHoldInd2 then createcolor (255, 153, 153) else if LongTkPftBub or ShortTkPftBub then createcolor (255, 0, 255) else createcolor (102, 102, 102));

What can go wrong....?

See the chart below. You will notice green candles which means all criteria to buy are met EXCEPT the price being within the defined range of the 5EMA. Because the price is extended, you didn't get a white arrow. If you FOMO'd in, get out on the pink boolean arrow. You will notice after 5 minutes the price sharply reverses down and below the 5EMA. The price eventually normalizes and starts a gradual uptrend. You would do your best to enter on the candle with the white arrow, as close as possible to the 5EMA and definitely below the white dash. You would then wait for a grey candle to completely close and then exit at the open of the following candle.

I didn't just pull that over extended cloud out of nowhere. That was me looking at multiple charts and coming up with the best number (probably has something to do with other algos).

To the right is what it's supposed to look like.

pMKSTHK.png


Some light backtesting here. This is over 90 days and BEFORE I backtested with the pink boolean arrows.

3ntuPXd.png


If you happen to have something of value to add please don't hesitate to post that here. This is however about 6 months of trial and error in the making.

###################################################################################
This is how I trade personally. Do whatever you want with this information.

Step 1. Before pre-market opens if I am awake. I look at the futures to get an idea of the direction of the market and VIX futures. So I am following the rules of the site. Here are the links to the two watchlist columns below. Not pertinent at this point. MT5 - http://tos.mx/4hzwiEn MT30 - http://tos.mx/45R1EOH

zOppDP6.png


Step 2. Look at my watchlist throughout the premarket to get an idea on what is running or what sectors may be in play. This comes with experience. I am strictly looking at percent gain or percent loss.

Step 3. Pick a few stocks that I think I want to trade. That may be based on news, pre-market action, recent earnings, some Elon Must Twitter post etc. I want something that is going to move! I would highly prefer that it move with the sector and with the futures and/or index it's trading in.

Step 4. Look at the daily charts of the tickers that you like. This is my main screen and what I traded today 5/31/22. My thought was that OXY would go down because the price was so extended from the 5EMA on the daily chart. (I scrolled to the premarket to show what I saw. Obviously can't do that with the daily candle.) More to come on those histograms on the bottom. TSI and MACD Line - http://tos.mx/91sbV6M and TSI and MACD Histogram - http://tos.mx/5fBU0TW

aUbuwkO.png


Step 5. Wait for your bias to play out or admit that you're wrong and look for another opportunity.

Step 6. Review the Chart Below for what I saw around 0910 CST. My direction is correct but I don't quite like that the 30 minute is not there yet. Lets wait a bit... In the mean time lets get a price target. $68 Put looks good because that is where the 5EMA is at. Be patient.

qkuM3WT.png


Step 7. 30 Minute Histogram is nearing 0 and still declining. I'm about ready to enter but I have to wait on the white arrow to appear and buy as close to the 5EMA as possible.

PePd0IY.png


Step 8. Now I switch to my flex grid where I have the 5 minute, 30 minute, 5 minute option that I want to buy, and active trader up. That way I am ready to pounce when the signal hits.

eKz2Pg7.png


Step 9. Buy. Don't hesitate. You did the work, now follow through! I entered at $0.45 per contract.

Step 10. Wait for your Exit. You could have exited on the pink boolean candle on the 30 minute chart. I did not. Profits would have been about the same.

s1tKG47.png


Step 11. Take your 150% profit and enjoy your day!
Thank you so much for your work. Is there a way to turn off the color of the candles? Most of my candles are gray on my 10 min. chart. Also can I change it to 8 min? Thanks
 
I have Vs 10 which was showing I think I'm experiencing a "DUH!" moment.

I have charts set at 1 day/ 10 min but when I press for backtesting I am not getting any signals showing and when I go to report it reads

Work Time : 8/17/94, 2:12 AM - 12/2/65, 11:47 AM

This is different from what showed previously.I don't believe I reset anything but maybe I inadvertently did, Do any ideas to correct this come to mind?

Thank you in advance!
 
Current Version 10.4 - 05/31/2022

Strategy Link: http://tos.mx/P3mxTl4 (Click Setup, Open Shared Item, Paste the Link)

Alternatively, to use the strategy code below (not the link above) click on the charts tab, studies button, edit studies, strategies tab, create, copy and paste the first code in and change the name at the top to your liking, click ok. Make sure to follow the rules on the first post regarding time frame, extended hours etc.

Watchlist Indicator: http://tos.mx/KDtke7m (Click Setup, Open Shared Item, Paste the Link)

For the watchlist custom indicator (again, the code is below not the link above) click the gear icon on your watchlist, customize, type in “custom”, click the small scroll looking icon to the left of an unused custom study, paste the second code in and change the name to your liking (something short), change the “D” to “5m” and check extended hours, click ok.

Flexible Grid Link: http://tos.mx/duZrCez

This is just the preview. More detailed instructions below.

dCW8nQm.png


I WILL ADD ALL UPDATES HERE! This strategy is changing and I don’t want to confuse anyone with comments from previous versions in the post below!!!

This is months of trial and error with different strategies and indicators. This is what I have found that works best as of today. I am continually updating this strategy to refine it and/or find better entries and exits. All updates will be posted here on Post #1.

This strategy USES two EMAs (5EMA, 12EMA), MACD, TSI, and Pre-Market High/Low. The EMAs are arranged in a cloud (5EMA / 12EMA). This strategy also INCLUDES but does not USE the 34EMA, 50EMA, and Yesterdays High/Low. These can be turned on and off to your liking.

The triggers I am using are:
  • Buy Signal only between 8:35 A.M. CST until 2:00 P.M. CST (This can be changed to fit your needs)
  • EMAs Bullish (5EMA>12EMA) or EMAs Bearish (5EMA<12EMA)
  • MACD Trending Up or MACD Trending Down
  • TSI >10 and trending up or TSI <-10 and trending down
  • Low > the Pre-Market High or High < the Pre-Market Low
Again, subject to change.

Of note, I use this for options so the wording I use in the strategy is geared towards that.
  • Gray Candles - Criteria Not Met
  • Red Candle - Put Buy or Sell to Open (Short) (Entry is on the 5EMA or When you get the Buy Bubble)
  • Light Red Candle - Put Hold or Short Hold
  • Green Candle - Call Buy or Buy to Open (Long) (Entry is on 5EMA or when you get the Buy Bubble)
  • Light Green Candle - Call Hold or Long Hold
Candle colors can be changed using the gear icon, scrolling to the very bottom and changing the "globals" settings.

Very basic instructions...
  • If you FOMO in at the beginning of the day without a buy signal, which you shouldn't, and you get a Pink Boolean Arrow than GET OUT! The price is too extended from the EMA and you are just asked for a knife candle to kill your profits.
  • If you were patient and waited on the Buy Signal (white arrow) then get in on that 5EMA (green dashed line) or better. Alternatively, if you missed your entry, then try to get in at least on the white dash or better. This was the entry point from the previous candle.
    • You should not get a Buy Signal unless the price is already within the defined range of the 5EMA.
    • If you are confident in your order placing abilities and the spread isn't too wide you can even set a trailing stop buy order to try to get the best price.
  • If you get a Pink Boolean Arrow then again, really think about taking profits.
    • This is a great spot for a trailing stop depending on the spread!
  • If you get a Grey Candle than get ready to close your trade at the open of the next bar. Don't get in a hurry though because sometimes the candle will repaint and continue with your trend.
  • Rinse and Repeat. Don't Get Fancy! Let It work or move on to a stock that is working!
The difference in my trading waiting on that 5EMA entry was a game changer. In options, if I rushed into a trade that gave me a buy signal before it came back to the 5EMA I might be down 50% within seconds before maybe recovering. However, if I wait on that 5 EMA entry I may never be down or at worst 15%-20% before becoming profitable.

I added labels to the top of the chart for each criteria this strategy is looking for. This will help you "get ready" to buy. If they are all red then get ready to go short or buy puts on that 5EMA. If they are all green than again, get ready to go long or buy calls on that 5EMA.

I THINK the labels should go green/blue from left to right if the stock cooperates. I have noticed that the biggest thing holding up the entry is MACD direction and price at the 5EMA at the same time but then again, that is what makes it mostly* dependable.

Once you are in the trade you can stop looking at the labels. At that point you are just waiting for the grey candle or pink boolean arrow for your exit.

WIth that being said, be careful with options and this study! I chose my stocks based on my 2+ years of trading experience and look at support/resistance to chose the right strike. I am excited about this strategy because every single backtest I ran on every ticker on my watchlist was profitable over the past 10 days when trading 100 shares at a time.

Few Rules:
  • To be used on 5 minute charts. That is all I have tested it on.
  • Must have Extended Hours on and I prefer 3 Day / 5 Min zoomed in.
  • Copy the code and paste it as a STRATEGY not study.
  • If you so choose, turn on the "Over Ext Clouds". That is a take profit spot where you would get the pink boolean arrow.
There is no scanner yet but some users are trying to create one that works (one or two are floating around the comments now). I use a flexible grid with 16 charts and load the tickers that I am looking at that particular day. This allows for the fastest response for me personally. Link at the top.

BDt0hOg.png


Code:
#JT Newest Strategy Based on EMAs, TSI, Premarket Highs/Lows, and MACD
#VERSION 10.4 - 05/31/2022

#Notes

Declare Upper;

##################################################################
#                                OPTIONS                         #
##################################################################
input ShowTestBubbles = no;
input ShowFlexGridBackgroundColor = no;
input ShowColorDefLabels = yes;
input AlertOn = yes;
input Show200EMA = no;
input ShowFastEMALines = no;
input ShowFastEMACloud = no;
input ShowSlowEMALines = no;
input ShowSlowEMACloud = no;
input ShowPreMarketLines = no;
input ShowPreMarketCloud = no;
input ShowPreMarketLabel = yes;
input ShowPrevDayLines = no;
input ShowPrevDayCloud = no;
input ShowPrevHighLowLabel = no;
input ShowBuySellBubbles = no;
input ShowArrows = yes;
input ShowSquares = yes;
input ShowDashes = yes;
input ShowBooleanArrows = yes;
input ShowOverExtCloud = no;
input ShowTkPftBubble = no;
input ShowOrders = no;
input ShowTkPftOrders = no;

##################################################################
#                                COLORS                          #
##################################################################
DefineGlobalColor("200EMA", createcolor (255, 255, 255));
DefineGlobalColor("CloudUp", createcolor (102, 255, 102));
DefineGlobalColor("CloudDown", createcolor (255, 102, 102));
DefineGlobalColor("OpenLongPosition", createcolor (0, 255, 0));
DefineGlobalColor("OpenShortPosition", createcolor (255, 0, 0));
DefineGlobalColor("HoldLongPosition", createcolor (153, 255, 153));
DefineGlobalColor("HoldShortPosition", createcolor (255, 153, 153));
DefineGlobalColor("SellPosition", createcolor (255, 0, 0));
DefineGlobalColor("TakeProfit", createcolor (255, 0, 255));
DefineGlobalColor("CriteriaNotMet", createcolor (102, 102, 102)); #(255, 255, 0)

##################################################################
#                                 TIMES                          #
##################################################################
#START AND END TIMES
input TimeFrame = {default "5-Min", "1-Min", "10-Min", "15-Min", "30-Min", "1-Hour"};
input PreMarketStart = 0700; #EST
input PreMarketEnd = 0929; #EST
input StartTime = 0930; #EST
input BuySignalDelay = 0;
input EndTime = 1600; #EST
input BuySignalStop = 60; #Minutes Before End of Day
def LastCandleStop; #Last Candle is Sell Candle

        switch (TimeFrame) {
        case "1-min": LastCandleStop = 1;
        case "10-Min": LastCandleStop = 10;
        case "15-Min": LastCandleStop = 15;
        case "30-Min": LastCandleStop = 30;
        case "1-Hour": LastCandleStop = 60;
        default: LastCandleStop = 5;
        }

def TradingDayStart= SecondsFromTime(StartTime);
def BuySignalDelaySeconds = BuySignalDelay * 60;
def SignalStart = TradingDayStart > BuySignalDelaySeconds;
def TradingDayEnd = SecondsTillTime(EndTime);
def EndSignalDelaySeconds = BuySignalStop * 60;
def SignalEnd = TradingDayEnd > EndSignalDelaySeconds;
def TradingDay = SignalStart and SignalEnd; #10:00EST - 1500EST
def LastStopDelaySeconds = LastCandleStop * 60;
def EndDay = TradingDayEnd == LastStopDelaySeconds; #1550EST
def TradingDayExt = TradingDayEnd > LastStopDelaySeconds;

##################################################################
#                              INDICATORS                        #
##################################################################
#200 EMA
plot EMA200 = ExpAverage(HL2, 200);
EMA200.SetDefaultColor(globalcolor("200EMA"));
EMA200.HideBubble();
EMA200.sethiding(!Show200EMA);

#EMAS
input Ema1Length = 5;
input Ema2Length = 12;
input Ema3Length = 34;
input Ema4Length = 50;

plot EMA1 = ExpAverage(close, Ema1Length);
EMA1.SetStyle(Curve.Short_Dash);
EMA1.SetDefaultColor(globalcolor("CloudUp"));
EMA1.HideBubble();
#EMA1.sethiding(!ShowFastEMALines);
plot EMA2 = ExpAverage(close, Ema2Length);
EMA2.SetDefaultColor(globalcolor("CloudDown"));
EMA2.HideBubble();
EMA2.sethiding(!ShowFastEMALines);
AddCloud(if ShowFastEMACloud then EMA1 else double.nan, if ShowFastEMACloud then EMA2 else double.nan, globalcolor("CloudUp"), globalcolor("CloudDown"));
plot EMA3 = ExpAverage(close, Ema3Length);
EMA3.SetDefaultColor(globalcolor("CloudUp"));
EMA3.HideBubble();
EMA3.sethiding(!ShowSlowEMALines);
plot EMA4 = ExpAverage(close, Ema4Length);
EMA4.SetDefaultColor(globalcolor("CloudDown"));
EMA4.HideBubble();
EMA4.sethiding(!ShowSlowEMALines);
AddCloud(if ShowSlowEMACloud then EMA3 else double.nan, if ShowSlowEMACloud then EMA4 else double.nan, globalcolor("CloudUp"), globalcolor("CloudDown"));

    #EMAS BULLISH OR BEARISH
    def EMABullish = EMA1 > EMA2;
    def EMABearish = EMA1 < EMA2;

        #EMA PERCENT SEPERATION
        def EMAPctBull = ((EMA1 / EMA2) * 100) - 100; #Distance Between EMA1 and EMA2
        def EMAPctBullRound = Round(EMAPctBull, 2);
        def EMAPctBear = ((EMA2 / EMA1) * 100) - 100; #Distance Between EMA2 and EMA1
        def EMAPctBearRound = Round(EMAPctBear, 2);

        #FAST EMA PERCENT SEPERATION BUY SIGNAL
        def EMASepThrHld;
        switch (TimeFrame) {
        case "1-min": EMASepThrHld = 0.1;
        case "10-Min": EMASepThrHld = 0.25;
        case "15-Min": EMASepThrHld = 0.25;
        case "30-Min": EMASepThrHld = 0.3;
        case "1-Hour": EMASepThrHld = 0.3;
        default: EMASepThrHld = 0.2;
        }

        def EMAPctBullish = EMAPctBullRound > EMASepThrHld and EMAPctBullRound >= EMAPctBullRound[1];
        def EMAPctBearish = EMAPctBearRound > EMASepThrHld and EMAPctBearRound >= EMAPctBearRound[1];
        #TESTING
        addchartbubble(ShowTestBubbles and EMAPctBullish, High * 1.005, EMAPctBullRound, color.dark_green, yes);
        addchartbubble(ShowTestBubbles and EMAPctBearish, Low * 0.995, EMAPctBearRound, color.dark_red, no);

            #EMA SELL SIGNALS
            def EMACrossDown = EMA1 crosses below EMA2;
            def EMACrossUp = EMA1 crosses above EMA2;

#TSI
input TSILongLength = 25;
input TSIShortLength = 13;
input TSISignalLength = 8;

def TSIDiff = close - close[1];
def DoubleSmoothedAbsDiff = ExpAverage(ExpAverage(AbsValue(TSIDiff), TSILongLength), TSIShortLength);
def TSIRound = Round((100 * (ExpAverage(ExpAverage(TSIDiff, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiff), 2);

    #TSI BUY SIGNAL
    def TSIBull = (TSIRound > TSIRound[2]); #(TSIRound > 10)
    def TSIBear = (TSIRound < TSIRound[2]); #(TSIRound < -10)

        #TSI SELL SIGNAL
        def TSICrossDown = TSIRound < (TSIRound[1] * 0.91);
        def TSICrossUp = TSIRound > (TSIRound[1] * 0.91);

#MACD
input MACDFast = 10;
input MACDSlow = 22;
input MACDLength = 8;

def MACDValue = ExpAverage(close, MACDFast) - ExpAverage(close, MACDSlow);
def MACDAverage = ExpAverage(MACDValue, MACDLength);
def MACDDiff = MACDValue - MACDAverage;
def ZeroLine = 0;

    #MACD BUY SIGNAL
    def MACDBull = TSIRound > MACDAverage; #(MACDAverage > MACDAverage[1]) within 3 bars;
    def MACDBear = TSIRound < MACDAverage; #(MACDAverage < MACDAverage[1]) within 3 bars;

#TSI AND MACD SELL SIGNAL
def TSIMACDLongSell = TSIRound crosses below MACDAverage;
def TSIMACDShortSell = TSIRound crosses above MACDAverage;

##################################################################
#                          PREMARKET                             #
##################################################################
#PREMARKET HIGHS AND LOWS
def PreMarketTimeRange = secondsFromTime(PreMarketStart) >= 0 and secondsTillTime(PreMarketEnd) >= 0;
def PreMarket = PreMarketTimeRange and !PremarketTimeRange[1];
def Pre_Market_High = compoundValue(1, if((high > Pre_Market_High[1] and PremarketTimeRange) or PreMarket, high, Pre_Market_High[1]), high);
def Pre_Market_Low = compoundValue(1, if((low < Pre_Market_Low[1] and PremarketTImeRange) or PreMarket, low, Pre_Market_Low[1]), low);

plot PreMarketHigh = Pre_Market_High;
PreMarketHigh.SetStyle(curve.short_dash);
PreMarketHigh.SetDefaultColor(color.light_gray);
PreMarketHigh.Sethiding(!ShowPreMarketLines);
plot PreMarketLow = Pre_Market_Low;
PreMarketLow.SetStyle(curve.short_dash);
PreMarketLow.SetDefaultColor(color.light_gray);
PreMarketLow.Sethiding(!ShowPreMarketLines);
AddCloud(if ShowPreMarketCloud then PreMarketHigh else double.nan, if ShowPreMarketCloud then PreMarketLow else double.nan, color.light_gray, color.light_gray);

AddLabel(if ShowPreMarketLabel then yes else no, "   ", color.black);
AddLabel(if ShowPreMarketLabel then yes else no, " PM High - $" + PreMarketHigh + " ", color.gray);
AddLabel(if ShowPreMArketLabel then yes else no, " PM Low - $" + PreMarketLow + " ", color.gray);

    #PREMARKET HIGH/LOW BUY SIGNAL
    def PreMarketBull = close > Pre_Market_High;
    def PreMarketBear = close < Pre_Market_Low;

        #PREMARKET HIGH/LOW SELL SIGNAL
        def PreMarketBullSell = PreMarketBull[1] and low < Pre_Market_High;
        def PreMarketBearSell = PreMarketBear[1] and high > Pre_Market_Low;

##################################################################
#                      YESTERDAY HIGH/LOW                        #
##################################################################
plot PrevHigh = high(period = "day")[1];
PrevHigh.SetStyle(curve.medium_dash);
PrevHigh.SetDefaultColor(Color.GREEN);
PrevHigh.Sethiding(!ShowPrevDayLines);
plot PrevLow = low(period = "day")[1];
PrevLow.SetStyle(curve.medium_dash);
PrevLow.SetDefaultColor(Color.GREEN);
PrevLow.Sethiding(!ShowPrevDayLines);
AddCloud(if ShowPrevDayCloud then PrevHigh else double.nan, if ShowPrevDayCloud then PrevLow else double.nan, color.light_gray, color.light_gray);

AddLabel(if ShowPrevHighLowLabel then 1 else 0, "   ", color.black);
AddLabel(if ShowPrevHighLowLabel then 1 else 0, "Prev High " + "$ " + PrevHigh + " ", color.gray);
AddLabel(if ShowPrevHighLowLabel then 1 else 0, "Prev Low " + "$ " + PrevLow + " ", color.gray);

##################################################################
#                               SIGNALS                          #
##################################################################
#INDICATOR BUY SIGNALS
def LongBuyInd = TradingDay and EMABullish and EMAPctBullish and MACDBull and TSIBull and PreMarketBull;
def ShortBuyInd = TradingDay and EMABearish and EMAPctBearish and MACDBear and TSIBear and PreMarketBear;

plot LongEntryLine = if (LongBuyInd[1] or LongBuyInd[2]) and ShowDashes and LongBuyInd then EMA1[1] * 1.0025 else double.nan;
LongEntryLine.SetPaintingStrategy(PaintingStrategy.Dashes);
LongEntryLine.SetDefaultColor(color.white);
LongEntryLine.SetLineWeight(3);
plot ShortEntryLine = if (ShortBuyInd[1] or ShortBuyInd[2]) and ShowDashes and ShortBuyInd then EMA1[1] * 0.9975 else double.nan;
ShortEntryLine.SetPaintingStrategy(PaintingStrategy.Dashes);
ShortEntryLine.SetDefaultColor(color.white);
ShortEntryLine.SetLineWeight(3);

#INDICATOR ENTRY SIGNALS
def LongEntryInd = (LongBuyInd[1] or LongBuyInd[2]) and LongBuyInd and low <= (EMA1 * 1.0025);
def ShortEntryInd = (ShortBuyInd[1] or ShortBuyInd[2]) and ShortBuyInd and high >= (EMA1 * 0.9975);

#INDICATOR HOLD SIGNALS
def LongHoldInd = TradingDayExt and PreMarketBull and (LongBuyInd[1] or LongHoldInd[1]);
def ShortHoldInd = TradingDayExt and PreMarketBear and (ShortBuyInd[1] or ShortHoldInd[1]);

##################################################################
#         ADDED FAST EMA PCT HERE BASED OFF BUY SIGNAL           #
##################################################################
            def EMAPctAtLongBuy = if LongEntryInd then EMAPctBullRound else EMAPctAtLongBuy[1];
            def EMAPctAtShortBuy = if ShortEntryInd then EMAPctBearRound else EMAPctAtShortBuy[1];

                #FAST EMA CLOUD SELL TRIGGER BASED OFF BUY INDICATOR
                input EMAPctDecFromBuy = 0.6;
                def LongEMAPctSell = EMAPctBullRound < (EMAPctAtLongBuy * EMAPctDecFromBuy);
                def ShortEMAPctSell = EMAPctBearRound < (EMAPctAtShortBuy * EMAPctDecFromBuy);

##################################################################
#                         SIGNALS CONT.                          #
##################################################################
    #SELL SIGNALS
    def LongPriceActSell = low < low[4];
    def ShortPriceActSell = high > high[4];
    def LongSellInd = TradingDayExt and (close < open) and close < EMA1 and LongPriceActSell and close < EMA2 and (EMACrossDown or TSICrossDown or LongEMAPctSell or TSIMACDLongSell);
    def ShortSellInd = TradingDayExt and (close > open) and close > EMA1 and ShortPriceActSell and close > EMA2 and (EMACrossUp or TSICrossUp or ShortEMAPctSell or TSIMACDShortSell);
        #TESTING
        addchartbubble(ShowTestBubbles and TSICrossDown, High * 1.005, "T-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and TSICrossUp, Low * 0.995, "T-Up", color.dark_red, no);
        addchartbubble(ShowTestBubbles and EMACrossDown, High * 1.005, "E-X-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and EMACrossUp, Low * 0.995, "E-X-Up", color.dark_red, no);
        addchartbubble(ShowTestBubbles and LongEMAPctSell, High * 1.005, "E-Pct-Dn", color.dark_green, yes);
        addchartbubble(ShowTestBubbles and SHortEMAPctSell, Low * 0.995, "E-Pct-Up", color.dark_red, no);

    #HOLD SIGNALS
    def LongHoldInd2 = LongHoldInd and !LongSellInd;
    def ShortHoldInd2 = ShortHoldInd and !ShortSellInd;

##################################################################
#                                 BARS                           #
##################################################################
AssignPriceColor(if LongBuyInd then GlobalColor("OpenLongPosition") else if ShortBuyInd then GlobalColor("OpenShortPosition") else if LongHoldInd2 then GlobalColor("HoldLongPosition") else if ShortHoldInd2 then GlobalColor("HoldShortPosition") else GlobalColor("CriteriaNotMet"));

##################################################################
# EMA TAKE PROFIT CLOUD (IDENTIFY IF PRICE IS EXTENDED FROM EMAS)#
##################################################################
            def OvrExtUp1 = if ShowOverExtCloud and SignalStart and TradingDayExt and (LongEntryInd or LongHoldInd2) then EMA1 * 1.01 else Double.NaN;
            def OvrExtUp2 = if ShowOverExtCloud and SignalStart and TradingDayExt and (LongEntryInd or LongHoldInd2) then EMA1 * 1.02 else Double.NaN;
            AddCloud(OvrExtUp1, OvrExtUp2, color.light_green, color.light_green);
            def OvrExtDn1 = if ShowOverExtCloud and SignalStart and TradingDayExt and (ShortEntryInd or ShortHoldInd2) then EMA1 * 0.99 else Double.NaN;
            def OvrExtDn2 = if ShowOverExtCloud and SignalStart and TradingDayExt and (ShortEntryInd or ShortHoldInd2) then EMA1 * 0.98 else Double.NaN;
            AddCloud(OvrExtDn1, OvrExtDn2, color.light_green, color.light_green);

##################################################################
#                                LABELS                          #
##################################################################
#LABELS
AddLabel(yes, "     ", color.black);
AddLabel(yes, "PREMKT", if PreMarketBull then GlobalColor("OpenLongPosition") else if PreMarketBear then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "CLOUD", if EMABullish then GlobalColor("OpenLongPosition") else if EMABearish then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "EMA SEP", if EMAPctBullish then GlobalColor("OpenLongPosition") else if EMAPctBearish then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "TSI", if TSIBull then GlobalColor("OpenLongPosition") else if TSIBear then GlobalColor("OpenShortPosition") else color.gray);
AddLabel(yes, "MACD", if MACDBull then GlobalColor("OpenLongPosition") else if MACDBear then GlobalColor("OpenShortPosition") else color.gray);

##################################################################
#               CHART BUBBLES/POINTS FOR BUY/SELL                #
##################################################################
#BUY
def LongBuyBub = LongEntryInd;
addchartbubble(ShowBuySellBubbles and LongBuyBub, High * 1.005, "Long", color.green, yes);
def ShortBuyBub = ShortEntryInd;
addchartbubble(ShowBuySellBubbles and ShortBuyBub, Low * 0.995, "Short", color.red, no);

plot LongBuyPoint = if ShowArrows and LongBuyBub then EMA1[1] else double.nan;
LongBuyPoint.SetDefaultColor(color.white);
LongBuyPoint.SetPaintingStrategy(PaintingStrategy.Arrow_Up);
LongBuyPoint.SetLineWeight(5);
LongBuyPoint.HideBubble();
plot ShortBuyPoint = if ShowArrows and ShortBuyBub then EMA1[1] else double.nan;
ShortBuyPoint.SetDefaultColor(color.white);
ShortBuyPoint.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
ShortBuyPoint.SetLineWeight(5);
ShortBuyPoint.HideBubble();

#SELL
def LongSellBub = (LongEntryInd[1] or LongHoldInd2[1]) and (LongEntryInd[2] or LongHoldInd2[2]) and LongSellInd;
addchartbubble(ShowBuySellBubbles and LongSellBub, High * 1.005, "Sell", color.red, yes);
def ShortSellBub = (ShortEntryInd[1] or ShortHoldINd2[1]) and (ShortEntryInd[2] or ShortHoldINd2[2]) and ShortSellInd;
addchartbubble(ShowBuySellBubbles and ShortSellBub, Low * 0.995, "Sell", color.green, no);

plot LongSellPoint = if ShowSquares and LongSellBub then Close else double.nan;
LongSellPoint.SetDefaultColor(color.red);
LongSellPoint.SetPaintingStrategy(PaintingStrategy.Squares);
LongSellPoint.SetLineWeight(5);
LongSellPoint.HideBubble();
plot ShortSellPoint = if ShowSquares and ShortSellBub then Close else double.nan;
ShortSellPoint.SetDefaultColor(color.green);
ShortSellPoint.SetPaintingStrategy(PaintingStrategy.Squares);
ShortSellPoint.SetLineWeight(5);
ShortSellPoint.HideBubble();

#TAKE PROFIT
def LongTkPftBub = TradingDayExt and (LongEntryInd or LongHoldInd2) and high > EMA1 * 1.01;
addchartbubble(ShowTkPftBubble and LongTkPftBub, high * 1.001, "Tk Pft", GlobalColor("TakeProfit"), yes);
def ShortTkPftBub = TradingDayExt and (ShortEntryInd or ShortHoldInd2) and low < EMA1 * 0.99;
addchartbubble(ShowTkPftBubble and ShortTkPftBub, low * 0.999, "Tk Pft", GlobalColor("TakeProfit"), no);

plot LongTkPftPoint = if ShowBooleanArrows and LongTkPftBub then High else double.nan;
LongTkPftPoint.SetDefaultColor(GlobalColor("TakeProfit"));
LongTkPftPoint.SetPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
LongTkPftPoint.SetLineWeight(5);
LongTkPftPoint.HideBubble();
plot ShortTkPftPoint = if ShowBooleanArrows and ShortTkPftBub then Low else double.nan;
ShortTkPftPoint.SetDefaultColor(GlobalColor("TakeProfit"));
ShortTkPftPoint.SetPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
ShortTkPftPoint.SetLineWeight(5);
ShortTkPftPoint.HideBubble();

##################################################################
#                             STOP LOSS                          #
##################################################################
def longstop = if (open < close) then open else close;
def shortstop = if (open > close) then open else close;
addlabel(if (LongBuyInd or LongHoldInd2) then yes else no, "STOP $ " + longstop[4] + " ", color.white);
addlabel(if (ShortBuyInd or ShortHoldInd2) then yes else no, "STOP $ " + shortstop[4] + " ", color.white);

##################################################################
#                                ORDERS                          #
##################################################################
def orderQuantity = Round(10000 / open, 0);

#BUY ORDERS
AddOrder(OrderType.BUY_TO_OPEN, ShowOrders and LongEntryInd, EMA1 * 1.0025, 100, Color.GREEN, Color.LIGHT_GREEN);
AddOrder(OrderType.SELL_TO_OPEN, ShowOrders and ShortEntryInd, EMA1 * 0.9975, 100, Color.GREEN, Color.LIGHT_GREEN);

#SELL ORDERS
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and ShowTkPftOrders and LongTkPftBub, high * 0.999, 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.SELL_TO_CLOSE, ShowOrders and (LongSellInd or EndDay[-1]), open[-1], 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.BUY_TO_CLOSE, ShowOrders and ShowTkPftOrders and ShortTkPftBub, low * 1.001, 100, Color.RED, Color.LIGHT_RED);
AddOrder(OrderType.BUY_TO_CLOSE, ShowOrders and (ShortSellInd or EndDay[-1]), open[-1], 100, Color.RED, Color.LIGHT_RED);
##################################################################
#                                ALERTS                          #
##################################################################
Alert(AlertOn and (LongSellBub or ShortSellBub or LongTkPftBub or ShortTkPftBub), "SELL" + GetSymbol(), Alert.BAR, Sound.Bell);
Alert(AlertOn and (LongBuyInd or ShortBuyInd), "BUY" + GetSymbol(), Alert.BAR, Sound.Chimes);

##################################################################
#                       CANDLE COLOR LABEL                       #
##################################################################
AddLabel(if ShowColorDefLabels == 1 then yes else no, "     ", color.black);
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Long Ind", GlobalColor("OpenLongPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Long Hld", GlobalColor("HoldLongPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Short Ind", GlobalColor("OpenShortPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "Short Hld", GlobalColor("HoldShortPosition"));
AddLabel(if ShowColorDefLabels == 1 then yes else no, "No Criteria", GlobalColor("CriteriaNotMet"));

##################################################################
#                BACKGROUND COLOR FOR FLEX GRID                  #
##################################################################
AssignBackgroundColor(if ShowFlexGridBackgroundColor and LongBuyInd then GlobalColor("OpenLongPosition") else if ShowFlexGridBackgroundColor and ShortBuyInd then GlobalColor("OpenShortPosition") else if ShowFlexGridBackgroundColor and (LongTkPftBub or ShortTkPftBub) then GlobalColor("TakeProfit") else color.current);

And last but not least, my watchlist indicator. I only use this to visually tell me when to take a closer look at a stock. I have whittled down my watchlist to ones that I know move and have plenty of options flow. Make sure your watchlist study is set to 5 Min and Extended Hours are turned On.

The numbers mean nothing. It is just my way of sorting. You can change the labels to whatever you want in the bottom of the code under “Label”

You will only get a signal on the chart and the watchlist between 8:35 A.M. CST and 2:55 P.M. CST.

Code:
#JT Newest Strategy Based on EMAs, TSI, Premarket Highs/Lows, and MACD
#VERSION 10.3 - 05/26/2022

#Notes

##################################################################
#                                 TIMES                          #
##################################################################
#START AND END TIMES
def PreMarketStart = 0700; #EST
def PreMarketEnd = 0929; #EST
def StartTime = 0930; #EST
def BuySignalDelay = 0;
def EndTime = 1600; #EST
def BuySignalStop = 60; #Minutes Before End of Day
def LastCandleStop = 5; #Last Candle is Sell Candle


def TradingDayStart= SecondsFromTime(StartTime);
def BuySignalDelaySeconds = BuySignalDelay * 60;
def SignalStart = TradingDayStart > BuySignalDelaySeconds;
def TradingDayEnd = SecondsTillTime(EndTime);
def EndSignalDelaySeconds = BuySignalStop * 60;
def SignalEnd = TradingDayEnd > EndSignalDelaySeconds;
def TradingDay = SignalStart and SignalEnd; #10:00EST - 1500EST
def LastStopDelaySeconds = LastCandleStop * 60;
def EndDay = TradingDayEnd == LastStopDelaySeconds; #1550EST
def TradingDayExt = TradingDayEnd > LastStopDelaySeconds;

##################################################################
#                              INDICATORS                        #
##################################################################
#200 EMA
def EMA200 = ExpAverage(HL2, 200);

#EMAS
def Ema1Length = 5;
def Ema2Length = 12;

def EMA1 = ExpAverage(close, Ema1Length);
def EMA2 = ExpAverage(close, Ema2Length);

    #EMAS BULLISH OR BEARISH
    def EMABullish = EMA1 > EMA2;
    def EMABearish = EMA1 < EMA2;

        #EMA PERCENT SEPERATION
        def EMAPctBull = ((EMA1 / EMA2) * 100) - 100; #Distance Between EMA1 and EMA2
        def EMAPctBullRound = Round(EMAPctBull, 2);
        def EMAPctBear = ((EMA2 / EMA1) * 100) - 100; #Distance Between EMA2 and EMA1
        def EMAPctBearRound = Round(EMAPctBear, 2);

        def EMAPctBullish = EMAPctBullRound > 0.2 and EMAPctBullRound >= EMAPctBullRound[1];
        def EMAPctBearish = EMAPctBearRound > 0.2 and EMAPctBearRound >= EMAPctBearRound[1];

            #EMA SELL SIGNALS
            def EMACrossDown = EMA1 crosses below EMA2;
            def EMACrossUp = EMA1 crosses above EMA2;

#TSI
def TSILongLength = 25;
def TSIShortLength = 13;
def TSISignalLength = 8;

def TSIDiff = close - close[1];
def DoubleSmoothedAbsDiff = ExpAverage(ExpAverage(AbsValue(TSIDiff), TSILongLength), TSIShortLength);
def TSIRound = Round((100 * (ExpAverage(ExpAverage(TSIDiff, TSILongLength), TSIShortLength)) / DoubleSmoothedAbsDiff), 2);

    #TSI BUY SIGNAL
    def TSIBull = (TSIRound > TSIRound[2]); #(TSIRound > 10)
    def TSIBear = (TSIRound < TSIRound[2]); #(TSIRound < -10)

        #TSI SELL SIGNAL
        def TSICrossDown = TSIRound < (TSIRound[1] * 0.91);
        def TSICrossUp = TSIRound > (TSIRound[1] * 0.91);

#MACD
def MACDFast = 10;
def MACDSlow = 22;
def MACDLength = 8;

def MACDValue = ExpAverage(close, MACDFast) - ExpAverage(close, MACDSlow);
def MACDAverage = ExpAverage(MACDValue, MACDLength);
def MACDDiff = MACDValue - MACDAverage;
def ZeroLine = 0;

    #MACD BUY SIGNAL
    def MACDBull = TSIRound > MACDAverage; #(MACDAverage > MACDAverage[1]) within 3 bars;
    def MACDBear = TSIRound < MACDAverage; #(MACDAverage < MACDAverage[1]) within 3 bars;

#TSI AND MACD SELL SIGNAL
def TSIMACDLongSell = TSIRound crosses below MACDAverage;
def TSIMACDShortSell = TSIRound crosses above MACDAverage;

##################################################################
#                          PREMARKET                             #
##################################################################
#PREMARKET HIGHS AND LOWS
def PreMarketTimeRange = secondsFromTime(PreMarketStart) >= 0 and secondsTillTime(PreMarketEnd) >= 0;
def PreMarket = PreMarketTimeRange and !PremarketTimeRange[1];
def Pre_Market_High = compoundValue(1, if((high > Pre_Market_High[1] and PremarketTimeRange) or PreMarket, high, Pre_Market_High[1]), high);
def Pre_Market_Low = compoundValue(1, if((low < Pre_Market_Low[1] and PremarketTImeRange) or PreMarket, low, Pre_Market_Low[1]), low);

def PreMarketHigh = Pre_Market_High;
def PreMarketLow = Pre_Market_Low;

    #PREMARKET HIGH/LOW BUY SIGNAL
    def PreMarketBull = close > Pre_Market_High;
    def PreMarketBear = close < Pre_Market_Low;

        #PREMARKET HIGH/LOW SELL SIGNAL
        def PreMarketBullSell = PreMarketBull[1] and low < Pre_Market_High;
        def PreMarketBearSell = PreMarketBear[1] and high > Pre_Market_Low;

##################################################################
#                               SIGNALS                          #
##################################################################
#INDICATOR BUY SIGNALS
def LongBuyInd = TradingDay and EMABullish and EMAPctBullish and MACDBull and TSIBull and PreMarketBull;
def ShortBuyInd = TradingDay and EMABearish and EMAPctBearish and MACDBear and TSIBear and PreMarketBear;

#INDICATOR ENTRY SIGNALS
def LongEntryInd = (LongBuyInd[1] or LongBuyInd[2]) and LongBuyInd and low <= (EMA1 * 1.0025);
def ShortEntryInd = (ShortBuyInd[1] or ShortBuyInd[2]) and ShortBuyInd and high >= (EMA1 * 0.9975);

#INDICATOR HOLD SIGNALS
def LongHoldInd = TradingDayExt and PreMarketBull and (LongBuyInd[1] or LongHoldInd[1]);
def ShortHoldInd = TradingDayExt and PreMarketBear and (ShortBuyInd[1] or ShortHoldInd[1]);

##################################################################
#         ADDED FAST EMA PCT HERE BASED OFF BUY SIGNAL           #
##################################################################
            def EMAPctAtLongBuy = if LongEntryInd then EMAPctBullRound else EMAPctAtLongBuy[1];
            def EMAPctAtShortBuy = if ShortEntryInd then EMAPctBearRound else EMAPctAtShortBuy[1];

                #FAST EMA CLOUD SELL TRIGGER BASED OFF BUY INDICATOR
                def LongEMAPctSell = EMAPctBullRound < (EMAPctAtLongBuy * 0.6);
                def ShortEMAPctSell = EMAPctBearRound < (EMAPctAtShortBuy * 0.6);

##################################################################
#                         SIGNALS CONT.                          #
##################################################################
    #SELL SIGNALS
    def LongPriceActSell = low < low[4];
    def ShortPriceActSell = high > high[4];
    def LongSellInd = TradingDayExt and (close < open) and (EMACrossDown or TSICrossDown or LongEMAPctSell or LongPriceActSell or TSIMACDLongSell);
    def ShortSellInd = TradingDayExt and (close > open) and (EMACrossUp or TSICrossUp or ShortEMAPctSell or ShortPriceActSell or TSIMACDShortSell);

    #HOLD SIGNALS
    def LongHoldInd2 = LongHoldInd and !LongSellInd;
    def ShortHoldInd2 = ShortHoldInd and !ShortSellInd;

##################################################################
#               CHART BUBBLES/POINTS FOR BUY/SELL                #
##################################################################
#TAKE PROFIT
def LongTkPftBub = TradingDayExt and (LongEntryInd or LongHoldInd2) and high > EMA1 * 1.01;
def ShortTkPftBub = TradingDayExt and (ShortEntryInd or ShortHoldInd2) and low < EMA1 * 0.99;

##################################################################
#                        WATCHLIST INDICATOR                     #
##################################################################

#LABEL
AddLabel(yes, if LongBuyInd then "1. LONG" else if LongHoldInd2 then "4. LONG HOLD" else if ShortBuyInd then "2. SHORT" else if ShortHoldInd2 then "5. SHORT HOLD" else if LongTkPftBub or ShortTkPftBub then "3. TAKE PROFIT" else "6. NO GO");

#BACKGROUND
AssignBackgroundColor(if LongBuyInd then createcolor (0, 255, 0) else if LongHoldInd2 then createcolor (153, 255, 153) else if ShortBuyInd then createcolor (255, 0, 0) else if ShortHoldInd2 then createcolor (255, 153, 153) else if LongTkPftBub or ShortTkPftBub then createcolor (255, 0, 255) else createcolor (102, 102, 102));

What can go wrong....?

See the chart below. You will notice green candles which means all criteria to buy are met EXCEPT the price being within the defined range of the 5EMA. Because the price is extended, you didn't get a white arrow. If you FOMO'd in, get out on the pink boolean arrow. You will notice after 5 minutes the price sharply reverses down and below the 5EMA. The price eventually normalizes and starts a gradual uptrend. You would do your best to enter on the candle with the white arrow, as close as possible to the 5EMA and definitely below the white dash. You would then wait for a grey candle to completely close and then exit at the open of the following candle.

I didn't just pull that over extended cloud out of nowhere. That was me looking at multiple charts and coming up with the best number (probably has something to do with other algos).

To the right is what it's supposed to look like.

pMKSTHK.png


Some light backtesting here. This is over 90 days and BEFORE I backtested with the pink boolean arrows.

3ntuPXd.png


If you happen to have something of value to add please don't hesitate to post that here. This is however about 6 months of trial and error in the making.

###################################################################################
This is how I trade personally. Do whatever you want with this information.

Step 1. Before pre-market opens if I am awake. I look at the futures to get an idea of the direction of the market and VIX futures. So I am following the rules of the site. Here are the links to the two watchlist columns below. Not pertinent at this point. MT5 - http://tos.mx/4hzwiEn MT30 - http://tos.mx/45R1EOH

zOppDP6.png


Step 2. Look at my watchlist throughout the premarket to get an idea on what is running or what sectors may be in play. This comes with experience. I am strictly looking at percent gain or percent loss.

Step 3. Pick a few stocks that I think I want to trade. That may be based on news, pre-market action, recent earnings, some Elon Must Twitter post etc. I want something that is going to move! I would highly prefer that it move with the sector and with the futures and/or index it's trading in.

Step 4. Look at the daily charts of the tickers that you like. This is my main screen and what I traded today 5/31/22. My thought was that OXY would go down because the price was so extended from the 5EMA on the daily chart. (I scrolled to the premarket to show what I saw. Obviously can't do that with the daily candle.) More to come on those histograms on the bottom. TSI and MACD Line - http://tos.mx/91sbV6M and TSI and MACD Histogram - http://tos.mx/5fBU0TW

aUbuwkO.png


Step 5. Wait for your bias to play out or admit that you're wrong and look for another opportunity.

Step 6. Review the Chart Below for what I saw around 0910 CST. My direction is correct but I don't quite like that the 30 minute is not there yet. Lets wait a bit... In the mean time lets get a price target. $68 Put looks good because that is where the 5EMA is at. Be patient.

qkuM3WT.png


Step 7. 30 Minute Histogram is nearing 0 and still declining. I'm about ready to enter but I have to wait on the white arrow to appear and buy as close to the 5EMA as possible.

PePd0IY.png


Step 8. Now I switch to my flex grid where I have the 5 minute, 30 minute, 5 minute option that I want to buy, and active trader up. That way I am ready to pounce when the signal hits.

eKz2Pg7.png


Step 9. Buy. Don't hesitate. You did the work, now follow through! I entered at $0.45 per contract.

Step 10. Wait for your Exit. You could have exited on the pink boolean candle on the 30 minute chart. I did not. Profits would have been about the same.

s1tKG47.png


Step 11. Take your 150% profit and enjoy your day!
@a1cturner Thanks so much for all of your hard work and sharing this. I will test it on paper tomorrow and see how I do.
I have a question about a comparison of your setting to mine. I have followed your instructions as close as I could and I am not getting some signals that you are getting. For instance, The chart just under step 8 where you show that you bought, I do not get that white arrow or the dashed line there. My Hist and TSI is different as well. I believe I am on the exact time frame and date. Do you have any idea what I may have wrong?
See below.
MIECi0F.jpg
 
Has anyone had any good wins recently with this?
I have only made 3 trades in the last three weeks. Been busy. And in all honesty I didn’t use this strategy as I was away from my computer. I strictly traded AMZN when it hit its support/resistance. Trying to find time to get back into this while also trying to learn PineScript
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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