HGI and strategy tester

Locked
BobbyT
Trader
Posts: 232
Joined: Thu Aug 21, 2014 1:34 am
Location: Seattle

HGI and strategy tester

Post by BobbyT »

Stop stop stop!!! Don't delete my account (or relegate me to the cretin bin)!!!!. I would like to ask something. Seriously.

I'm curious as to why harvesting signals from HGI with hgi_lib is a bad idea. Let me explain.

I get HGI constantly updates itself, which is awesome. It makes HGI what it is. BUT, if my strategy calls for bar1 and older and I call hgi_lib for bar1 or older, won't those signals be valid at Time[0]?

I get that these signals will not be updated (unless the lib is called every tick) but if my strategy says:

Code: Select all

if(time0 != Time[0]) {
       bar1_signal = getHGISignal(Symbol(), Period(), 1);
       if(bar1_signal != 0) {
             doStuff();
       }
}
then shouldn't the bar1 signal be valid for that point in Time[0]? I'm not interested if it's there in 1 minute, 4 minutes or 30 minutes into bar0, just if it exists @ Time[0].

If this is true, and my account still exists, and you're still reading this, does the same apply to any calls to

Code: Select all

getHGISignal(Symbol(), Period(), 0);
That is, they are only valid for the first tick at bar0. Or is there something about the way HGI works that makes a call to bar0 not valid at all.

I'm certain I'm missing something about the way the tester actually works. But I'm not sure what it is. I get the strategy tester is a joke for a whole host of reasons but what is it specifically about the strategy tester and/or HGI, in this situation, that makes the above proposal a bad idea.

Looking forward to posting again some day :cry:
BobbyT
Procrastination provides exponentially negative returns - BobbyT
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

HGI and strategy tester

Post by renexxxx »

You are not saying what time0 is equal to, but let's assume for a moment that

Code: Select all

time0 = TimeCurrent()
and that you code is executed OnTick():

Code: Select all

void OnTick() {
   SIGNAL bar1_signal = NONE;
   datetime time0 = TimeCurrent();
   if ( time0 != Time[0] ) {
       bar1_signal = getHGISignal( _Symbol, _Period, 1);
       if( bar1_signal != NONE ) {
             doStuff();
       }
   }
   // ...
}
Further, let's assume that the TimeFrame selected in the tester is H1 (or H4 ... whatever, but higher than M1), So, in the code _Period is H1. Now, I don't know exactly how the Strategy Tester works (no one does), but I believe it is using M1 data to simulate tick-data to send to the OnTick() function (so 60 ticks per H1). As HGI can be repainting, it is possible that getHGISignal( _Symbol, _Period, 1) returns a different value for the 5min tick than for the 22min tick, if that makes sense. True, both calls refer the previous H1 candle, but new price data on the current bar (bar0), can make a difference to the result (due to repainting).

I have no idea if this answers your question, but there is one thing you must keep in mind: Take the results from the Strategy Tester with a grain of salt. It is almost not worth the exercise, as you can not believe positive results (although, you'd like to).
BobbyT
Trader
Posts: 232
Joined: Thu Aug 21, 2014 1:34 am
Location: Seattle

HGI and strategy tester

Post by BobbyT »

renexxxx » Mon Nov 21, 2016 7:37 pm wrote:You are not saying what time0 is equal to, but let's assume for a moment that

Code: Select all

time0 = TimeCurrent()
and that you code is executed OnTick():

Code: Select all

void OnTick() {
   SIGNAL bar1_signal = NONE;
   datetime time0 = TimeCurrent();
   if ( time0 != Time[0] ) {
       bar1_signal = getHGISignal( _Symbol, _Period, 1);
       if( bar1_signal != NONE ) {
             doStuff();
       }
   }
   // ...
}
Further, let's assume that the TimeFrame selected in the tester is H1 (or H4 ... whatever, but higher than M1), So, in the code _Period is H1. Now, I don't know exactly how the Strategy Tester works (no one does), but I believe it is using M1 data to simulate tick-data to send to the OnTick() function (so 60 ticks per H1). As HGI can be repainting, it is possible that getHGISignal( _Symbol, _Period, 1) returns a different value for the 5min tick than for the 22min tick, if that makes sense. True, both calls refer the previous H1 candle, but new price data on the current bar (bar0), can make a difference to the result (due to repainting).

I have no idea if this answers your question, but there is one thing you must keep in mind: Take the results from the Strategy Tester with a grain of salt. It is almost not worth the exercise, as you can not believe positive results (although, you'd like to).
Hi Rene,

Thanks for dropping in :clap:

About the time0, sorry. I should have included that but I thought the Time[0] would do the explaining. Well, you know what they say about assumptions :smile:
Anyway, time0 = Time[0] at the end of each iteration. Just so the wrapper I've written only executes once per bar. This is why I reference 'first tick of the bar'.

That's an interesting idea about building higher TF bars from M1 bars. I had seen someone reference constrained random tick generation over on MQL4 forum at some stage. Either way I was aware that the 'tick' structure of each bar is essentially B.S. That enough is normally enough for me to stay away from it.

So why am I at it then you ask? Because in this instance, HGI will be an entry only signal with no further action taken for repainting or opposite signals. In this way it doesn't matter what part of the bar the signal appears, weather it be the 5th or 22nd 'tick', just that it's there.

However when it comes to actual strategy testing, this of course introduces problems with order open prices with the 'appearance' of signals on any given bar. And really, prices are what it's all about. Would it acceptable to just look at bar1/2 at bar0 and use bar0 Open price and ignore the timing? Probably not. Although given a big enough dataset, the random error introduced in entry point should approach some mean value.

I would really like to integrate HGI into an R project I've just started working on. But without a way to extract proper signals I may have to drop it. Unless I get super, super lucky and someone with R/C skills, a damn big heart and access to the code may whip something up :xm:

Cheers,
BobbyT
Procrastination provides exponentially negative returns - BobbyT
Locked

Return to “Coders Hangout”