Auto Trade (ALGO) in TOS

I wanted to share my latest ahk algo script. To use this you will need to set all the coordinates and images files.

iQ0MvZR.png


CSS:
; Created/Shared by Kevin N altered by SilverWolf
;https://usethinkscript.com/threads/auto-trade-algo-in-tos.7546/page-15#post-116225
; Version Beta .15 - Last Modified: 01-05-23
; streamlined cleaned up script
; INI settings added
; P/l grabbed by Vis2OCR
; Gui upgrades: mini buttons time and chart
; Added three indicator look and agreement to take position
; Single share assurance for futures
; Added TOS position checks
; Added GUI
; Added option to disable pre-buy/sell flatten for quicker entries.
; double tap the flatten button.
; last mod creates a delay after trade closes and new trade allowed
; .07 Added entryPause Added error clearing feature.
; ver .062 Added pause for x number of minutes features.
; Made some adjustments to the screen and added auto status.
; This version to be used with the algo version 5.5 or later.

#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]

#include <Vis2>

CoordMode, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

; User Defineable variables
; Use the following to set the vertical and horizontal coordinates for each.
buttonsHorizontal     = 1635    ; Horizontal Coordinates, this will be the same for buy, flat, sell.
buyCoord              = 155     ; Vertical Coordinates, middle of button
sellCoord             = 189    ; Vertical Coordinates, middle of button
flatCoord             = 222     ; Vertical Coordinates, middle of button
statusHorizontal      = 80     ; The horizontal setting for the status bar
statusCoord           = 783    ; The vertical setting for the status bar


tradeLimit             = 100      ; How many trades are allowed in clearCounterPeriod before sitting out resetPeriod
resetPeriod            = 900      ; In Seconds, if tradeLimit is reached in clearCounterPeriod, how long to wait before another trade
clearCounterPeriod     = 1800     ; In Seconds, if tradeLimit is reached in this amount of time, sit out resetPeriod
entryDelay             = 5        ; In Seconds, the amount of time that must pass before another entry is allowed
exitDelay              = 0        ; In Seconds, Time that must pass after a trade exits before its allowed to buy again.
delayTime              = 0        ; In Seconds, the amount of time to wait sleep after buy, short, or flat.
entryPause             = 0        ; In Seconds, the amount of seconds to pause before pressing the buy/sell button.
flatBeforeEntry        = 0        ; In Seconds, amount of time to wait after pre-buy/sell flatten, if 0 then no pre-buy/sell flatten.


; End user defineable
global status          = 0
global statusWord      = ???
trades                 = 0
stopTimer              = 0
tosErrors              = 0
Checkbox_1             = 1
GoLong                 = 0
GoShort                = 0

; Generated using SmartGUI Creator 4.0
Gui, Destroy
Gui -Caption +ToolWindow +Border +LastFound +AlwaysOnTop -Border +hWndhGUI
;Gui, Color, 313131
Gui, Color, 4b4b4b
;Gui, Font, S7 CDefault Bold, Verdana
Gui, Font, S8 , Verdana
Gui, Add, Button, x2 y0 w50 h24 , Start
Gui, Add, Button, x52 y0 w50 h24 , Pause
Gui, Add, Button, x102 y0 w50 h24 , Settings
Gui, Add, Button, x202 y0 w50 h24 , Trash
Gui, Add, Button, x152 y0 w50 h24 , Refresh
Gui, Add, Button, x252 y0 w50 h24 , Focus
Gui, Add, Button, x302 y0 w30 h24 , 1
Gui, Add, Button, x332 y0 w30 h24 , 2
Gui, Add, Button, x362 y0 w30 h24 , 3
Gui, Add, Button, x392 y0 w30 h24 , 4
Gui, Add, Button, x422 y0 w30 h24 , 5
Gui, Add, Checkbox, x463 y-4 w13 h30 Checked vCheckbox_1 gSubmit_All, OneC
Gui, Add, Button, x487 y0 w50 h24 , Exit
;Gui, Add, Text, x4 y30 w540 h30 cffffff,

Gui, Show, x780 y51 h25 w539, TOS Algo Trading System
Gui, Submit, NoHide
Return


Submit_All:
Gui, Submit, NoHide
Return

ButtonExit:
GuiClose:
ExitApp   2

ButtonPause:
Send Esc
Pause,, 1
tooltip [>    ~TOS Algo Trading System is PAUSED~    <], %statusCoord%, %statusHorizontal%
Return

ButtonSettings:
Run, notepad.exe "My TOS ALGO Settings.ini"
Return

ButtonRefresh:
Run, lib/TOS refresh chart
Return

ButtonTrash:
;Run, lib/TOS collect garbage
    MouseClick, Left, 720, 60, 1, 0
    Sleep 10
    MouseClick, Left, 316, 83, 1, 0
    Sleep 10
    MouseClick, Left, 1700, 120, 1, 0
    Sleep 10
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100
Return

ButtonFocus:
;Run, lib/TOS focus
    MouseClick, Left, 70, 200, 1, 0
    Sleep 10
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100
Return
Return

Button1:
if (Checkbox_1 = 1){
;Run, lib/TOS ActiveTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100

}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 4000t
    MouseMove,  1080, 111, 100
}
Return

Button2:
if (Checkbox_1 = 1){
;Run, lib/TOS ForexTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 345, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 2000t
    MouseMove,  1080, 111, 100
}
Return

Button3:
if (Checkbox_1 = 1){
;Run, lib/TOS FuturesTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 465, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 1000t
    MouseMove,  1080, 111, 100
}
Return

Button4:
if (Checkbox_1 = 1){
;Run, lib/TOS PairsTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 715, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 500t
    MouseMove,  1080, 111, 100
}
Return

Button5:
if (Checkbox_1 = 1){
;Run, lib/TOS Charts
    MouseClick, Left, 535, 62, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 64t
    MouseMove,  1080, 111, 100
}
Return



^B:: MouseClick, Left,  %buttonsHorizontal%, %buyCoord%, 1, 0
^F:: MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
^S:: MouseClick, Left, %buttonsHorizontal%, %sellCoord%, 1, 0
^ESC:: ExitApp
ESC:: Pause
^R:: trades = 0  ;Reset the trades
^T:: stopTimer = 0
^D:: delayFunction(86400,"Waiting") ; 86400 = 1 Day
^F1:: delayFunction(3600,"Pausing for 1 hour")
^F2:: delayFunction(7200,"Pausing for 2 hours")
^F4:: delayFunction(14400,"Pausing for 4 hours")
^0:: status = 0
^1:: status = 1
^2:: status = 2

ButtonStart:
;Main:
a := entryDelay
Toggle := !Toggle
While Toggle {
Sleep 10
    a++
    b++

    IniRead, HowManyIndicatorsVar, My TOS ALGO Settings.ini, Settings, HowManyIndicators, 3
    ;MsgBox, The value is %HowManyIndicatorsVar%.
    HowManyIndicators = %HowManyIndicatorsVar%
    IniRead, SingleShareVar, My TOS ALGO Settings.ini, Settings, SingleShare, 1
    ;MsgBox, The value is %SingleShareVar%.
    SingleShare = %SingleShareVar%


        if (SingleShare = 1){
            ;Maintain single share
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w70 *h26 Images\TwoBuy.tiff
                if (ErrorLevel = 0){
                status = 1
                    ;Correct and sell one back
                               MouseClick, Left, %buttonsHorizontal%, %sellCoord%, 1, 0
                    sleep 2000
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w71 *h26 Images\TwoSell.tiff
                if (ErrorLevel = 0){
                status = 2
                    ;Correct and buy one back
                                MouseClick, Left, %buttonsHorizontal%, %buyCoord%,  1, 0
                    sleep 2000
                }
        }

        status = 1111 ;Reset for Loop
            ;Get status from TOS
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w71 *h26 Images\FlatPic.tiff
                if (ErrorLevel = 0){
                    status = 0
                    ;statusWord = Flat
                    Sleep 11
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w59 *h26 Images\Positive.tiff
                if (ErrorLevel = 0){
                    status = 1
                    statusWord = Long
                    Sleep 11
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w58 *h26 Images\Negative.tiff
                if (ErrorLevel = 0){
                    status = 2
                    statusWord = Short
                    Sleep 11
                }


        if (status = 0){ ;Flat! Look for indicators
                    sleep 11

            ;Three indicator and buy signal
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w20 *h20 images\BuyLabel.tiff
                if (ErrorLevel = 0){
                    UpBuySignal = 1
                }else{
                    UpBuySignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 750, 400, 835, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw1Bsignal = 1
                }else{
                    Lw1Bsignal = 0
                    }
                    sleep 11

            ImageSearch, FoundX, FoundY, 0, 835, 400, 920, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw2Bsignal = 1
                }else{
                    Lw2Bsignal = 0
                    }
                    sleep 11

            ImageSearch, FoundX, FoundY, 0, 920, 400, 1000, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw3Bsignal = 1
                }else{
                    Lw3Bsignal = 0
                }
                sleep 11


            if (HowManyIndicators == 3){
            BUYvalue := Lw1Bsignal+Lw2Bsignal+Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 2){
            BUYvalue := Lw2Bsignal+Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 1){
            BUYvalue := Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 0){
            BUYvalue := UpBuySignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }

            GoLong = 0
            if (HowManyIndicators == 3 and BUYvalue == 3){
                GoLong = 1
            }
            if (HowManyIndicators == 2 and BUYvalue == 2){
                GoLong = 1
            }
            if (HowManyIndicators == 1 and BUYvalue == 1){
                GoLong = 1
            }
            if (HowManyIndicators == 0 and BUYvalue == 1){
                GoLong = 1
            }


            ;Three indicator and sell signal
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w20 *h20 images\SellLabel.tiff        
                if (ErrorLevel = 0){
                    UpSellSignal = 1
                }else{
                    UpSellSignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 750, 400, 835, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw1Ssignal = 1
                }else{
                    Lw1Ssignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 835, 400, 920, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw2Ssignal = 1
                }else{
                    Lw2Ssignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 920, 400, 1000, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw3Ssignal = 1
                }else{
                    Lw3Ssignal = 0
                }
                sleep 11

            if (HowManyIndicators == 3){
            SELLvalue := Lw1Ssignal+Lw2Ssignal+Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 2){
            SELLvalue := Lw2Ssignal+Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 1){
            SELLvalue := Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 0){
            SELLvalue := UpSellSignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }

            GoShort = 0
            if (HowManyIndicators == 3 and SELLvalue == 3){
                GoShort = 1
            }
            if (HowManyIndicators == 2 and SELLvalue == 2){
                GoShort = 1
            }
            if (HowManyIndicators == 1 and SELLvalue == 1){
                GoShort = 1
            }
            if (HowManyIndicators == 0 and SELLvalue == 1){
                GoShort = 1
            }

           
           
            statusWord = Flat (L%BUYvalue%|S%SELLvalue%)


            ;Evaluate and Go Long
            if (UpBuySignal == 1 and GoLong == 1 and a >= entryDelay) { ;goLong
                    if (entryPause > 0) {
                        k := entryPause
                        while (k > 0) {
                            ;tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                            sleep 100
                            k--
                        }
                    }
                    ;Click Flatten Button
                    if (flatBeforeEntry > 0) {
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                    delayFunction(flatBeforeEntry, "Flat Before Next Entry")
                    }

                    ;Click Buy (Long)
                    MouseClick, Left, %buttonsHorizontal%, %buyCoord%,  1, 0
                   
                    MouseMove,  1800, 175, 100

                    status = 1
                    statusWord = Long

                    a = 0
                    trades++
                    sleep delayTime * 100
            }

            ;Evaluate and Go Short
            if (UpSellSignal == 1 and GoShort == 1  and a >= entryDelay) { ;goShort
                    if (entryPause > 0) {
                        k := entryPause
                        while (k > 0) {
                            ;tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                            sleep 100
                            k--
                        }
                    }
                    ;Click Flatten Button
                    if (flatBeforeEntry > 0) {
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                    delayFunction(flatBeforeEntry, "Flat Before Next Entry")
                    }
                   
                    ;Click Sell (short)
                    MouseClick, Left, %buttonsHorizontal%, %sellCoord%,  1, 0
                   
                    MouseMove,  1800, 175, 100

                    status = 2
                    statusWord = Short

                    a = 0
                    trades++
                    sleep delayTime * 100
            }
        }
       
        if (status = 1){ ;Long! Look for close
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w15 *h15 images\MagentaLabel.tiff
            if (ErrorLevel = 0){ ;Long Close        
                        ;Click Flatten Button
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                        MouseMove,  1800, 175, 100
                        status = 0
                       

                        sleep delayTime * 100
                        delayFunction(exitDelay, "Next Entry is Delayed")
            }
        }

        if (status = 2){ ;Short! Look for close
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w15 *h15 Images\LightGreenLabel.tiff
            if (ErrorLevel = 0){ ;Short Close
                        ;Click Flatten Button
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                        MouseMove,  1800, 175, 100
                        status = 0
                       

                        sleep delayTime * 100
                        delayFunction(exitDelay, "Next Entry is Delayed")
            }
        }

        if (status == 1111){ ;Cannot see TOS! Lost Connection?
            statusWord = !! No connection with TOS !!
            MsgBox, % "Cannot see TOS! Lost Connection? Status: " status
        }


    timeLeft := clearCounterPeriod - b
    entryTime := FormatSeconds(a)
    countdownTime := FormatSeconds(timeLeft)
    FormatTime, TimeString,, Time

    tooltip  Status: %status%-%statusWord% | Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%, %statusCoord%, %statusHorizontal%
     ;tooltip  Status: %statusWord%, %statusCoord%, %statusHorizontal%
    ;tooltip

    ;Gui, Font, S12, Verdana
    ;Gui, Add, Text, x4 y30 w599 h30 cffffff, Status: %statusWord% | Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%
    ;Gui, Add, Text, x5 y29 w500 h30 cffffff, Status: %statusWord%
    ;Gui, Add, Text, x175 y30 w499 h30 cffffff, Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%

    if (trades >= tradeLimit) {
        trades = 0
        ;Click Flatten Button
        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
        sleep resetPeriod * 100
        j++

        if (j == 2 ) {
            tooltip Reset Count: %j% Time: %TimeString%, %statusCoord%, %statusHorizontal%
            exit
        }
    }
    if (b >= clearCounterPeriod) {
        b = 0
        trades = 0
    }

}
return



FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time := 19990101  ; *Midnight* of an arbitrary date.
    time += NumberOfSeconds, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss
    /*
    ; Unlike the method used above, this would not support more than 24 hours worth of seconds:
    FormatTime, hmmss, %time%, h:mm:ss
    return hmmss
    */
}

delayFunction(SecondsToWait, Message )
{
    k := SecondsToWait
    global stopTimer = 1
    global statusCoord
    global statusHorizontal
    while (k > 0)
    {
        if (stopTimer != 1) {
            break
        }
        timeLeft:= FormatSeconds(k)
        tooltip %Message%: %timeLeft%, %statusCoord%, %statusHorizontal%
        sleep 1000
        k--
    }
    stopTimer = 0
}

; CTRL - P to get PL popup
^p::
GetPL()
Return


GetPL()
{

;To setup uncomment the msg box. You only want the numbers no letters no symbols or the math wont work.

; P/L coordinates
x := 1705
y := 394
w := 40
h := 25
;MsgBox % OCR([x, y, w, h])

; B/S ? by ? coordinates
x1 := 1571
y1 := 365
w1 := 20
h1 := 30
;MsgBox % OCR([x1, y1, w1, h1])

        ;Get P/L Day
        PLDay := OCR([x, y, w, h])

        ;Get B/S for the day
        BSDay := OCR([x1, y1, w1, h1])

        StringTrimLeft, BSDay, BSDay, 2

        ;Fees
        CommissionsNFees = 6.2

        ;Math to get day Total of fees
        BSTotal := BSDay * CommissionsNFees

                ;msgbox, %BSTotal%

        ;Math to gey Net Profits
        PLTotal := PLDay - BSTotal

        ;Trim zeros
        StringTrimRight, PLTotal, PLTotal, 4

                    ;msgbox, %PLTotal%


MsgBox, 48, Net P/L Total:, Net Profit and Loss for the day: $%PLTotal%

}Return
 
@SilverWolf thanks for sharing the script is there any way you can just give me the entry time as a script
That code is remnant of @Kevin N script. He would have a much better grasp on how to make that a standalone script..

I have an idea though.. do you just want a log of when trades were taken? AHK has all kinds of ways to accomplish something like that. In your loop in the buy or sell statement you could have it write to a file with FileAppend.
CSS:
 FileAppend, Went long at %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%.`n, TradeLog.txt
 
I wanted to share my latest ahk algo script. To use this you will need to set all the coordinates and images files.

iQ0MvZR.png


CSS:
; Created/Shared by Kevin N altered by SilverWolf
;https://usethinkscript.com/threads/auto-trade-algo-in-tos.7546/page-15#post-116225
; Version Beta .15 - Last Modified: 01-05-23
; streamlined cleaned up script
; INI settings added
; P/l grabbed by Vis2OCR
; Gui upgrades: mini buttons time and chart
; Added three indicator look and agreement to take position
; Single share assurance for futures
; Added TOS position checks
; Added GUI
; Added option to disable pre-buy/sell flatten for quicker entries.
; double tap the flatten button.
; last mod creates a delay after trade closes and new trade allowed
; .07 Added entryPause Added error clearing feature.
; ver .062 Added pause for x number of minutes features.
; Made some adjustments to the screen and added auto status.
; This version to be used with the algo version 5.5 or later.

#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]

#include <Vis2>

CoordMode, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

; User Defineable variables
; Use the following to set the vertical and horizontal coordinates for each.
buttonsHorizontal     = 1635    ; Horizontal Coordinates, this will be the same for buy, flat, sell.
buyCoord              = 155     ; Vertical Coordinates, middle of button
sellCoord             = 189    ; Vertical Coordinates, middle of button
flatCoord             = 222     ; Vertical Coordinates, middle of button
statusHorizontal      = 80     ; The horizontal setting for the status bar
statusCoord           = 783    ; The vertical setting for the status bar


tradeLimit             = 100      ; How many trades are allowed in clearCounterPeriod before sitting out resetPeriod
resetPeriod            = 900      ; In Seconds, if tradeLimit is reached in clearCounterPeriod, how long to wait before another trade
clearCounterPeriod     = 1800     ; In Seconds, if tradeLimit is reached in this amount of time, sit out resetPeriod
entryDelay             = 5        ; In Seconds, the amount of time that must pass before another entry is allowed
exitDelay              = 0        ; In Seconds, Time that must pass after a trade exits before its allowed to buy again.
delayTime              = 0        ; In Seconds, the amount of time to wait sleep after buy, short, or flat.
entryPause             = 0        ; In Seconds, the amount of seconds to pause before pressing the buy/sell button.
flatBeforeEntry        = 0        ; In Seconds, amount of time to wait after pre-buy/sell flatten, if 0 then no pre-buy/sell flatten.


; End user defineable
global status          = 0
global statusWord      = ???
trades                 = 0
stopTimer              = 0
tosErrors              = 0
Checkbox_1             = 1
GoLong                 = 0
GoShort                = 0

; Generated using SmartGUI Creator 4.0
Gui, Destroy
Gui -Caption +ToolWindow +Border +LastFound +AlwaysOnTop -Border +hWndhGUI
;Gui, Color, 313131
Gui, Color, 4b4b4b
;Gui, Font, S7 CDefault Bold, Verdana
Gui, Font, S8 , Verdana
Gui, Add, Button, x2 y0 w50 h24 , Start
Gui, Add, Button, x52 y0 w50 h24 , Pause
Gui, Add, Button, x102 y0 w50 h24 , Settings
Gui, Add, Button, x202 y0 w50 h24 , Trash
Gui, Add, Button, x152 y0 w50 h24 , Refresh
Gui, Add, Button, x252 y0 w50 h24 , Focus
Gui, Add, Button, x302 y0 w30 h24 , 1
Gui, Add, Button, x332 y0 w30 h24 , 2
Gui, Add, Button, x362 y0 w30 h24 , 3
Gui, Add, Button, x392 y0 w30 h24 , 4
Gui, Add, Button, x422 y0 w30 h24 , 5
Gui, Add, Checkbox, x463 y-4 w13 h30 Checked vCheckbox_1 gSubmit_All, OneC
Gui, Add, Button, x487 y0 w50 h24 , Exit
;Gui, Add, Text, x4 y30 w540 h30 cffffff,

Gui, Show, x780 y51 h25 w539, TOS Algo Trading System
Gui, Submit, NoHide
Return


Submit_All:
Gui, Submit, NoHide
Return

ButtonExit:
GuiClose:
ExitApp   2

ButtonPause:
Send Esc
Pause,, 1
tooltip [>    ~TOS Algo Trading System is PAUSED~    <], %statusCoord%, %statusHorizontal%
Return

ButtonSettings:
Run, notepad.exe "My TOS ALGO Settings.ini"
Return

ButtonRefresh:
Run, lib/TOS refresh chart
Return

ButtonTrash:
;Run, lib/TOS collect garbage
    MouseClick, Left, 720, 60, 1, 0
    Sleep 10
    MouseClick, Left, 316, 83, 1, 0
    Sleep 10
    MouseClick, Left, 1700, 120, 1, 0
    Sleep 10
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100
Return

ButtonFocus:
;Run, lib/TOS focus
    MouseClick, Left, 70, 200, 1, 0
    Sleep 10
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100
Return
Return

Button1:
if (Checkbox_1 = 1){
;Run, lib/TOS ActiveTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    MouseMove,  1080, 111, 100

}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 4000t
    MouseMove,  1080, 111, 100
}
Return

Button2:
if (Checkbox_1 = 1){
;Run, lib/TOS ForexTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 345, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 2000t
    MouseMove,  1080, 111, 100
}
Return

Button3:
if (Checkbox_1 = 1){
;Run, lib/TOS FuturesTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 465, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 1000t
    MouseMove,  1080, 111, 100
}
Return

Button4:
if (Checkbox_1 = 1){
;Run, lib/TOS PairsTrader
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 715, 85, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 500t
    MouseMove,  1080, 111, 100
}
Return

Button5:
if (Checkbox_1 = 1){
;Run, lib/TOS Charts
    MouseClick, Left, 535, 62, 1, 0
    MouseMove,  1080, 111, 100
}Else{
    MouseClick, Left, 255, 62, 1, 0
    Sleep 10
    MouseClick, Left, 600, 85, 1, 0
    Run, lib/TOS 64t
    MouseMove,  1080, 111, 100
}
Return



^B:: MouseClick, Left,  %buttonsHorizontal%, %buyCoord%, 1, 0
^F:: MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
^S:: MouseClick, Left, %buttonsHorizontal%, %sellCoord%, 1, 0
^ESC:: ExitApp
ESC:: Pause
^R:: trades = 0  ;Reset the trades
^T:: stopTimer = 0
^D:: delayFunction(86400,"Waiting") ; 86400 = 1 Day
^F1:: delayFunction(3600,"Pausing for 1 hour")
^F2:: delayFunction(7200,"Pausing for 2 hours")
^F4:: delayFunction(14400,"Pausing for 4 hours")
^0:: status = 0
^1:: status = 1
^2:: status = 2

ButtonStart:
;Main:
a := entryDelay
Toggle := !Toggle
While Toggle {
Sleep 10
    a++
    b++

    IniRead, HowManyIndicatorsVar, My TOS ALGO Settings.ini, Settings, HowManyIndicators, 3
    ;MsgBox, The value is %HowManyIndicatorsVar%.
    HowManyIndicators = %HowManyIndicatorsVar%
    IniRead, SingleShareVar, My TOS ALGO Settings.ini, Settings, SingleShare, 1
    ;MsgBox, The value is %SingleShareVar%.
    SingleShare = %SingleShareVar%


        if (SingleShare = 1){
            ;Maintain single share
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w70 *h26 Images\TwoBuy.tiff
                if (ErrorLevel = 0){
                status = 1
                    ;Correct and sell one back
                               MouseClick, Left, %buttonsHorizontal%, %sellCoord%, 1, 0
                    sleep 2000
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w71 *h26 Images\TwoSell.tiff
                if (ErrorLevel = 0){
                status = 2
                    ;Correct and buy one back
                                MouseClick, Left, %buttonsHorizontal%, %buyCoord%,  1, 0
                    sleep 2000
                }
        }

        status = 1111 ;Reset for Loop
            ;Get status from TOS
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w71 *h26 Images\FlatPic.tiff
                if (ErrorLevel = 0){
                    status = 0
                    ;statusWord = Flat
                    Sleep 11
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w59 *h26 Images\Positive.tiff
                if (ErrorLevel = 0){
                    status = 1
                    statusWord = Long
                    Sleep 11
                }
            ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600, *20  *w58 *h26 Images\Negative.tiff
                if (ErrorLevel = 0){
                    status = 2
                    statusWord = Short
                    Sleep 11
                }


        if (status = 0){ ;Flat! Look for indicators
                    sleep 11

            ;Three indicator and buy signal
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w20 *h20 images\BuyLabel.tiff
                if (ErrorLevel = 0){
                    UpBuySignal = 1
                }else{
                    UpBuySignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 750, 400, 835, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw1Bsignal = 1
                }else{
                    Lw1Bsignal = 0
                    }
                    sleep 11

            ImageSearch, FoundX, FoundY, 0, 835, 400, 920, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw2Bsignal = 1
                }else{
                    Lw2Bsignal = 0
                    }
                    sleep 11

            ImageSearch, FoundX, FoundY, 0, 920, 400, 1000, *20 *w15 *h15 images\LowerBuyLabel.tiff
                if (ErrorLevel = 0){
                    Lw3Bsignal = 1
                }else{
                    Lw3Bsignal = 0
                }
                sleep 11


            if (HowManyIndicators == 3){
            BUYvalue := Lw1Bsignal+Lw2Bsignal+Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 2){
            BUYvalue := Lw2Bsignal+Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 1){
            BUYvalue := Lw3Bsignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }
            if (HowManyIndicators == 0){
            BUYvalue := UpBuySignal
                ;MsgBox, % "Buy Total: " BUYvalue
            }

            GoLong = 0
            if (HowManyIndicators == 3 and BUYvalue == 3){
                GoLong = 1
            }
            if (HowManyIndicators == 2 and BUYvalue == 2){
                GoLong = 1
            }
            if (HowManyIndicators == 1 and BUYvalue == 1){
                GoLong = 1
            }
            if (HowManyIndicators == 0 and BUYvalue == 1){
                GoLong = 1
            }


            ;Three indicator and sell signal
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w20 *h20 images\SellLabel.tiff       
                if (ErrorLevel = 0){
                    UpSellSignal = 1
                }else{
                    UpSellSignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 750, 400, 835, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw1Ssignal = 1
                }else{
                    Lw1Ssignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 835, 400, 920, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw2Ssignal = 1
                }else{
                    Lw2Ssignal = 0
                }
                sleep 11

            ImageSearch, FoundX, FoundY, 0, 920, 400, 1000, *20 *w15 *h15 images\LowerSellLabel.tiff
                if (ErrorLevel = 0){
                    Lw3Ssignal = 1
                }else{
                    Lw3Ssignal = 0
                }
                sleep 11

            if (HowManyIndicators == 3){
            SELLvalue := Lw1Ssignal+Lw2Ssignal+Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 2){
            SELLvalue := Lw2Ssignal+Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 1){
            SELLvalue := Lw3Ssignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }
            if (HowManyIndicators == 0){
            SELLvalue := UpSellSignal
                ;MsgBox, % "Sell Total: " SELLvalue
            }

            GoShort = 0
            if (HowManyIndicators == 3 and SELLvalue == 3){
                GoShort = 1
            }
            if (HowManyIndicators == 2 and SELLvalue == 2){
                GoShort = 1
            }
            if (HowManyIndicators == 1 and SELLvalue == 1){
                GoShort = 1
            }
            if (HowManyIndicators == 0 and SELLvalue == 1){
                GoShort = 1
            }

          
          
            statusWord = Flat (L%BUYvalue%|S%SELLvalue%)


            ;Evaluate and Go Long
            if (UpBuySignal == 1 and GoLong == 1 and a >= entryDelay) { ;goLong
                    if (entryPause > 0) {
                        k := entryPause
                        while (k > 0) {
                            ;tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                            sleep 100
                            k--
                        }
                    }
                    ;Click Flatten Button
                    if (flatBeforeEntry > 0) {
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                    delayFunction(flatBeforeEntry, "Flat Before Next Entry")
                    }

                    ;Click Buy (Long)
                    MouseClick, Left, %buttonsHorizontal%, %buyCoord%,  1, 0
                  
                    MouseMove,  1800, 175, 100

                    status = 1
                    statusWord = Long

                    a = 0
                    trades++
                    sleep delayTime * 100
            }

            ;Evaluate and Go Short
            if (UpSellSignal == 1 and GoShort == 1  and a >= entryDelay) { ;goShort
                    if (entryPause > 0) {
                        k := entryPause
                        while (k > 0) {
                            ;tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                            sleep 100
                            k--
                        }
                    }
                    ;Click Flatten Button
                    if (flatBeforeEntry > 0) {
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                    delayFunction(flatBeforeEntry, "Flat Before Next Entry")
                    }
                  
                    ;Click Sell (short)
                    MouseClick, Left, %buttonsHorizontal%, %sellCoord%,  1, 0
                  
                    MouseMove,  1800, 175, 100

                    status = 2
                    statusWord = Short

                    a = 0
                    trades++
                    sleep delayTime * 100
            }
        }
      
        if (status = 1){ ;Long! Look for close
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w15 *h15 images\MagentaLabel.tiff
            if (ErrorLevel = 0){ ;Long Close       
                        ;Click Flatten Button
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                        MouseMove,  1800, 175, 100
                        status = 0
                      

                        sleep delayTime * 100
                        delayFunction(exitDelay, "Next Entry is Delayed")
            }
        }

        if (status = 2){ ;Short! Look for close
            ImageSearch, FoundX, FoundY, 840, 180, 1111, 245, *20 *w15 *h15 Images\LightGreenLabel.tiff
            if (ErrorLevel = 0){ ;Short Close
                        ;Click Flatten Button
                        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
                        MouseMove,  1800, 175, 100
                        status = 0
                      

                        sleep delayTime * 100
                        delayFunction(exitDelay, "Next Entry is Delayed")
            }
        }

        if (status == 1111){ ;Cannot see TOS! Lost Connection?
            statusWord = !! No connection with TOS !!
            MsgBox, % "Cannot see TOS! Lost Connection? Status: " status
        }


    timeLeft := clearCounterPeriod - b
    entryTime := FormatSeconds(a)
    countdownTime := FormatSeconds(timeLeft)
    FormatTime, TimeString,, Time

    tooltip  Status: %status%-%statusWord% | Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%, %statusCoord%, %statusHorizontal%
     ;tooltip  Status: %statusWord%, %statusCoord%, %statusHorizontal%
    ;tooltip

    ;Gui, Font, S12, Verdana
    ;Gui, Add, Text, x4 y30 w599 h30 cffffff, Status: %statusWord% | Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%
    ;Gui, Add, Text, x5 y29 w500 h30 cffffff, Status: %statusWord%
    ;Gui, Add, Text, x175 y30 w499 h30 cffffff, Entry: %entryTime% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Time: %TimeString%

    if (trades >= tradeLimit) {
        trades = 0
        ;Click Flatten Button
        MouseClick, Left, %buttonsHorizontal%, %flatCoord%, 1, 0
        sleep resetPeriod * 100
        j++

        if (j == 2 ) {
            tooltip Reset Count: %j% Time: %TimeString%, %statusCoord%, %statusHorizontal%
            exit
        }
    }
    if (b >= clearCounterPeriod) {
        b = 0
        trades = 0
    }

}
return



FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time := 19990101  ; *Midnight* of an arbitrary date.
    time += NumberOfSeconds, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss
    /*
    ; Unlike the method used above, this would not support more than 24 hours worth of seconds:
    FormatTime, hmmss, %time%, h:mm:ss
    return hmmss
    */
}

delayFunction(SecondsToWait, Message )
{
    k := SecondsToWait
    global stopTimer = 1
    global statusCoord
    global statusHorizontal
    while (k > 0)
    {
        if (stopTimer != 1) {
            break
        }
        timeLeft:= FormatSeconds(k)
        tooltip %Message%: %timeLeft%, %statusCoord%, %statusHorizontal%
        sleep 1000
        k--
    }
    stopTimer = 0
}

; CTRL - P to get PL popup
^p::
GetPL()
Return


GetPL()
{

;To setup uncomment the msg box. You only want the numbers no letters no symbols or the math wont work.

; P/L coordinates
x := 1705
y := 394
w := 40
h := 25
;MsgBox % OCR([x, y, w, h])

; B/S ? by ? coordinates
x1 := 1571
y1 := 365
w1 := 20
h1 := 30
;MsgBox % OCR([x1, y1, w1, h1])

        ;Get P/L Day
        PLDay := OCR([x, y, w, h])

        ;Get B/S for the day
        BSDay := OCR([x1, y1, w1, h1])

        StringTrimLeft, BSDay, BSDay, 2

        ;Fees
        CommissionsNFees = 6.2

        ;Math to get day Total of fees
        BSTotal := BSDay * CommissionsNFees

                ;msgbox, %BSTotal%

        ;Math to gey Net Profits
        PLTotal := PLDay - BSTotal

        ;Trim zeros
        StringTrimRight, PLTotal, PLTotal, 4

                    ;msgbox, %PLTotal%


MsgBox, 48, Net P/L Total:, Net Profit and Loss for the day: $%PLTotal%

}Return
Dear SilverWolf, thank you for your efforts and kindness to share your great ideas. I have installed AHK script with Vis2OCR. While I run as Administrator the script according to your instructions I receive a message that "Cannot see TOS! Lost connection status:1111".

One additional topic from a very inexperienced user- using Window Spy I need to set correct coordinates for the Buy, Sell and Flatten button of ThinkorSwim. Please, explain what do you mean by Status Bar in order to place correct coordinates. I know this sound strange, but can you put some very short explanation how to make this script work for less knowledgeable users like me. As I see from the code I need in addition to make a subfolder Images, make and place into it the tiff files with size 15x15 pixels. These questions sound so elementary for you, but I shall be grateful for your help. With best regards, Nelly
 
Hey @NellyN , glad to help.. The Status Bar is the tooltip that shows the status, time, entry time, etc.. you can see it in the image there. Yes, it is very important that you use WindowSpy to modify coordinates of everything. That being said, if the script cannot see the "Pos Flat" or "Pos Short" or "Pos Long" the script doesnt know what TOS is doing. I use that to alert if the script can not see one of them. The msgbox is not necessary you can comment it out if you like or at least until you get the script seeing TOS. You can see in the status bar if the script is seeing it while you setup. You want to test each image to confirm good "connection" between the programs. I will attach examples of what I use. I suggest that you use Windows snipping tool and create your own as the color size and tint most likely is different on my computer.
xWInMys.png
9wEzAgS.png
ACW2d4o.png


The vis2ocr script is only used to get the profit and trades.. put that on a back burner until you get the buttons, connection images, and indicator locations set. Locating those numbers is a long process of trial and error.

The coordinates are in a set.. To help you visualize heres an Example: (ImageSearch, FoundX, FoundY, 1300, 125, 1900, 600,) the first two "1300, 125," are the top left corner of the rectangle that ahk will screenshot to look for your image. The "1900, 600," is the bottom right corner.

In the folder where the script is located an images folder is what its looking for. You can change that of course. The buy sell flat coordinates should be easy to set but you should organize your active trader to look like this:
9YXsvuB.png


You could always pin point their location if you dont want to rearrange your Active Trader.

I hope this helps :)
 

Attachments

  • xWInMys.png
    xWInMys.png
    810 bytes · Views: 528
  • 9wEzAgS.png
    9wEzAgS.png
    672 bytes · Views: 530
@SilverWolf are you lookingat 2 lower indicators with this one?
what do you mean by
twobuy.tiff,twosell.tiff
LowerBuyLabel.tiff LowerSellLabel.tiff
@Goingdark365 yes it can look at three lower indicators if you setup the coordinates.

The twobuy.tiff is this
tgx4Nij.png


In the settings you will see "singleShare" this is to ensure that i dont hold more than 1 share or contract. the script looks for that at the start of the loop and if it see two it will sell one back
 
Oh if you click the settings button it will ask to make a settings file in the script directory. This is to allow me to make a couple changes and not have to reload the script. after the ini file is created it should look like:

CSS:
[Settings]
HowManyIndicators = 3
SingleShare = 1

if there is no file or contents it will default to those values. You can see that in the loop where it says "IniRead"
 
Hallo Algo Traders, inspired by @dap711 I made my first simple auto trader with Macro Recorder. I found it easier since the script watches for specific color in order to activate itself. Here I attach my file with the Macro Recorder script. When the script sees lebel Buy it clicks Buy MKT button, lebel Sell - Sell MKT and Close-Flatten. I have one problem, the scripts clicks numerous time Buy or Sell when there is a signal. Please, help how to enter 1 time per direction. If you improve it, please share it here. The strategy may be any, it reads the colour of the labels. More useful info with label codes and nice made video explanation you may see here: https://usethinkscript.com/threads/moving-average-master-strategy-for-thinkorswim.13975/
P.S. I really like the last script written by @SilverWolf , but it is too complicated for an absolute beginner like me. May be he can make a video with very brief explanations of his code, logic and mainly chart positions of the labels, libraries, numbers in his GUI toolbar, etc.
Code:
"Mouse left click";"857, 17";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Go to label";"Buy";
"Mouse left click";"100, 167";
"Key Down";"Alt";
"Key press";"F";
"Key press";"B";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Sell";
"Mouse left click";"285, 167";
"Key Down";"Alt";
"Key press";"F";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Close";
"Mouse left click";"193, 167";
"Key Down";"Alt";
"Key press";"S";
"Wait";"5000 ms";
 
Last edited:
Hallo Algo Traders, inspired by @dap711 I made my first simple auto trader with Macro Recorder. I found it easier since the script watches for specific color in order to activate itself. Here I attach my file with the Macro Recorder script. When the script sees lebel Buy it clicks Buy MKT button, lebel Sell - Sell MKT and Close-Flatten. I have one problem, the scripts clicks numerous time Buy or Sell when there is a signal. Please, help how to enter 1 time per direction. If you improve it, please share it here. The strategy may be any, it reads the colour of the labels. More useful info with label codes and nice made video explanation you may see here: https://usethinkscript.com/threads/moving-average-master-strategy-for-thinkorswim.13975/
P.S. I really like the last script written by @SilverWolf , but it is too complicated for an absolute beginner like me. May be he can make a video with very brief explanations of his code, logic and mainly chart positions of the labels, libraries, numbers in his GUI toolbar, etc.
Code:
"Mouse left click";"857, 17";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Go to label";"Buy";
"Mouse left click";"100, 167";
"Key Down";"Alt";
"Key press";"F";
"Key press";"B";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Sell";
"Mouse left click";"285, 167";
"Key Down";"Alt";
"Key press";"F";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Close";
"Mouse left click";"193, 167";
"Key Down";"Alt";
"Key press";"S";
"Wait";"5000 ms";
Does your strategy keep the label color the whole time or only on one bar?
 
Does your strategy keep the label color the whole time or only on one bar?
There is only one label that we see at a time. Buy, Sell or Close. It distinguishes the color and clicks the Buttons. Very easy and simple, even for an absolute novice like me. For an experienced person like you it will be really easy and fast to make a clicker. To be honest one active bar per time looks for me more logical, we can not buy, sell or close simultaneously. This is my draft clicker as a file, a lot must be improved of course. https://drive.google.com/file/d/15TuKY7B_nbd0LRDuZgkA4Pm5ESFMhoRe/view?usp=sharing
Code:
# These are the orders and Labels from the strategy (I plan to use a different strategy, but keep the logic for the labels - one for an action)

input ShowAutoKeyLabels = yes; #(I use Macro Recorder to auto trade. Ask me about the setup at [email protected])

#Open the orders on the chart for back testing and optimizing the settings

AddOrder(OrderType.BUY_TO_OPEN, diff > diff[1] and low > MA and (if UseVolumeAsFilter then VolStrength>0 else yes) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN, Color.CYAN, "");
AddOrder(OrderType.SELL_TO_CLOSE, ( diff < diff[1] or close < MA ) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN,Color.CYAN, "");
AddOrder(OrderType.SELL_TO_OPEN, diff < diff[1] and high < MA and (if UseVolumeAsFilter then VolStrength>0 else yes) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");
AddOrder(OrderType.BUY_TO_CLOSE, ( diff > diff[1] or close > MA )  and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");

#Add the signal labels (use with Macro Recorder or not)
def OpenOrders = GetQuantity();
AddLabel(ShowAutoKeyLabels and diff[1] > diff[2] and low > MA and OpenOrders < 1 and (if UseVolumeAsFilter then VolStrength>0 else yes),  "     BUY      ", CreateColor(153, 255, 153));
AddLabel(ShowAutoKeyLabels and ( diff[1] < diff[2] or close < MA ) and OpenOrders > 0, "     CLOSE     ", CreateColor(102, 0, 0));
AddLabel(ShowAutoKeyLabels and diff[1] < diff[2] and high < MA and OpenOrders > -1 and (if UseVolumeAsFilter then VolStrength>0 else yes), "     SELL     ", CreateColor(255, 102, 102));
AddLabel(ShowAutoKeyLabels and ( diff[1] > diff[2] or close > MA ) and OpenOrders < 0 , "     CLOSE     ", CreateColor(102, 0, 0));
 
Last edited:
There is only one label that we see at a time. Buy, Sell or Close. It distinguishes the color and clicks the Buttons. Very easy and simple, even for an absolute novice like me. For an experienced person like you it will be really easy and fast to make a clicker. To be honest one active bar per time looks for me more logical, we can not buy, sell or close simultaneously. This is my draft clicker as a file, a lot must be improved of course. https://drive.google.com/file/d/15TuKY7B_nbd0LRDuZgkA4Pm5ESFMhoRe/view?usp=sharing
Code:
# These are the orders and Labels from the strategy (I plan to use a different strategy, but keep the logic for the labels - one for an action)

input ShowAutoKeyLabels = yes; #(I use Macro Recorder to auto trade. Ask me about the setup at [email protected])

#Open the orders on the chart for back testing and optimizing the settings

AddOrder(OrderType.BUY_TO_OPEN, diff > diff[1] and low > MA and (if UseVolumeAsFilter then VolStrength>0 else yes) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN, Color.CYAN, "");
AddOrder(OrderType.SELL_TO_CLOSE, ( diff < diff[1] or close < MA ) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.CYAN,Color.CYAN, "");
AddOrder(OrderType.SELL_TO_OPEN, diff < diff[1] and high < MA and (if UseVolumeAsFilter then VolStrength>0 else yes) and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");
AddOrder(OrderType.BUY_TO_CLOSE, ( diff > diff[1] or close > MA )  and ShowBackTestPositions, open[-1], BackTestTradeSize, Color.RED, Color.RED,"");

#Add the signal labels (use with Macro Recorder or not)
def OpenOrders = GetQuantity();
AddLabel(ShowAutoKeyLabels and diff[1] > diff[2] and low > MA and OpenOrders < 1 and (if UseVolumeAsFilter then VolStrength>0 else yes),  "     BUY      ", CreateColor(153, 255, 153));
AddLabel(ShowAutoKeyLabels and ( diff[1] < diff[2] or close < MA ) and OpenOrders > 0, "     CLOSE     ", CreateColor(102, 0, 0));
AddLabel(ShowAutoKeyLabels and diff[1] < diff[2] and high < MA and OpenOrders > -1 and (if UseVolumeAsFilter then VolStrength>0 else yes), "     SELL     ", CreateColor(255, 102, 102));
AddLabel(ShowAutoKeyLabels and ( diff[1] > diff[2] or close > MA ) and OpenOrders < 0 , "     CLOSE     ", CreateColor(102, 0, 0));
Hi All,

I've been giving it some thought (Lord help us!) .. and believe the labels should be static because they always remain in the foreground. I'm going to change my code to display the label in white until it receives a signal.
 
Hallo Algo Traders, inspired by @dap711 I made my first simple auto trader with Macro Recorder. I found it easier since the script watches for specific color in order to activate itself. Here I attach my file with the Macro Recorder script. When the script sees lebel Buy it clicks Buy MKT button, lebel Sell - Sell MKT and Close-Flatten. I have one problem, the scripts clicks numerous time Buy or Sell when there is a signal. Please, help how to enter 1 time per direction. If you improve it, please share it here. The strategy may be any, it reads the colour of the labels. More useful info with label codes and nice made video explanation you may see here: https://usethinkscript.com/threads/moving-average-master-strategy-for-thinkorswim.13975/
P.S. I really like the last script written by @SilverWolf , but it is too complicated for an absolute beginner like me. May be he can make a video with very brief explanations of his code, logic and mainly chart positions of the labels, libraries, numbers in his GUI toolbar, etc.
Code:
"Mouse left click";"857, 17";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Go to label";"Buy";
"Mouse left click";"100, 167";
"Key Down";"Alt";
"Key press";"F";
"Key press";"B";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Sell";
"Mouse left click";"285, 167";
"Key Down";"Alt";
"Key press";"F";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Close";
"Mouse left click";"193, 167";
"Key Down";"Alt";
"Key press";"S";
"Wait";"5000 ms";

@NellyN .. This is because you are trading paper. This won't happen when trading real money. My latest code in the ASAP strategy has a fix with a "Trading Paper" switch.
 
Hallo Algo Traders, inspired by @dap711 I made my first simple auto trader with Macro Recorder. I found it easier since the script watches for specific color in order to activate itself. Here I attach my file with the Macro Recorder script. When the script sees lebel Buy it clicks Buy MKT button, lebel Sell - Sell MKT and Close-Flatten. I have one problem, the scripts clicks numerous time Buy or Sell when there is a signal. Please, help how to enter 1 time per direction. If you improve it, please share it here. The strategy may be any, it reads the colour of the labels. More useful info with label codes and nice made video explanation you may see here: https://usethinkscript.com/threads/moving-average-master-strategy-for-thinkorswim.13975/
P.S. I really like the last script written by @SilverWolf , but it is too complicated for an absolute beginner like me. May be he can make a video with very brief explanations of his code, logic and mainly chart positions of the labels, libraries, numbers in his GUI toolbar, etc.
Code:
"Mouse left click";"857, 17";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Wait for pixel color";"29, 235";
"Go to label";"Buy";
"Mouse left click";"100, 167";
"Key Down";"Alt";
"Key press";"F";
"Key press";"B";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Sell";
"Mouse left click";"285, 167";
"Key Down";"Alt";
"Key press";"F";
"Key Up";"Alt";
"Wait";"5000 ms";
"Go to label";"Close";
"Mouse left click";"193, 167";
"Key Down";"Alt";
"Key press";"S";
"Wait";"5000 ms";

@NellyN .. I see an issue with your srcipt.

Key presses are not needed if you chose to mouse click on the Buy and Sell buttons. I have active trader hot keys turned on and like using them instead of mouse clicks. The key presses I have setup is to flatten "ALT-F" the trades before issuing a buy or sell. That way, I know that order is the only thing being traded.
 
@NellyN .. I see an issue with your srcipt.

Key presses are not needed if you chose to mouse click on the Buy and Sell buttons. I have active trader hot keys turned on and like using them instead of mouse clicks. The key presses I have setup is to flatten "ALT-F" the trades before issuing a buy or sell. That way, I know that order is the only thing being traded. The logic is simple, the script sees the color of the label and clicks Buy, Sell or Flatten buttons of the platform. Than it moves back on top to wait for the next color (of the chart label).
Thanks a lot for your time helping me. Your idea with the Macro Recorder is wonderful. Here is the image of my last settings. This particular version of the script works with mouse clicks . The logic is simple, the script see the color of the label and clicks Buy, Sell or Flatten. After that the mouse moves back on top to wait for the next color(of the chart label). Final thought, the script loops and clicks numerous times the current label. If you put in the strategy limitation to have 1 open contract, it opens position, immediately closes, opens again, etc. . @dap711 has a good idea to remove labels once there is a position in the proper direction. May be this will be the right fix.
Another option - the label to change color once position is taken to a color that is not searched for?
 
Last edited:
Dear Kevin N, I
I'm going to save you guys hours of work. Here's the AHK script I have developed to work on any strategy. It's very simple and uses 3 color labels to do the following. White = Buy, Blue = Flatten, Orange = Short. You'll have to come up with your own strategy on what you feel works for you. As for this AHK script, I have commented on much of it to give some clear directions on how to use it. It has some error clearing features built in so if TOS throws up an error in the middle of the night it will clear it out.

Here's a link to the images I use. Wherever you put the script below, create a subfolder called images, then place the images from the url in that subfolder. In case they don't download as the default name, I put the proper name in the description.

Let's see if this works for the images...
Have fun....

Code:
; Version Beta .07 - Last Modified: 11-14-22 09:18 - Added option to disable pre-buy/sell flatten for quicker entries.
; double tap the flatten button.
; last mod creates a delay after trade closes and new trade allowed
; .07 Added entryPause Added error clearing feature.
; ver .062 Added pause for x number of minutes features.
; Made some adjustments to the screen and added auto status.  This version to be used with the algo version 5.5 or later.
#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, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

; CheapWindowsVPS_10
; User Defineable variables
; Use the following to set the vertical and horizontal coordinates for each.
buttonsHorizontal     = 130     ; Horizontal Coordinates, this will be the same for buy, flat, sell.
buyCoord              = 75     ; Vertical Coordinates, middle of button
flatCoord             = 150     ; Vertical Coordinates, middle of button
sellCoord             = 240     ; Vertical Coordinates, middle of button
statusHorizontal     = 125     ; The horizontal setting for the status bar
statusCoord          = 320     ; The vertical setting for the status bar
labelSearchX         = 275     ; How far to the right to search for the buy/sell label
labelSearchY         = 275     ; How far down to search for the buy/sell label

tradeLimit             = 5     ; How many trades are allowed in clearCounterPeriod before sitting out resetPeriod
resetPeriod         = 900     ; In Seconds, if tradeLimit is reached in clearCounterPeriod, how long to wait before another trade
clearCounterPeriod     = 1800     ; In Seconds, if tradeLimit is reached in this amount of time, sit out resetPeriod
entryDelay             = 0     ; In Seconds, the amount of time that must pass before another entry is allowed
exitDelay            = 0        ; In Seconds, Time that must pass after a trade exits before its allowed to buy again.
delayTime             = 0     ; In Seconds, the amount of time to wait sleep after buy, short, or flat.
entryPause            = 0        ; In Seconds, the amount of seconds to pause before pressing the buy/sell button.
flatBeforeEntry        = 0        ; In Seconds, amount of time to wait after pre-buy/sell flatten, if 0 then no pre-buy/sell flatten.
                            ;  - this is used to make sure we're flat before hitting the buy or sell entries buttons.
useTradovate        = 0     ; default is 1 (on), off is 0 (zero)
tradoBuyCoord          = 900    ; Vertical Coordinates, middle of button
tradoFlatCoord         = 1010     ; Vertical Coordinates, middle of button
tradoSellCoord         = 1135     ; Vertical Coordinates, middle of button
tradoAlignH            = 233    ; Alignment tool, this will be your horizontal setting for buy/Exit/Sell buttons.
tradoAlginV            = 1140    ; Alignment tool, this should align to the right of all your buttons.
tradoAlignT            = 0        ; 1 - yes, 0 - no, Use/display Align Tool

; End user defineable
status                 = 0
trades                 = 0
stopTimer             = 0
tosErrors            = 0

^B:: MouseClick, Left, %buyCoord%,  %buttonsHorizontal%, 1, 0
^F:: MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
^S:: MouseClick, Left, %sellCoord%, %buttonsHorizontal%, 1, 0
^P:: Pause
^E:: checkForErrors()
^R:: trades = 0  ; Reset the trades
^T:: stopTimer = 0
^D:: delayFunction(86400,"Waiting") ; 86400 = 1 Day
^F1:: delayFunction(3600,"Pausing for 1 hour")
^F2:: delayFunction(7200,"Pausing for 2 hours")
^F4:: delayFunction(14400,"Pausing for 4 hours")
^0:: status = 0 ; use this and the next two below to adjust trade status, 0 = Flat
^1:: status = 1    ; 1 = We are long
^2:: status = 2 ; 2 = We are short;

esc::
Main:
sleep 1000
a := entryDelay
;checkForErrors()

loop {
    sleep 1000
    a++
    b++
    if (status != 1 and a >= entryDelay or status == 2 and a >= entryDelay) {
        ImageSearch, FoundX, FoundY, 0, 0, %labelSearchX%, %labelSearchY%, *w50 *h15 *10 images\white.png
        if (ErrorLevel = 0) {
            if (entryPause > 0) {
                k := entryPause
                while (k > 0) {
                    tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                    sleep 1000
                    k--
                }
            }
 
            ;Click Flatten Button
            if (flatBeforeEntry > 0) {
                MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
 
                ;TradoVate ------------
                if (useTradovate == 1) {
                    MouseClick, Left, %tradoFlatCoord%, %tradoAlignH%, 1, 0
                }
                delayFunction(flatBeforeEntry, "Flat Before Next Entry")
            }
 
            ;Click Buy Button if green status and we're not already in a trade
            MouseClick, Left, %buyCoord%, %buttonsHorizontal%, 1, 0
 
            ;TradoVate ------------
            if (useTradovate == 1) {
                MouseClick, Left, %tradoBuyCoord%, %tradoAlignH%, 1, 0
            }
 
            status = 1
            a = 0
            trades++
            tooltip Status: Buy Image Cords: %FoundX% x %FoundY%, %statusCoord%, %buttonsHorizontal%
            sleep delayTime * 1000
            ;checkForErrors()
        }
    }
    if (status != 0) {
        ImageSearch, FoundX, FoundY, 0, 0, %labelSearchX%, %labelSearchY%, *w50 *h15 *10 images\blue.png
        if (ErrorLevel = 0) {
            ;Click Flatten Button
            MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
 
            ;TradoVate ------------
            if (useTradovate == 1) {
                MouseClick, Left, %tradoFlatCoord%, %tradoAlignH%, 1, 0
            }
 
            delayFunction(15, "Waiting to hit the flat button again")
 
            ; Lets hit the flat button again, to be sure after delay above
            if (useTradovate == 1) {
                MouseClick, Left, %tradoFlatCoord%, %tradoAlignH%, 1, 0
            }
            ;Click Flatten Button
            ; Let's hit TOS flat once more
            MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
 
 
            status = 0
            tooltip Status: Flat Image Cords: %FoundX% x %FoundY%, %statusCoord%, %statusHorizontal%
            sleep delayTime * 1000
            ;checkForErrors()
            delayFunction(exitDelay, "Next Entry is Delayed")
 
        }
    }
    if (status != 2 and a >= entryDelay or status == 1 and a >= entryDelay) {
        ImageSearch, FoundX, FoundY, 0, 0, %labelSearchX%, %labelSearchY%, *w50 *h15 *10 images\dark_orange.png
        if (ErrorLevel = 0) {
            if (entryPause > 0) {
                k := entryPause
                while (k > 0) {
                    tooltip Status: Delaying Entry: %k% Seconds, %statusCoord%, %buttonsHorizontal%
                    sleep 1000
                    k--
                }
            }
            ;Click Flatten Button
            if (flatBeforeEntry > 0) {
                MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
 
                ;TradoVate ------------
                if (useTradovate == 1) {
                    MouseClick, Left, %tradoFlatCoord%, %tradoAlignH%, 1, 0
                }
                delayFunction(flatBeforeEntry, "Flat Before Next Entry")
            }
 
            ;Click Sell (short)
            MouseClick, Left, %sellCoord%, %buttonsHorizontal%, 1, 0
 
            ;TradoVate -------------
            if (useTradovate == 1) {
                MouseClick, Left, %tradoSellCoord%, %tradoAlignH%, 1, 0
            }
 
            status = 2
            a = 0
            trades++
            tooltip Status: Short Image Cords: %FoundX% x %FoundY%, %statusCoord%, %statusHorizontal%
            sleep delayTime * 1000
            ;checkForErrors()
        }
    }
 
    timeLeft := clearCounterPeriod - b
    entryTime := FormatSeconds(a)
    countdownTime := FormatSeconds(timeLeft)
    FormatTime, TimeString,, Time
 
    ;tooltip Status: %status%  Trades: %trades%  Count: %TimeLeft%  Entry: %a%  Time: %TimeString%, %statusCoord%, %statusHorizontal%
    tooltip Status: %status% | Trades: %trades% of %tradeLimit% | Count: %countDownTime% | Entry: %entryTime% | Time: %TimeString% | Errors: %tosErrors%, %statusCoord%, %statusHorizontal%
 
    ; Tradovate
    if (tradoAlignT == 1) {
        tooltip "<----", %tradoAlignV%, %tradoAlignH%, 2
    }
 
    if (trades >= tradeLimit) {
        trades = 0
        ;Click Flatten Button
        MouseClick, Left, %flatCoord%, %buttonsHorizontal%, 1, 0
        sleep resetPeriod * 1000
        j++
 
        if (j == 2 ) {
            tooltip Reset Count: %j% Time: %TimeString%, %statusCoord%, %statusHorizontal%
            exit
        }
    }
    if (b >= clearCounterPeriod) {
        b = 0
        trades = 0
        checkForErrors()
    }
}

return

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time := 19990101  ; *Midnight* of an arbitrary date.
    time += NumberOfSeconds, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss
    /*
    ; Unlike the method used above, this would not support more than 24 hours worth of seconds:
    FormatTime, hmmss, %time%, h:mm:ss
    return hmmss
    */
}

delayFunction(SecondsToWait, Message )
{
    k := SecondsToWait
    global stopTimer = 1
    global statusCoord
    global statusHorizontal
    while (k > 0)
    {
        if (stopTimer != 1) {
            break
        }
        timeLeft:= FormatSeconds(k)
        tooltip %Message%: %timeLeft%, %statusCoord%, %statusHorizontal%
        sleep 1000
        k--
    }
    stopTimer = 0
}

checkForErrors()
{
    global statusCoord
    global statusHorizontal
    global tosErrors
 
    tosHorizontal := statusHorizontal - 30
    tooltip Errors:  %tosErrors% | %FoundX% x %FoundY%, %statusCoord%, %tosHorizontal%
 
    ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *50 images\tosWarningOK.bmp
    if (ErrorLevel = 0) {
            ;Clear the TOS Performance Issue Message
            FoundX:=FoundX+5, FoundY:=FoundY+5
            MouseClick, Left, %FoundX%, %FoundY%, 1, 0
            tosErrors++
            tooltip OK Warnings Cleared: %tosErrors% | %FoundX% x %FoundY%, %statusCoord%, %tosHorizontal%

    }
    ImageSearch, FoundX, FoundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *140 images\tosWarningContinue.png
    if (ErrorLevel = 0) {
            ;Clear the TOS Order Submit Error Message
            FoundX:=FoundX+10, FoundY:=FoundY+10
            MouseClick, Left, %FoundX%, %FoundY%, 1, 0
            tosErrors++
            tooltip CONTINUE Warnings Cleared: %tosErrors% | %FoundX% x %FoundY%, %statusCoord%, %tosHorizontal%
    }
 
    ; Lets mouse click top left to clear this weird drop down menu error I've received many times
    MouseClick, Left, 5, 5, 1, 0
 
    return
}

I forgot to mention above, run the script as administrator, that's the only way it will click the buttons for you. Also, to start the script hit the esc on your keyboard, then there are several keys I did not comment what they are, but should be kinda obvious, it's all the ones that have the ^ (Ctrl) in front of them, so Ctrl + F1 will pause the script for one hour, etc...
Dear @Kevin N , Dear @SilverWolf, I downloaded all images in subfolder images, the script in .AHK format, installed your strategy Fractal Chaos and started the script with Ctrl+Esc button. All vertical and horizontal coordinates are exactly the same and there was no need to make changes (screen size 15.6 inches, screen resolution, 1920 x 1080 Pixels ). Now I see the strategy labels and the AHK toolbar and have problems wit Image Search coordinates.

Corrected ImageSearch coordinates for the 3 color images as follows: ImageSearch, FoundX, FoundY, 20,171,175,185, *w50 *h15 *10 C:\Users\NelN\Desctop\Kevin_AHK\images\white.png. The script toolbar is visible with Windows+S buttons combination and right click of the mouse. Are ImageSearch coordinates expressed correctly?

Can you clarify where are on the TOS screen the buttons tosWarningContinue.png and tosWarningOk.png in order to correct image search settings and put coordinates or just share a picture of your chart with the buttons on it?
Please, explain what shall I do in addition to make the AHK script work. Did the script expect some key combination to be activated?

Thank you for your amazing job and for your patience to enlighten inexperienced users with AHK like me. I am very excited to put your AHK program into work, but need some very small and final help. With best regards, Nelly
 
Last edited:
Thanks a lot for your time helping me. Your idea with the Macro Recorder is wonderful. Here is the image of my last settings. The script works with mouse click, because I activated the Hot keys, but on simulation mode they did not work. The logic is simple, the script see the color of the label and clicks Buy, Sell or Flatten. After that the mouse moves back on top to wait for the next color(of the chart label). .


Looks much better! One thing .. it's not hurting anything, but you don't need to set focus to the app window after clicking the buttons. A mouse click on the buttons will do that for you. I set focus to the window in my script because I'm sending keystrokes.
 
This is a pretty simple "dumb" smart bot its a python based program.
the "bot" works perfectly as i envisioned it.

the only variable is the strategy being used to generate the signals(if you have a good strategy script that doesn't repaint, help a brother out).

how it works is pretty simple, see image on basics works and proof that it does.

daOZ7Zj.png


dNFMCk3.jpg
Can you give more information about this clicking Python bot?
 

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