Exact Hour:Minute:Second action issue (onTick missing the time setting)
Exact Hour:Minute:Second action issue (onTick missing the time setting)
04 Jul 2022, 22:07
Dear all,
if i understood it correctly i can set my cBot to execute some actions onStart, onBars or onTick.
I wrote a cBot that can place an order at a specific time (hour:minute:second) under the onTick part of the code.
This sometimes fails since on that specific time there are no price changes and so the onTick doesn't fire the lines of the code.
How can i solve this issue? Is there a sort of "while True" loop that i can put in the code so that it doesn't miss my specific time setting?
Thanks in advance.
BR
P.
Replies
capanna.paolo
06 Jul 2022, 08:14
RE:
I solved it with the function onTimer, thanks!
firemyst said:
If it doesn't matter, why not just look for the first OnTick that happens after your specified time and execute the order then? So instead of checking if the time matches exactly, just check if onTickTime >= your specified time and if so, execute your actions. If you want it limited to only occur within a few seconds after your specified time, then pseudo logic would be:
if (onTIckTime >= yourSpecifiedTime && onTickTime <= OnTickTime + numberOfAllowedSecondsAfter)
{
// do what you have to do
}
If you do want it at the exact hour:minute:second and a tick doesn't come through, then there's nothing you can do as that's based on the market.
@capanna.paolo
firemyst
06 Jul 2022, 03:40
If it doesn't matter, why not just look for the first OnTick that happens after your specified time and execute the order then? So instead of checking if the time matches exactly, just check if onTickTime >= your specified time and if so, execute your actions. If you want it limited to only occur within a few seconds after your specified time, then pseudo logic would be:
if (onTIckTime >= yourSpecifiedTime && onTickTime <= OnTickTime + numberOfAllowedSecondsAfter)
{
// do what you have to do
}
If you do want it at the exact hour:minute:second and a tick doesn't come through, then there's nothing you can do as that's based on the market.
@firemyst