Error optimizing trendline (TL) strategy

Questions about MultiCharts and user contributed studies.
User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Error optimizing trendline (TL) strategy

Postby MC_Prog » 18 Jan 2015

Hi,

I have a signal that draws TLs and trades based on associated logic.

The signal itself draws the TLs and trades them fine ...

until I attempt to optimize it.

All attempts at optimization immediately produce a TL_New failure.

Example error:

Image

This is in MC64 9.0 Build 10360. Is this a bug? Is there anything I can do about it?
Attachments
MC_TL_Opt_Error_01.png
Error when optimizing TL strategy
(7.93 KiB) Downloaded 1056 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Error optimizing trendline (TL) strategy

Postby TJ » 18 Jan 2015

Hi,
I have a signal that draws TLs and trades based on associated logic.
The signal itself draws the TLs and trades them fine ...
until I attempt to optimize it.
All attempts at optimization immediately produce a TL_New failure.
Example error:
Image
This is in MC64 9.0 Build 10360. Is this a bug? Is there anything I can do about it?
Without looking at your code and studying the details...
I can say, it is most likely caused by the date/time. You see, the date/time do not increment in decimals during optimization.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Error optimizing trendline (TL) strategy

Postby MC_Prog » 19 Jan 2015

Thanks TJ.

However, I'm a bit skeptical that that is issue.

The params to TL_New, in order are:

TL_New params - SwLoDate[1]: 1041122 SwLoTime[1]: 1800 SwLoVal[1]: 611.20 SwLoDate[0]: 1041209 SwLoTime[0]: 1800 SwLoVal[0]: 621.20

Nothing weird there.

The very first call to TL_New during the opt fails as shown, whereas when not optimizing the entire chart fills with TLs and simulates trades as it should.

Also, the same code optimizes fine in TS 9.1.

I'm thinking there may be some issue in MC involving the optimizer and the drawing objects.

I tried turning off multi-core opt as per here:

viewtopic.php?f=1&t=10663&hilit=core#p52794

but that did not seem to make any difference.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Error optimizing trendline (TL) strategy

Postby Henry MultiСharts » 29 Jan 2015

Hello MC_Prog,

If you still need help with this error - please send us (support@multicharts.com) the following information for further investigation:
- workspace you are using;
- in QuoteManager select the symbol you are using, make a right click on it->Export data->Export instrument (without data). Send me the Qmd export file for analysis;
- in PowerLanguage editor->File->Export->export with dependent functions the studies you are using in the workspaces you are providing. Send me the study export file;
- step by step instructions for replicating the error.

mrticks
Posts: 19
Joined: 19 Apr 2012
Has thanked: 2 times

Re: Error optimizing trendline (TL) strategy

Postby mrticks » 02 Feb 2015

Hi,

I have a signal that draws TLs and trades based on associated logic.

The signal itself draws the TLs and trades them fine ...

until I attempt to optimize it.

All attempts at optimization immediately produce a TL_New failure.

Example error:

Image

This is in MC64 9.0 Build 10360. Is this a bug? Is there anything I can do about it?
Hello MC_Prog,

Did you get this issue resolved? I have some signals with "tl_new" in them and it trades fine but I cannot optimise them. They backtest and trade with no issues but optimisation produces nothing. All fitness criteria columns show zero in each box.

Could you share how you resolved it please? I would love to be able to optimise signals that draw trendlines.

Picture of optimisation report window below, showing 0.00 in all fields.
Attachments
Optim_report.png
Picture of optimisation report window below, showing 0.00 in all fields.
(85.51 KiB) Downloaded 1116 times
Last edited by mrticks on 02 Feb 2015, edited 1 time in total.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Error optimizing trendline (TL) strategy

Postby MC_Prog » 02 Feb 2015

Hi. Unfortunately, I have no solution at this time.

As I mentioned above, the very first call to TL_New() fails if done while optimizing.

IMO, this is a bug in MC, and I would be surprised if they could not immediately reproduce it.
Last edited by MC_Prog on 02 Feb 2015, edited 1 time in total.

mrticks
Posts: 19
Joined: 19 Apr 2012
Has thanked: 2 times

Re: Error optimizing trendline (TL) strategy

Postby mrticks » 02 Feb 2015

Hi. Unf. I have no solution at this time. IMO, this is a bug in MC.
Thanks for the response. I've seen a project request for this feature and have voted for it.

Image

mrticks
Posts: 19
Joined: 19 Apr 2012
Has thanked: 2 times

Re: Error optimizing trendline (TL) strategy

Postby mrticks » 02 Feb 2015

Hi. Unfortunately, I have no solution at this time.

As I mentioned above, the very first call to TL_New() fails if done while optimizing.

IMO, this is a bug in MC, and I would be surprised if they could not immediately reproduce it.
I have a different issue to you, when I kick off an optimisation it looks like it is working but when finished produces zero parameters. All parameters show a field with 0.00 in them. It is a shame, as it would be really good to have this ability.

Thanks for taking a look.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Error optimizing trendline (TL) strategy

Postby ABC » 03 Feb 2015

MC ignores Trendlines in the optimization. Therefore without modifying the code you can't optimize the signals. The usual result is that of mrticks - an optimization report containing zeros for all combinations.
However I can imagine that this can create other issues like runtime errors, too.

Regards,
ABC

mrticks
Posts: 19
Joined: 19 Apr 2012
Has thanked: 2 times

Re: Error optimizing trendline (TL) strategy

Postby mrticks » 03 Feb 2015

MC ignores Trendlines in the optimization. Therefore without modifying the code you can't optimize the signals. The usual result is that of mrticks - an optimization report containing zeros for all combinations.
However I can imagine that this can create other issues like runtime errors, too.

Regards,
ABC

Hi ABC,

Thanks for the response.

When you say, "Therefore without modifying the code you can't optimize the signals." Does that mean it is possible to optimise trendline signals by modifying the code somehow? If so, would you have a sample of this?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Error optimizing trendline (TL) strategy

Postby ABC » 03 Feb 2015

Yes, this is what I mean. I don't have a sample code, but think of it like this:
When you draw a trendline you know the start and end point. So you can compute the slope and with this you can compute every point in the future. With that it's simple to substitute the trendlines.

Regards,
ABC
Hi ABC,

Thanks for the response.

When you say, "Therefore without modifying the code you can't optimize the signals." Does that mean it is possible to optimise trendline signals by modifying the code somehow? If so, would you have a sample of this?

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Error optimizing trendline (TL) strategy

Postby MC_Prog » 03 Feb 2015

MC ignores Trendlines in the optimization.
Intentionally? This is very surprising to me.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Error optimizing trendline (TL) strategy

Postby ABC » 03 Feb 2015

Yes, intentionally.

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: Error optimizing trendline (TL) strategy

Postby Mydesign » 19 Feb 2021

Hello,

I bumped into exact same problem with latest MC14: backtest with TL is Okay but optimization is broken (full of zeros as seen above). What's the deal ? Is it a known MC bug ? Is it a coding issue ? I just use TL_New(), TL_SetEnd() and TL_GetValue() keywords, nothing fancy.

Very frustrating :?

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Error optimizing trendline (TL) strategy

Postby lingwuchung » 19 Feb 2021

MC ignores Trendlines in the optimization.
Intentionally? This is very surprising to me.
Not surprisng to me at all and I am actually grateful if it does. I found that TL is adding unnecessary burden in optimizatin. You don't need to plot and see any every line in optimization. Therefore my signal will automatically switch off TL within my code by using:

if GetAppInfo(aioptimizing) = 1 then begin
ShowTL = false;
end else begin
ShowTL = true;
end;

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Error optimizing trendline (TL) strategy

Postby lingwuchung » 19 Feb 2021

Hi,

I have a signal that draws TLs and trades based on associated logic.

The signal itself draws the TLs and trades them fine ...

until I attempt to optimize it.

All attempts at optimization immediately produce a TL_New failure.

Example error:

Image

This is in MC64 9.0 Build 10360. Is this a bug? Is there anything I can do about it?
Change your code to skip TL during optimization. You will appreciate the amount of time saved in optimization.

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: Error optimizing trendline (TL) strategy

Postby Mydesign » 20 Feb 2021

So one actually needs to recreate maths behind TLs and substitue them in order to optimize them ? Oh well...

[Edit] Okay, for those wondering, I found a workaround by using these functions to compute TLs without actually drawing them:

Code: Select all

TLValue(StartPrice, StartBar, EndPrice, EndBar, TgtBar) or TLValueEasy(Price, StartBar, EndBar, TgtBar)
http://help.TS.com/10_00/eng/ ... ction_.htm
http://help.TS.com/10_00/eng/ ... ction_.htm

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: Error optimizing trendline (TL) strategy

Postby Mydesign » 22 Feb 2021

Not surprisng to me at all and I am actually grateful if it does. I found that TL is adding unnecessary burden in optimizatin. You don't need to plot and see any every line in optimization. Therefore my signal will automatically switch off TL within my code by using:

if GetAppInfo(aioptimizing) = 1 then begin
ShowTL = false;
end else begin
ShowTL = true;
end;
I just try that and did not notice any difference in optimization time. I guess, as already mentionned, MC just skips TLs during optimization: so no need to switch them off.

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Error optimizing trendline (TL) strategy

Postby lingwuchung » 22 Feb 2021

Not surprisng to me at all and I am actually grateful if it does. I found that TL is adding unnecessary burden in optimizatin. You don't need to plot and see any every line in optimization. Therefore my signal will automatically switch off TL within my code by using:

if GetAppInfo(aioptimizing) = 1 then begin
ShowTL = false;
end else begin
ShowTL = true;
end;
I just try that and did not notice any difference in optimization time. I guess, as already mentionned, MC just skips TLs during optimization: so no need to switch them off.
Ok. Maybe MC can skip the TL calls but it won’t skip other calculations before and after the TL. So I still prefer to skip them as well.

How many bars are u playing and how much time does it take to run one round?

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: Error optimizing trendline (TL) strategy

Postby Mydesign » 24 Feb 2021

Few thousands bars and few minutes optimizing... but nevermind my issue was about being able to optimize TLs, not about how long it would take. the TLValue() function does the trick.

User avatar
lingwuchung
Posts: 50
Joined: 03 Feb 2014
Has thanked: 6 times

Re: Error optimizing trendline (TL) strategy

Postby lingwuchung » 01 Mar 2021

Few thousands bars and few minutes optimizing... but nevermind my issue was about being able to optimize TLs, not about how long it would take. the TLValue() function does the trick.
ok, few thousands bars and few minutes shouldn't make a big difference. Mine is talking about 100K bars, 10K optimization possiblities and 10-20 hours to complete.


Return to “MultiCharts”