ForexTester uses Borland Delphi time format for its functions like Time(), iTime() and others. So, if you use C++ compilers you should convert this time to C++ format.
Delphi format (TDateTime):
Delphi TDateTime is equals to double value. The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.
Following are some examples of TDateTime values and their corresponding dates and times:
0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am
C++ format (Unix format):
C++ time is an integer value that shows how many seconds passed sinse 01/01/1970.
Is there a way to select only those values for indicators like MACD as well as Ask(), Bid prices, etc, in each invocation of GetSingleTick() which correspond to the times shown on the graph for the timeframe set in the FT GUI?
I'm developing a MACD strategy, which works, but there are what appear to be false buy and sell signals which cause some problems. I think these are occuring due to jitter around MACD zero at the tick level, since GetSingleTick() seems to be called for each tick (is that correct?), rather than once every simulated 15 minutes (say) if I have my timeframe set to 15 minutes.
So, in my code, I'm looking for MACD changing from negative to positive in GetSingleTick(), to signal a buy, and I'm not always seeing all of those buy signals in the MACD graph. I think this is because the graph is set to a 15 minute timeframe, so the signals are smoothed out, compared to what's happening at the tick-level. I really want my code to respond only to the signals shown on the graph, for the selected timeframe.
I think what I'd like ideally is a GetTimeframeInterval() (or similar) to be called once every simulated 15 minutes, or whatever the timeframe is set to, synchronised with the graph, but I guess that's not currently possible?
What's the best way to synchronize your code in GetSingleTick() to make sure it selects only data for the same times as the graph is showing, for any given timeframe?
Posted: Sun Jul 14, 2013 8:29 am
I think I've worked out how to do this now, thanks.
I'm calling TimeCurrent() in GetSingleTick(), then using this value to work out the next expected time of interest based on the selected time-frame. So I ignore all the ticks apart from the ones that come through approx every 15 minutes, if the time-frame is set to 15 minutes. I hope this makes sense and is reasonable. If not, please let me know.
Re: How to work with time
Posted: Wed Dec 23, 2015 11:52 pm
The function "HourOf" is not in FT2 API, nevertheless this function is used in more than one Example code in "Scripts API", and so, I think "HarriForexTester" is right. The function "HourOf" must be added to library.
HourOf is a Delphi function (*1). The type of input of the HourOf function is TDateTime that really is a double type value (*2). In VisualC++ is there the type COleDateTime that stores date and time the same way TDateTime does (*2)(*3)(*4). The function COleDateTime::GetHour is the VisualC++ equivalent for HourOf (*5).