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...
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); }
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...
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.
- What are Function return values ? How do I use them ? - MQL4 forum
- The point is that you use the same exact values to create a tline or compute it's position.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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