Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 19:08:03 +0000



Post From: [User Discussion] - Scroll chart by chart through a chartbook at timed intervals.

[2024-07-10 18:04:41]
User14953 - Posts: 232
Use at your own risk though, using macro recorders is kinda spooky. When your cursor starts doing stuff on it's own it's unsettling, especially with a trading platform open.


Provides a timer to simulate the F9 keypress at the assigned interval.

#Persistent ; Keep the script running
SetTimer, CheckForTimer, 1000 ; Check every second if it's time to run the main function

; Global variables
global timerInterval := 0 ; Store the interval in milliseconds
global lastRunTime := 0 ; Store the last time the script ran

; The name of the Sierra Chart window (adjust if necessary)
windowTitle := "Sierra Chart"

; GUI to set the timer
Gui, Add, Text,, Enter interval in seconds:
Gui, Add, Edit, vIntervalInput w100
Gui, Add, Button, gSetTimer, Set Timer
Gui, Add, Button, gStopTimer, Stop Timer
Gui, Show

return

SetTimer:
Gui, Submit, NoHide
if (IntervalInput is not number)
{
MsgBox, Please enter a valid number.
return
}
timerInterval := IntervalInput * 1000 ; Convert seconds to milliseconds
lastRunTime := A_TickCount ; Reset the last run time
MsgBox, Timer set to run every %IntervalInput% seconds.
return

StopTimer:
timerInterval := 0
MsgBox, Timer stopped.
return

CheckForTimer:
if (timerInterval > 0 && A_TickCount - lastRunTime >= timerInterval)
{
lastRunTime := A_TickCount
GoSub, RunMainFunction
}
return

RunMainFunction:
; Activate the Sierra Chart window
IfWinExist, %windowTitle%
{
WinActivate
; Wait for the window to become active
WinWaitActive, %windowTitle%
; Simulate the F9 keypress
Send, {F9}
}
else
{
MsgBox, Sierra Chart is not running.
}
return

GuiClose:
ExitApp