Macro Recorder Questions For ThinkOrSwim

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

@billionmetrics - i use it on a Mac. Once you get passed the admin set up portion (follow the MR website) works perfectly fine. I am actually trying to tune it to do multiple stocks at once now.

@METAL @dap711 - have you gents had any luck setting MR logic to run charts at once ? Assuming both are on the same timeframe ?
 
@eugnis
I have a question about MR that you may know the answer to. Since I primarily trade options, I really need the trigger to come from the chart with the stock on it as the options chain does not work properly with Strategies. When I first tested MR, I could not get it to trigger the hot key for AT and I think that was because I had the labels on my stock chart and not the options chain chart that is connected to AT. when I moved the strategy to the chart connected to AT, the hokeys worked with MR. It doesn't make since though. As I do not see how TOS and determine what is triggering the hotkey. Hopefully, this makes since. Here is an example:

W4bwEq4.jpg


I would like to use the labels on the right to trigger the hotkeys to buy,sell, and close.
 
Last edited by a moderator:
I have a question about MR that you may know the answer to. Since I primarily trade options, I really need the trigger to come from the chart with the stock on it as the options chain does not work properly with Strategies. When I first tested MR, I could not get it to trigger the hot key for AT and I think that was because I had the labels on my stock chart and not the options chain chart that is connected to AT. when I moved the strategy to the chart connected to AT, the hokeys worked with MR. It doesn't make since though. As I do not see how TOS and determine what is triggering the hotkey. Hopefully, this makes since. Here is an example:

W4bwEq4.jpg


I would like to use the labels on the right to trigger the hotkeys to buy,sell, and close.
Check you Y and X axis point on MR. That's what it uses to spot the pixel color. Likely an issue with that. You will need to customize those axis trigger points every time you move the charts around. Also, give the pixel color like 20 to 30% tolerance. (you'll see a setting there for that)
That should help.
 
Check you Y and X axis point on MR. That's what it uses to spot the pixel color. Likely an issue with that. You will need to customize those axis trigger points every time you move the charts around. Also, give the pixel color like 20 to 30% tolerance. (you'll see a setting there for that)
That should help.
That isn't it. My y and x axis is good. It actually triggers in MR but not in TOS. The hotkey does not work unless I am using the label on the same chart that is connected to AT. weird. Doesn't make sense at all. Like I said b4, TOS shouldn't care what triggers the hotkey function. I have tried a few times and cannot get it to work. I believe I saw a video where someone else used it the way i want to with no issues. Maybe someone will know what the issue is.
 
That isn't it. My y and x axis is good. It actually triggers in MR but not in TOS. The hotkey does not work unless I am using the label on the same chart that is connected to AT. weird. Doesn't make sense at all. Like I said b4, TOS shouldn't care what triggers the hotkey function. I have tried a few times and cannot get it to work. I believe I saw a video where someone else used it the way i want to with no issues. Maybe someone will know what the issue is.
The only other thing I can think of is placing a mouse click on that part of the option chain screen before going to your BUY or SELL sequence. So TOS knows which panel its working with before firing the HotKeys.
 
The only other thing I can think of is placing a mouse click on that part of the option chain screen before going to your BUY or SELL sequence. So TOS knows which panel its working with before firing the HotKeys.
I did think of that. I have not tried it yet. I had my mouse click at top of TOS like @dap711 showed in his video. I will give it a try.
 
@billionmetrics - i use it on a Mac. Once you get passed the admin set up portion (follow the MR website) works perfectly fine. I am actually trying to tune it to do multiple stocks at once now.

@METAL @dap711 - have you gents had any luck setting MR logic to run charts at once ? Assuming both are on the same timeframe ?
Thanks @eugnis. Just started playing around. Is it possible for you to share the MRF file? I downloaded one from but thats for windows and learning from it.
 
New here... been lurking for a long time though!

I am trying to get an Auto Trade Setup Refined, Here is what im working with... thanks to BenTen and dap711!

The main issue im having is trying to keep if from trading in the "Chop" or "Consolidation" areas... that eats up allot of profit!!!!
I havent traded with it live yet but looking at the Floating P/L it eats away pretty bad and adds allot of fees/comissions.

Does anyone have an idea of what to add to this to make it not trade during those times????

Thanks in advance for any help!!


# Moving Average Crossover With Arrows, Alerts, Crossing Count and Bubble at Cross
# Mobius
# Chat Room Request 01.25.2017
# Modified a bit by BenTen

input price = close;
input fastLength = 1;
input slowLength = 21;
input averageType = AverageType.EXPONENTIAL;
input BackTestTradeSize = 1;
input ShowBackTestPositions = yes;
input AlertOnSignal = yes;
input Show_Labels = yes;

plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));

plot ArrowUp = if FastMA crosses above SlowMA
then low
else double.nan;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
ArrowUP.SetLineWeight(3);
ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if FastMA crosses below SlowMA
then high
else double.nan;
ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
ArrowDN.SetLineWeight(3);
ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);

AddCloud(FastMA, SlowMA, Color.GREEN, Color.RED);

#Define the signals
def BuyToOpenSignal = ArrowUp ;
def SellToOpenSignal = ArrowDN ;

#Open the orders on the chart for back testing and optimizing the setting
AddOrder(OrderType.BUY_AUTO, BuyToOpenSignal and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN, Color.CYAN, "");
AddOrder(OrderType.SELL_AUTO, SellToOpenSignal and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");

#Add the signal labels to the chart
AddLabel(yes, " BUY", if BuyToOpenSignal[1] crosses above BuyToOpenSignal[2] then CreateColor(153, 255, 153) else Color.White);
AddLabel(yes, " ", Color.White);
AddLabel(yes, " SELL", if SellToOpenSignal[1] crosses above SellToOpenSignal[2] then CreateColor(255, 102, 102) else Color.White);


#Sound the bell. (If alerts are turn on)
Alert(BuyToOpenSignal[1] crosses above BuyToOpenSignal[2] and AlertOnSignal, "Buy Open Signal", Alert.Bar, Sound.Ding);
Alert(SellToOpenSignal[1] crosses above SellToOpenSignal[2] and AlertOnSignal, "Sell Open Signal", Alert.Bar, Sound.Ding);
# End Code
 
Hi everyone,

I need help with the script below. I use an indicator on ninja trader which allows me when I press f7 to click a stop price and then an entry price. From this it calculates the shares I need to trade (fixed risk I'm willing to lose) and put the trade on. I'm looking something the same for Thinkorswim. Could anyone help??
Code so far with errors I have came up with is as follows:


declare lower;
input enableScript =no;
input pricePerShare =1.0;
inputriskAmountPerTrade = 100.0;

def stopPrice = ifIsNaN(close) then stopPrice[1] else if MouseButton.LEFT then closeelse stopPrice[1];
def entryPrice = ifIsNaN(close) then entryPrice[1] else if MouseButton.RIGHT then closeelse entryPrice[1];
def riskAmount =riskAmountPerTrade;

def shares =RoundDown(riskAmountPerTrade / (AbsValue(entryPrice - stopPrice)),0);
AddLabel(yes, "Sharesto Buy/Sell: " + shares, Color.WHITE);
plot entryLine = ifMouseButton.RIGHT then close else Double.NaN;
entryLine.SetDefaultColor(Color.GREEN);
entryLine.SetStyle(Curve.SHORT_DASH);
entryLine.SetLineWeight(2);

plot sellLine = ifMouseButton.LEFT == 2 then close else Double.NaN;
sellLine.SetDefaultColor(Color.RED);
sellLine.SetStyle(Curve.SHORT_DASH);
sellLine.SetLineWeight(2);


plot stopLine = ifMouseButton.LEFT then close else Double.NaN;
stopLine.SetDefaultColor(Color.YELLOW);
stopLine.SetStyle(Curve.SHORT_DASH);
stopLine.SetLineWeight(2);


def profitTarget1 =entryPrice + 2 * (entryPrice - stopPrice);
plot profitTarget1Line= if MouseButton.RIGHT then profitTarget1 else Double.NaN;
profitTarget1Line.SetDefaultColor(Color.CYAN);
profitTarget1Line.SetStyle(Curve.SHORT_DASH);
profitTarget1Line.SetLineWeight(2);

def profitTarget2 =entryPrice + 4 * (entryPrice - stopPrice);
plot profitTarget2Line= if MouseButton.RIGHT then profitTarget2 else Double.NaN;
profitTarget2Line.SetDefaultColor(Color.MAGENTA);
profitTarget2Line.SetStyle(Curve.SHORT_DASH);
profitTarget2Line.SetLineWeight(2);

def enableKey = 112;
def isEnabled = ifGetLastKeyPress() == enableKey then !enableScript else enableScript;
AssignPriceColor(ifisEnabled then Color.WHITE else Color.GRAY);
 
Hi,

how to select using mouse any bar to get location i.e. {bar time / bar reference number} and price e.g {open/high/low or close} for say two or three bars to then use this data in calculation to then plot a line between these bars or project beyond the last bar to the right side of the chart for "n" bars.

example: say we pick two bars 10 and 5 bars before the current bar and the bar 10 bars before the open is say 20, and the bar 5 bars before the close is say 27 then the price range from bar(-10) to bar(-5) is 7 (27-20) and then we want to plot a line from one bar before current bar i.e. bar(-1) to project a line 10 bars ahead from the bar(-1) open price with a slope =7/5 ie price range(27-20)/#bars(bar(-10)-bar(-5))

PS the indicator should be able to plot multiple such lines at different places on the chart.

thanks
S
 
Guess who's back?

Had a long fight with 3 ruptured disks in my back that were pinching my sciatic nerve and after 3 surgeries and a few years (yes years) in bed, I'm fighting my way back. But the good news? I didn't let my brain just sit there! LOL I've been working on a way to automate options trading! AND IT'S WORKING!

Here is the juicy stuff and the things you need (are you listening Metal? I know you are telling me to hurry up with the details! LOL)

Intro: I've given up trying to catch ever little up and down in the very noisy lower timeframes. It was driving me absolutely crazy trying to code for ever possible outcome and have moved to trading swing style on inter-day. It'll make better sense once we get to the part of how to select the stocks to trade. Just remember this is a living breathing development and I will most likely change things on daily bases. Just today, I added the "green-day shut down" feature (allows me to automatically shut down the system after reaching a percentage gain for the day). Mine is set to 10% and I normally hit it within 30 minutes of trading.

What you will need:

1. Two scans. One for Buys and one for Sells. (These are the stocks that will take a call or put option.)
2. Python (I'm using version 3.12) with PyCharm IDE.
3. Access to the Market and Account Schwab API.

This doesn't sound like much, but it will take you a few days just to get that setup.

Here is how it works .. I add the scans to two watchlists. One watchlist with My_Buy scan and the other with My_Sell scan. Both of these watchlists are detached and running in their own window. I then have my Python code looks for those 2 windows and then OCR's the list and trades the option for each ticker in the list. I have code that pulls the first option list X number of days out from the API and then finds the first OTM option. It takes the Ask + Bid / 2 = my bid and sends the order to the API with my modified bid. When the symbol drops off the list, the system closes the option trade. I'm looking for few brave souls to help me improve the system.

Here is what the system did today:

The scans in a watchlist:
1758677264659.png


The Python output:

[ledger] initialized new file at C:\Python projects\TOS_Bridge\trades_ledger.csv
[ledger] wrote OPEN RGTI RGTI 250926C00030000 x1 @1.5900 preview=Y -> C:\Python projects\TOS_Bridge\trades_ledger.csv
[2025-09-23 08:37:04] SIGNAL BUY SOUN
2025-09-23 08:37:04,332 INFO ORDER_INTENT: OPEN RGTI CALL 2025-09-26 30.0 x1 @ 1.59 (base_mid=1.59) [place=False preview=True]
2025-09-23 08:37:04,865 INFO ORDER_INTENT: OPEN SOUN CALL 2025-09-26 18.0 x1 @ 0.65 (base_mid=0.65) [place=False preview=True]
[ledger] wrote OPEN SOUN SOUN 250926C00018000 x1 @0.6500 preview=Y -> C:\Python projects\TOS_Bridge\trades_ledger.csv
[2025-09-23 08:37:06] UNREALIZED P/L (ledger-open 2 pos): -$5.30
Currently I do not allow the system to actually send the order to the API, as I want to continue testing until I feel VERY comfortable with how it trades. Anyways, I have been manually trading the tickers and have been increasing my account on average 10% per day.

Here is the EOD P/L report :

C:\Programs\Python\Python312\python.exe "C:\Python projects\TOS_Bridge\daily_pl_report.py"
Ledger: C:\Python projects\TOS_Bridge\trades_ledger.csv
2025-09-23 to 2025-09-23
------------------------------------------------------------
Net P/L: $250.80 Trades: 28 Wins: 13 Losses: 15 Avg/Trade: $8.96

By contract:
AMZN 250926P00220000 trades=1 pl=$ 12.35
AMZN 250926P00222500 trades=1 pl=$ 187.35
CDE 251017C00020000 trades=2 pl=$ -13.30
CLSK 250926C00015500 trades=1 pl=$ -43.65
CSX 250926C00020000 trades=1 pl=$ 4.35
HOOD 250926C00127000 trades=2 pl=$ -71.30
INTC 250926C00030000 trades=2 pl=$ -51.30
IONQ 250926C00075000 trades=1 pl=$ 36.35
JOBY 250926C00016500 trades=1 pl=$ 19.35
KGC 250926C00025000 trades=1 pl=$ -13.65
MRVL 250926C00076000 trades=2 pl=$ -101.30
NBIS 250926C00110000 trades=1 pl=$ -95.65
QBTS 250926C00027000 trades=1 pl=$ 46.35
RGTI 250926C00030000 trades=1 pl=$ 128.35
RIVN 250926C00015500 trades=1 pl=$ 4.35
RIVN 250926C00016000 trades=1 pl=$ -2.65
RKLB 250926C00051000 trades=1 pl=$ 145.35
SOUN 250926C00018000 trades=1 pl=$ 16.35
T 250926P00028500 trades=2 pl=$ -15.30
TOST 250926P00037500 trades=2 pl=$ 3.70
TOST 250926P00038000 trades=2 pl=$ 54.70

As you can see the win rate isn't all that great but my account grew 14% today. Small stuff, but it's only a matter of time now.

Let me know if you are interested in improving the system and I will share my watchlist scans and Python code.

Dwain
 
Last edited by a moderator:
Thread starter Similar threads Forum Replies Date
HODL-Lay-HE-hoo! Need Screen Recorder For Streaming Playground 4
J How do I delete old questions? Playground 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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