Auto Trade (ALGO) in TOS

@Svanoy I added it back and still nothing when I try it. so the script knows to start with just ctrl+9:: ? So what I tried was, i went into tos and have the green label showing, I press ctrl+9 and nothing happens... Im assuming that with the label green the moment i press ctrl9 it should move my mouse to a spot on the screen and click (to bring tos to the top) then it should press ctrlF to flatten, then ctrlB to buy.
 

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

@aCuddlyTurtle
Save this as an .ahk and run it,
It is set with ctrl+9 as the start command because it will go to that line when you press ctrl+9 and then execute code going down.
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance [Forced]

CoordMode, Pixel, Screen
Delay = 10000

^0:: Pause
^9::
MouseClick, Left, 1747, 248, 1, 0
 
@aCuddlyTurtle
ok, good
Close exit that script and go back to your original file.
Change you ImageSearch coordinates to look at the entire screen.
Should be:
Code:
ImageSearch, FoundX, FoundY, 0, 0, your max screen width, your max screen height, *w20 *h20 C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\BuyLabel.tiff
If you open Window Spy and TOS fullscreen, it should tell you the max width and height.
Hp9jtwI.png
 
@aCuddlyTurtle
ok try this for your image search.
Code:
ImageSearch, FoundX, FoundY, 27, 230, 161, 269, *w20 *h20 *TransBlack C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\BuyLabel.tiff
 
@Svanoy No luck... Something about my image search just doesn't want to work... I even took that mouse cord script you send me a while ago and I added my keybinds to it and it worked in tos. I just cant get the label to trigger it.
 
Run this as an .ahk script, ctrl+9 starts it just like the last one. Does it show a message box?
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance [Forced]

CoordMode, Pixel, Screen

Delay = 10000

^0:: Pause
^9::
Loop{
ImageSearch, FoundX, FoundY, 27, 230, 161, 269, *w20 *h20 *TransBlack C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\BuyLabel.tiff

MsgBox, 0, , %ErrorLevel%, 5
}Return
 
@aCuddlyTurtle
Ok, ErrorLevel 1 is obviously it can't find the image. The only other thing that may work is to add allowable variation.

This is the same as the last post except the *n before the file path.
Start by changing n to 1 and run the script. Keep increasing until you get 0 in the message box.
You can go up by 10s or 50. Once you get a 0 in the message box start dropping back down.

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance [Forced]

CoordMode, Pixel, Screen

Delay = 10000

^0:: Pause
^9::
Loop{
ImageSearch, FoundX, FoundY, 27, 230, 161, 269, *w20 *h20 *TransBlack *n C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\BuyLabel.tiff

MsgBox, 0, , %ErrorLevel%, 5
}Return

if that doesn't work, you may have to use @Jonessw1 suggestion of PixelGetColor.
 
@Svanoy I then plugged that code back into my orginal and it now works when i try to test it!!! But I need it to only buy one time on a label change.. it kept spamming the buy button.
 
@aCuddlyTurtle

That's what I was just fixing. Added variables to track the trade.

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance [Forced]

CoordMode, Pixel, Screen

Buy = 0
Sell = 0
Delay = 10000

^0:: Pause
^9::
Loop{

;Watch for Buy Signal
ImageSearch, FoundX, FoundY, 27, 230, 161, 269, *w20 *h20 *TransBlack *1 C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\BuyLabel.tiff

;If found click mouse on random screen location, send ctrl + f key combo, send ctrl + b key combo.
    If (ErrorLevel = 0 and Buy = 0)
        {
        MouseClick, Left, 1747, 248, 1, 0
        delay = 10
        Send ^{f}
        delay = 10
        Send ^{b}
        Buy = 1
        Sell = 0
        }
;If not found do nothing
    Else If (ErrorLevel = 1)
        {
        }
;Watch for Sell Signal
ImageSearch, FoundX, FoundY, 27, 230, 161, 269, *w20 *h20 *TransBlack *1 C:\Users\bqe27\OneDrive\Desktop\AutoHotKey Images\SellLabel.tiff

;If found click mouse on random screen location, send ctrl + f key combo, send ctrl + s key combo.
    If (ErrorLevel = 0 and Sell = 0)
        {
        MouseClick, Left, 1747, 248, 1, 0
        delay = 10
        Send ^{f}
        delay = 10
        Send ^{s}
        Buy = 1
        Sell = 1
        }
;If not found do nothing
    Else If (ErrorLevel = 1)
        {
        }

}Return
 
@aCuddlyTurtle Glad you got it working. Has to be something with the screen res or maybe 32 BIT vs. 64 BIT.
Got real lucky only having to use 1 as variation. That means the image reference and on screen image are different by a shade.
 

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