Need to Record Stock Ticker Keystrokes to Clipboard to be able to quickly (Macro/Automatedly) paste elsewhere

Hello,

I’m a Day Trader, and sometimes a stock will hit my scanners that is moving up very fast.

I don’t want to miss the move, but before I do anything, I need to enter the stock ticker into 2 different charts, as well as my Buy/Sell Broker window, and of course, need to do this rapidly, and in succession.

So, is there a way to set up a Macro where, once I trigger the Macro, I could have a “Wait for Return Key Press,”, and set up a task were as soon as I trigger the Macro, it records any/all keystrokes that happen between the triggering of the Macro, and the “Return” press?

What I’m trying to do is get that stock ticker symbol I type, after the triggering of the Macro, and before the “Return” key press, to be recorded, so that I can have the Macro move the mouse to various stock charts, and my broker’s window, click on them (respectively), and paste/return that stock ticker symbol into chart window / my brokers window to load that stock’s ticker into each window (respectively).

So, here’s the flow I”m trying to accomplish:

  1. Stock hits my scanner.
  2. I trigger the Macro (it waits for me to hit the Return key).
  3. I type in the stock ticker, and hit the Return key.
  4. The Macro records the keystrokes to the clipboard.
  5. The Macro then quickly moves the mouse to various windows, and does a Paste/Return function.

Thus, all of my charts, and my broker’s window are “auto-populated” VERY quickly with the stock ticker I typed in after I activated the Macro, so that I can jump into a trade, without having to manually move my mouse all over the place, take my hands off the mouse at each window to jump on the keyboard to retype the stock ticker, again, etc., etc.

So, is there a function that I can put within a Macro that will copy whatever I type between triggering the Macro, and hitting the “Return” key, to the clipboard?

If I'm understanding correctly, you just need to use a Prompt for User Input action to capture what you type to a variable:

Save ticker symbol to variable Macro (v11.0.4)

Save ticker symbol to variable.kmmacros (3.1 KB)

There are other ways to capture input to variables, but this seems like the simplest.

Note that you will probably run into issues with the "very quickly" portion of the macro, depending on how you can identify the items you need to click on—screen capture and OCR will be slower than clicking at defined locations onscreen, for example, and there's always some overhead incurred when switching apps.

-rob.

1 Like

Thank you very much for explaining that and writing a script!
I’m in the middle of trading pre-market, so will have to work at this later, but am very grateful, and hope that it works well.

I’ll reply again if I have any more questions or need any more help.

Thanks again!

Might you not save more time, and money, by quitting the day-trading before your stake is exhausted ?

Nearly 100% of stakes are exhausted within 5 years of day-trading.

The transaction costs are simply too high, and you are competing with industrial operations responding to new information with light fibre latencies.

1 Like

Hello Again,

While I love this elegant solution, my need has changed slightly.

Here is what I need KM to do:

  1. I trigger the Macro using a HotButton / HotKey.
  2. It prompts me for input (ie: keystrokes).
  3. It records my keystrokes (finalized by the pressing of the "Return" key).
  4. It saves my keystrokes into a "Insert Text by TYPING" subroutine.

That's it.
Once whatever I've typed, when prompted, is saved into a "Insert Text by TYPING" subroutine, I can figure out the rest of the Macro steps.

Thanks again for any/all help.

Steps 1 through 3 are handled by the Prompt for User Input action posted above. I have no idea what step 4 means. Can you please explain what you want the macro to do with the input it captured?

-rob.

Another way you might go about this is by using the “Record Quick Macro” action.

You’d trigger the macro, type the ticker, hit whatever hotkey you assigned to trigger the macro to stop recording. And then the keystrokes you typed are saved in that quick macro. I find it to be very helpful for keystroke based automations that are helpful for a short time, but aren’t worth building out a whole dedicated macro for.

So, wrt Step 4, once I type the stock ticker I need, KM inserts the string of keys I typed into an "Insert Text by TYPING" subroutine within the Master Macro.

I don't want whatever I type to be saved to the "Clipboard," per se, but rather inserted into an "Insert Text by TYPING" subroutine within the Master Macro (IF, whatever I type in can be directly inserted in an "Insert Text by TYPING" subroutine within the Master Macro. If not, then I guess we can have that subroutine get its information from the clipboard).

Thus, when I trigger the Master Macro, I'm prompted for my input, and when I hit "Return" that triggers the Master Macro to continue, which would "Insert Text by TYPING" on my Trading Software window, and then the next subroutine within the Master Macro would be to switch over to Chrome, click on a specific Chrome window location, "Insert Text by TYPING" (which would call up that stock in the TradingView Stock Charts in that Chrome window), then the next subroutine would click on another Chrome window (at a different X,Y location), with a different Stock Chart Timeframe, and do the same thing (ie: "Insert Text by TYPING"), and the final step would be to take me back to the Stock Trading Software.

So, here are the steps I'm trying to accomplish:

  1. Trigger the Macro.
  2. Prompted for my input (macro waits until I hit the "Return" key).
  3. KM puts whatever stock ticker I typed, into a "Insert Text by TYPING" subroutine within the Master Macro itself.
  4. KM executes the "Insert Text by TYPING" subroutine at a specific X,Y location, which is on/in the already active LightSpeed Trader software (thus causing the Trading software to pull up that stock so I can trade it a few second from now, after...)
  5. KM switches to make Chrome the active application.
  6. KM clicks on one Chrome window at a specific X,Y location.
  7. KM runs the "Insert Text by TYPING" subroutine in that Chrome window, to call up the stock on the 1 Minute Chart.
  8. KM clicks on another Chrome window in a different X,Y location.
  9. KM runs the "Insert Text by TYPING" subroutine in that Chrome window, to call up the stock on the 10s Chart.
  10. KM then reactivates the Trader Software to make it active so that I can start hitting Hot Keys (native to the Trading Platform Software).

So, the net-net is that I want to set it up that once I trigger the Master Macro, KM prompts me for my input, and then loads the Trading Software by TYPING the text string I entered in to the prompt, and then does this 2 more times in two different Chrome windows, so that within about 1-2 seconds total, my trading software, and both of my Chrome windows (with TradingView Stock Charts on different time frames), are ALL changed over to the same stock, and at the end of the Macro, I wind up back on the Stock Trading software (ready for my Hot Key presses that are native to the Trader Software).

In Short:
I want KM to take my input, TYPE it at Location #1, then go to Location #2 and TYPE my input, then go to Location #3 and TYPE my input, and then return me to Location #1....all in a very short amount of time.

Instead of saving the input to local_ variable, just save it to a global variable (name it whatever you like without a local prefix). Then you can use it in any macro or sub-macro just by referring to it. Assuming your input box saved it to a variable named theStockTicker, then you'd just do this wherever you needed it:

-rob.

A subroutine is a specific thing. Do you actually mean a Subroutine (or another macro that you are executing from this one), or is this just one or more Actions that happen later in the macro?