Load template problem

Back to topics list To post a new topic, please log in or register
avatar
16
dbarnabe 2016.01.30 12:37
 

Hi,

I making an EA and on that EA I need 3 EMAs displayed on the chart, with different colors. So I have  tried to use ICustom (my topic) and after some suggestions I'm trying to load the template that I have made. I have template on "C:\Users\...\MetaTrader - Install\profiles\templates" and mannually it works but when I try to run the EA on tester it gives an error that it can't find the template:

"...  Load_Template_v27-01-2016 EURUSD,Daily: File 'template_Forex_v2.pdl' not found in C:\Users\...\MetaTrader - Install\profiles\templates"

 I have tried an simple EA just to apllie te template, like on mql4 docs but I have one question:

- Can I load template on strategy tester? It doesn´t work when I run the EA...

- The 3 EMAs used in the EA are due to the EA EMAs or are 3 different EMAs, used by the template and only for display?

- Do I call ChartApplyTemplate on OnInit? 

- When I use a template in an new chart, manually though, it overrides the symbols that I have created with the EA! Will not happend the same when i call the template load function?

 

#property strict
#property indicator_chart_window

int OnInit()
  {
   string terminal_path=TerminalInfoString(TERMINAL_PATH);
   Print("Terminal directory:",terminal_path);
   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   Print("Terminal data directory:",terminal_data_path);
   
   if(FileIsExist("\\template_Forex_v2.tpl"))
     {
      Print("The file template_Forex_v2.tpl found in Files'");
      if(ChartApplyTemplate(0,"\\template_Forex_v2.tpl"))
        {
         Print("The template 'template_Forex_v2.tpl' applied successfully");
        }
      else
         Print("Failed to apply 'template_Forex_v2.pdl', error code ",GetLastError());
     }
   else
     {
      Print("File 'template_Forex_v2.pdl' not found in "
            +TerminalInfoString(TERMINAL_PATH)+"\\profiles\\templates");
     }
   return(INIT_SUCCEEDED);
  }

Thanks.

 

avatar
736
honest_knave 2016.01.30 12:55 #
 

There have been some issues with templates and visual testing. Have a look through these threads and you may find a workaround

https://forum.mql4.com/67878 

https://forum.mql4.com/67869 

There are probably other threads too if you search. 

avatar
16
dbarnabe 2016.02.03 01:09 #
 
honest_knave:

There have been some issues with templates and visual testing. Have a look through these threads and you may find a workaround

https://forum.mql4.com/67878 

https://forum.mql4.com/67869 

There are probably other threads too if you search. 

Thanks honest_knave,

I did read that "Adding templates to visual testing window is denied now" although angevoyageur saying that we can set our template BEFORE the strategy tester start to run. What I don't know is if we set by code on the EA!??

 So, what I have done was creating two templates and call it "Default.tpl" and "Tester.tpl" and I think that its working... the only problem that I'm seeing in this method is that when I optimize the EA I will have to change EMAs indicators on the chart to see if its working ok.

 I am correctly?

avatar
125
zirkoner 2016.02.03 14:42 #
 
dbarnabe:

Thanks honest_knave,

I did read that "Adding templates to visual testing window is denied now" although angevoyageur saying that we can set our template BEFORE the strategy tester start to run. What I don't know is if we set by code on the EA!??

 So, what I have done was creating two templates and call it "Default.tpl" and "Tester.tpl" and I think that its working... the only problem that I'm seeing in this method is that when I optimize the EA I will have to change EMAs indicators on the chart to see if its working ok.

 I am correctly?

Yes you are. It's a recurring issue to have the same parameters on your chart and EA.
avatar
16
dbarnabe 2016.02.04 00:20 #
 
zirkoner:
Yes you are. It's a recurring issue to have the same parameters on your chart and EA.

Thanks zirkoner.

I am now more cleared!

Back to topics list  

To add comments, please log in or register