trendline optimization

 

I'm having trouble optimizing a strategy that triggers trades from a trendline object.


Zero trades are being made when optimizing, however several trades are made when backtesting it.


iTime(NULL,PERIOD_H1,2), iLow(NULL,PERIOD_H1,2), iTime(NULL,PERIOD_H1,1), iLow(NULL,PERIOD_H1,1), 0, 0);

Even when I don't query another time frame I can't get the optimizer to make any trades. (I am showing the "worthless trades"

in the Optimized Results and 0 trades are made)


Anyone have any suggestions?


Thanks in advance

 
mql4jg:

I'm having trouble optimizing a strategy that triggers trades from a trendline object.


Zero trades are being made when optimizing, however several trades are made when backtesting it.


Even when I don't query another time frame I can't get the optimizer to make any trades. (I am showing the "worthless trades"

in the Optimized Results and 0 trades are made)


Anyone have any suggestions?


Thanks in advance


Can anyone else get optimization to work with a trendline object?

I'm not optimizing the trendline itself, but once a trend is established i trade around it and optimize the takeprofit and stoploss.


Anyone with a working example?

 
Looks like that trendlines CANT be optimized...
 
claudio_arrau2:
Looks like that trendlines CANT be optimized...
Yes they can, just don't rely on a physical trend line,  just use the data that the trendline is based on,  if you know where it starts and ends you can still use it.
 

And how is this possibe?

I generate a trendline with Code (with ObjectCreate) and then read the values of the line.

MaxValD=ObjectGetValueByShift("LH"+aiD,q)-High[q];


Then the Optimizer doesnt find the values of the Object (what is the trendline).
 
void TLine( string name, datetime T0, double P0, datetime T1, double P1){
   if( !ObjectCreate(name, OBJ_TREND, 0, T0, P0, T1, P1) ) ...
}
double TLGetValueByShift(datetime T0, double P0, datetime T1, double P1, int iShift){
   int    iBeg  = iBarShift(NULL,0, T0),
          iEnd  = iBarShift(NULL,0, T1);
   double slope = (p0 - p1) / (iEnd - iBeg);
   return(slope * (iShift - iBeg) + p0);
}
 
claudio_arrau2:

And how is this possibe?


Mathematics.
 

Thanks WHRoeder...that looks great, event though I don't understand 100%.

In TLine, what does the if statement (!ObjectCreate) is supposed to do?

I acutally do not need to really "print/draw" the trendline, I just need the values.


By the way, that example makes me think whether I should make the switch to MQL5 or not...

I am missing in MQL4 the portfolio testing feature, as my EAs take interdependencies between different Symbols (not testable in MQL4).
But the need to change the Broker as well (mine only supports MQL4)....and of course re-write the EAs and indicators...

 
claudio_arrau2:
In TLine, what does the if statement (!ObjectCreate) is supposed to do?
I acutally do not need to really "print/draw" the trendline, I just need the values.
  1. What are Function return values ? How do I use them ? - MQL4 forum
  2. The point is that you use the same exact values to create a tline or compute it's position.
 
;) right...this is school math actually ...thanks for bringing this to my attention, will finally make my testing live easier :)
Reason: