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

Sorry just noticed I screwed up the background color code when I was getting color changes on my main chart. Corrections have been made and posted along with updated link.
 
Okay I got the Version 8 up in Post #1. The link has also been updated.

I made the following changes. Sorry if I didn't get to yours yet. I DID NOT make any changes to the watchlist code.

  • Added The Ability to Turn Off PreMarket High/Low Cloud
  • Added Labels for PreMarket High/Low with Ability to Turn On/Off
  • Changed the Global Color of Tk Pft to Pink (can be changed by user)
  • Added the ability of Background Color Change to Match Bubble (Used in FlexGrid), Default if Off.
  • Added different time frames. This controls the EMA Seperation Threshold and Last Sell Candle.
- Disclaimer. I quickly tested the EMA Seperation Thresholds on 1, 5, 10, 15, 30, and 60 minute time frames. No guarantee on signals or that they won't be a little early. I ran out of time. If you see an issue please let me know.​
If you want to use this on different time frames than you will have to change the first setting here:

NTzwDC1.png


I'll probably be off-line for the weekend but please don't hesitate to keep sending those suggested changes and/or problems

** I just noticed the profit/loss label does not work correctly on other time frames. Not really a big deal right now but I will look into it.Showing a $109,112.78 profit on TSLA on the 1-Min Chart, lol
Afternoon.

Just wanted to pass along an observation I noticed in both versions 7 and 8. If one decides to change "show buy sell bubbles" to No, it will disable "show tk pft bubble" despite it showing Yes.

Other than that, thank you for continuously making this a better strategy!
 
I noticed my pre-market time was set to 0730. Not real sure why I set it to that time, lol. Would y'all rather have it at 0400 or 0700? This will make a difference on some tickers depending on any crazy "pre" pre-market action. Does anyone have an opinion about that because I don't really know what professional traders would use.
 
Thanks again for all the hard work on this strategy. I've done well this week with it. I've noticed a few things back testing though.

1. I've removed CallBuy and PutBuy from the AddOrder to stop it from triggering a buy on the first red or blue candle to get a more accurate back test. Its like this now
#BUY ORDERS
AddOrder(OrderType.BUY_TO_OPEN, ShowOrders and (CallBuy[1] or CallBuy[2])or CallBuy[3] and low <= FastEMA1 and low >= FastEMA2, FastEMA1, 100, Color.GREEN, Color.LIGHT_GREEN);
AddOrder(OrderType.SELL_TO_OPEN, ShowOrders and (PutBuy[1] or PutBuy[2] or PutBuy[3]) and high >= FastEMA1 and high <=FastEMA2, FastEMA1, 100, Color.GREEN, Color.LIGHT_GREEN);
2. The AddOrder will trigger up to 3 candles after a Green or Blue candle even if a red candle appears. Can this be coded to reset once a red candle appears?
3. Also once a trade starts if the candle turn grey before red it will continue with a big loss. Can this be coded to sell on a grey candle as well?
I changed the entry orders to CallBuyBub and PutBuyBub because I assumed it would make the most sense. I then realized that some of my sell indicators are not working properly. Looking at VZ I get a TSICrossDown and a CallEMAPctSell but neither triggers a red candle or obviously a SellOrder. This is going to take a lot of trial and error since this code is getting so long. Any help would be appreciated.
 
Last edited:
Version 8b posted with updated code and link. Still haven't touched the watchlist.

Changes include:

Changed the EMA Percent Sell Threshold from the time of a Buy Signal to 0.5 from 0.65
Added a Parameter that CallBuyBubble must be a (CallBuy or CallHold) Candle or (PutBuy or PutHold) Candle. Basically it cannot be grey.

This fixed the order problem for the VZ chart that someone mentioned as well as an order I noticed on TSLA back on 12/21/2021.

There is still a problem that I cannot pinpoint with the sell signals. It doesn't seem to affect most charts but I want the code to be perfect so I will keep working on it. If anyone smarter than me wants to take a look they can change the CallEMAPctSell on line 232 and PutEMAPctSell on line 235 back to 0.65 and turn the orders on. Then go look at VZ on 4/21/2022 at 0940 CST. You will notice a buy order but it's not followed by a sell order until the end of the day even though there is a 65% decrease in EMA Separation, TSI crosses back below 10, and EMA1 crosses below EMA2 (all my sell signals)
 
@Fluideng What day is this for SHOP?

Just to make it easy look at VZ yesterday. 10 min. chart.
Thanks,
@Fluideng I think I fixed the VZ problem. I posted the updated code tonight. Let me know if you see other issues. (I think I just put a band-aid on it but we shall see)
 
Version 9 posted in Post #1

#Changed the EMA Percent Sell Threshold from Buy Signal to 0.5 from 0.65
#Added a Parameter that CallBuyBubble must be a (CallBuy or CallHold) Candle or (PutBuy or PutHold) Candle. Basically it cannot be grey
#Changed !CallSell to !CallSellInd and !PutSell to !PutSellInd which fixed the sell candle not appearing
#Changed the EMA Percent Sell Threshold back to 0.65
#Added the ability to turn off EMA clouds. User still has to turn the plot off in the plots tab
#Added the ability for the user to change the EMA Percent Sell Threshold from default "EMAPctDecFromBuy"
 
  • Like
Reactions: rfb
how to avoid like this ..

TSLA ( Today )

p_2309mxra01.png
You don’t. This isn’t a perfect strategy and honestly TSLA is very hard to trade. That was probably a $1-$2 loss so in the grand scheme of things that’s not too bad. Backtest on TSLA show an approximate $165,000 gain over 6 months so I’d just take the loss and continue looking for opportunities. This isn’t the average trade with this strategy.
 
You don’t. This isn’t a perfect strategy and honestly TSLA is very hard to trade. That was probably a $1-$2 loss so in the grand scheme of things that’s not too bad. Backtest on TSLA show an approximate $165,000 gain over 6 months so I’d just take the loss and continue looking for opportunities. This isn’t the average trade with this strategy.
Also look at the higher time frame analysis. 30 min. 1 and 4 hour charts all in a down trend.
 
To avoid trading against the trend, besides many available studies, I use one built-in study called TTM_LRC on a 2 HR chart to see the overall trend and use a 10-minute chart for trading. I avoid against the trend trades to avoid losses and as a general rule, if my portfolio drops below 5% from the point in time I started the trades, I close all trades and I do not trade that day.
This current study yields good results/profits on a daily basis and serves its purpose better than any other strategy, that I have used so far. We just need to be a bit careful. Hope this helps.
TTM_LRC is built-in the TOS.
 
Last edited:
I have posted an updated and hopefully better functioning watchlist indicator in Post #1. You won't see very many (if any) visual changes and it may or may not show "loading" but it will better match the changes made to the strategy. I have removed every possible line and changed all inputs to def, removed all bubbles, and removed all labels so HOPEFULLY it doesn’t show loading anymore. Fingers crossed it works better.

Don’t think I can code a setting to allow users to change the colors, sorry.
 
Last edited:
What is different between 1,5.10 minutes
In rules to buy and sell are all the same reule
The EMA Separation Threshold. It is the difference between the 5EMA and 12EMA. There are different thresholds for different time frames. Also the last candle will always be a sell candle so I had to define what the last candle was depending on the time frame.
 

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
535 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