Login Page - Create Account

Support Board


Date/Time: Fri, 31 Jan 2025 23:00:29 +0000



Post From: Calculation triggered by Time Value == comparison continues calculating after Time Values !=

[2019-06-01 03:21:38]
Tom Hanks - Posts: 20
Hello friends,

So I am triggering a calculation when two time values are equal. The first value I have defined as:
int RangeCloseTime = HMS_TIME(7, 1, 0);

time value 2:
int CurrentTime = sc.BaseDateTimeIn[sc.Index].GetTime();

Calculation:

if  (RangeCloseTime == CurrentTime)
    {
    SCString actualtime;
    actualtime.Format("actualtime is: %i", CurrentTime);
    sc.AddMessageToLog(actualtime, 0);
    SCString Rangetime;
    Rangetime.Format("RangeClosetime is: %i", RangeCloseTime);
    sc.AddMessageToLog(Rangetime, 0);
    CurrentTime = 0;
    }

So I thought that the current time, defined with sc.BaseDateTimeIn[sc.Index].GetTime(), should only equal the constructed time once per day and as a result only calculate once per day. It is calculating way more than that. The messages are just for confirmation of the readings. The multiple recalculations at the same time are messing up my trade logic.

How can I make this calculation only happen once, when the constructed time = the time of the current day?

My only guess as to why this is happening is that it is recalculating multiple times within the same second and it is not making a comparison down to the millisecond level.

I've been stuck on this for a long time, would you mind steering me towards victory?