DAS Trader Advanced Hotkeys 16
How to time your actions coding your own scheduler
Sometimes you want to do or block a thing at a certain time of the day. How can we do that when there is no scheduler available?
Let’s calculate the time
There is a function that calculates the seconds from the midnight. We can get the actual second of the day into a variable like this:
$MYTIME=getsecond();
This will populate the $MYTIME variable with a number
You can calculate the time with an online seconds to time calculator.
Here are some times for a reference
9:30 AM - 34200
9:35 AM - 34500
10:00 AM - 36000
3:55 PM - 57300
Use cases
For practical reasons, you can store those in variables on the start of your DAS Trader program. As these are all static, you can load them just once with the following code.
$930AM=34200;
$935AM=34500;
$10AM=36000;
$355PM=57300;
Scheduled voice reminders
Personally, I used to have a voice reminder telling me to calm down for a few months. I used a utility on Windows to accomplish that. I ran it in windows scheduler. Now if I want to be reminded that it is 10 o clock, I just use this script in my Event Timer Script
if(getsecond()==$10AM)
{
Speak("10 o clock");
}
As you can see, it is very simple to schedule an action if you know the exact time you want it to happen. If you need it to repeat, it is a bit more challenging but still possible.
Block you from taking trades before or after certain time.
If your stats say that you suck at trading at a certain time of the day, this can block you from doing it.
This use case is similar to the one described before, so I assume you are familiar with calling the saved hotkeys for opening a position.
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.