/ES Index Futures Scalping System for ThinkorSwim

@barbaros
I am not a programmer. Is there a way to set backtesting to a specific number of points?
This is a backtest of his study without any modifications.

In real life, I use his entry signals but as I said, I use my own exit points.
The Thursday and Friday signals were extremely profitable.
I skipped Monday and Today's as my strategy signaled they were not good setups.
 

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

@MerryDay I don't have details of the script you are using, but you can set your specific exit target and stoploss target with something like this. Caution, I have not tested the code below. Idea is when you put your actual order in, it would execute at the next bar open with OCO. Since the OCO targets can get hit within that bar, you can execute the close targets in that bar looking forward. If this doesn't work, you can take out the [-1] and try. Again, I have not tested this and writing it from my iPad :)

Python:
# Profit Target and Stoploss for long
addOrder(OrderType.SELL_TO_CLOSE, close[-1] >= EntryPrice()[-1] + 1, name = "Close Long");
addOrder(OrderType.SELL_TO_CLOSE, close[-1] <= EntryPrice()[-1] - 4, name = "Close Long Stop");

# Profit Target and Stoploss for short
addOrder(OrderType.BUY_TO_CLOSE, close[-1] <= EntryPrice()[-1] - 1, name = "Close Short");
addOrder(OrderType.BUY_TO_CLOSE, close[-1] >= EntryPrice()[-1] + 4, name = "Close Short Stop");
 
Last edited:
@MerryDay I don't have details of the script you are using, but you can set your specific exit target and stoploss target with something like this. Caution, I have not tested the code below. Idea is when you put your actual order in, it would execute at the next bar open with OCO. Since the OCO targets can get hit within that bar, you can execute the close targets in that bar looking forward. If this doesn't work, you can take out the [-1] and try. Again, I have not tested this and writing it from my iPad :)

Python:
# Profit Target and Stoploss for long
addOrder(OrderType.SELL_TO_CLOSE, close[-1] >= EntryPrice()[-1] + 1, name = "Close Long");
addOrder(OrderType.SELL_TO_CLOSE, close[-1] <= EntryPrice()[-1] - 4, name = "Close Long Stop");

# Profit Target and Stoploss for short
addOrder(OrderType.BUY_TO_CLOSE, close[-1] <= EntryPrice()[-1] - 1, name = "Close Short");
addOrder(OrderType.BUY_TO_CLOSE, close[-1] >= EntryPrice()[-1] + 4, name = "Close Short Stop");
To the best of my knowledge, EntryPrice() is EntryPrice() and shouldn't require nor should it accept [-1]... And, unless I'm mistaken, it doesn't work with backtesting... Do you have information to the contrary...???
 
To the best of my knowledge, EntryPrice() is EntryPrice() and shouldn't require nor should it accept [-1]... And, unless I'm mistaken, it doesn't work with backtesting... Do you have information to the contrary...???

Now that I am in front of my computer so I run it for errors, you are correct that you cannot reference the function without dereferencing the result into a variable.

Here is a sample test. It exits if it hits the target or the stop loss in either direction.

Python:
def sma9 = reference SimpleMovingAvg(close, 9);
def entryPrice = EntryPrice();

# Long entry
addOrder(OrderType.BUY_TO_OPEN, close crosses above sma9);

# Profit Target and Stoploss for long
addOrder(OrderType.SELL_TO_CLOSE, close[-1] >= entryPrice[-1] + 1, name = "Close Long", price = entryPrice[-1] + 1);
addOrder(OrderType.SELL_TO_CLOSE, close[-1] <= entryPrice[-1] - 4, name = "Close Long Stop", price = entryPrice[-1] - 4);

# Short entry
addOrder(OrderType.SELL_TO_OPEN, close crosses below sma9);

# Profit Target and Stoploss for short
addOrder(OrderType.BUY_TO_CLOSE, close[-1] <= entryPrice[-1] - 1, name = "Close Short", price = entryPrice[-1] - 1);
addOrder(OrderType.BUY_TO_CLOSE, close[-1] >= entryPrice[-1] + 4, name = "Close Short Stop", price =  entryPrice[-1] + 4);

For @MerryDay's reference, it becomes

Code:
def entryPrice = EntryPrice();

# Profit Target and Stoploss for long
addOrder(OrderType.SELL_TO_CLOSE, close[-1] >= entryPrice[-1] + 1, name = "Close Long", price = entryPrice[-1] + 1);
addOrder(OrderType.SELL_TO_CLOSE, close[-1] <= entryPrice[-1] - 4, name = "Close Long Stop", price = entryPrice[-1] - 4);

# Profit Target and Stoploss for short
addOrder(OrderType.BUY_TO_CLOSE, close[-1] <= entryPrice[-1] - 1, name = "Close Short", price = entryPrice[-1] - 1);
addOrder(OrderType.BUY_TO_CLOSE, close[-1] >= entryPrice[-1] + 4, name = "Close Short Stop", price =  entryPrice[-1] + 4);

There is a catch with this though. There are cases where the stoploss is too small and price movement is highly volatile, it could have hit the stoploss in the candle before turning around and hitting the profit target. The order of the exit entries favor the profit target.
 
Last edited:
@barbaros Looks good...!!! (y) I had to look back at a few of my Strategies to remember that I had used EntryPrice() in a few AddOrder() calls... 🧐 I stand corrected... ;) I hope old age isn't setting in... :cautious:
 
Hi Benten,
Is there a way to incorporate this into a watchlist with two columns 1 for Up green arrow and 1 for down red arrow. This way i can get in on it quickly rather than watching the graph all day and waiting for alerts..
 
@barbaros
The Indicator works exactly as Mobius said:
with clear signals and 60% or better win rate

As I mentioned only one setup was signaled at mid-morning today and the ROI wasn't worth it.
LcrB7Jc.png
Hi How are you getting those labels total trades etc. Also can you share your set up. Thanks
 
Hi Benten,
Is there a way to incorporate this into a watchlist with two columns 1 for Up green arrow and 1 for down red arrow. This way i can get in on it quickly rather than watching the graph all day and waiting for alerts..

One thing to remember is that Custom Watchlist Column refreshes lag by 3 - 7 minutes, or thereabouts, regardless of the timeframe setting you use for the Watchlist Column... That means a signal showing on a Chart may not be reflected in the Watchlist for said 3 - 7 minutes... Are you ok with missing an entry by that many minutes...???
 
One thing to remember is that Custom Watchlist Column refreshes lag by 3 - 7 minutes, or thereabouts, regardless of the timeframe setting you use for the Watchlist Column... That means a signal showing on a Chart may not be reflected in the Watchlist for said 3 - 7 minutes... Are you ok with missing an entry by that many minutes...???
Oh wow .. i didnt realize it would lag by that much .. I was looking for a way for it to flash whenever the up or down arrow is true.
 
I don't fully understand how to use this indicator. Mobius noted that you should feel comfortable pulling the trigger as soon as you see the arrow, but the arrows repaint midbar, meaning they appear and disappear. Sometimes they flicker on and off several times. It's intriguing but I'm not sure how to use it exactly.
 
I don't fully understand how to use this indicator. Mobius noted that you should feel comfortable pulling the trigger as soon as you see the arrow, but the arrows repaint midbar, meaning they appear and disappear. Sometimes they flicker on and off several times. It's intriguing but I'm not sure how to use it exactly.

Combine this indicator with another one for further confirmation... Either that or base confirmation on price action... No one indicator is accurate enough to rely on by itself... I have customized indicators to have arrows and they may flicker but there are usually at least two other indicators to provide added confirmation, and that's without even looking at the upper chart panel itself where there are more indicators... You can't have too much confirmation but you have to balance confirmations without producing too much clutter...
 
Thanks so much BenTen for all you do and contribute on this forum. I have been using the Mobius Futures Scalper indicator for a while in combination with others for setups and confirmations. However, the ALERT sounding issue has been bothering me, as I have tried all combinations including your script above. The ALERT simply will not sound. At this point even if we cannot get your Alert script to work, as it logically should, I want to know what is keeping the Alerts from sounding. I have tried almost everything. Getting Alert to work would be great. Knowing why they won't, with your script would be the next best thing adding to my coding knowledge. Anyone's help would be greatly appreciated.
 
Thanks so much BenTen for all you do and contribute on this forum. I have been using the Mobius Futures Scalper indicator for a while in combination with others for setups and confirmations. However, the ALERT sounding issue has been bothering me, as I have tried all combinations including your script above. The ALERT simply will not sound. At this point even if we cannot get your Alert script to work, as it logically should, I want to know what is keeping the Alerts from sounding. I have tried almost everything. Getting Alert to work would be great. Knowing why they won't, with your script would be the next best thing adding to my coding knowledge. Anyone's help would be greatly appreciated.
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58010
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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