optimization does no trades when back testing trades perfectly.

 

Hi everybody!


I use custom indicator that draws trend lines.  And I trade on brake of line.

Works fine on back testing but does 000 trades on optimization run.


Please advise on why it could happen and how can I go around it.

Thanks in advance.


int start()
   {
   
   if (scan_trades(0,0)==0 && LastTrade !=Time[0])
      {
      iCustom(NULL,0,"Tredlines",AlertsOn, Comments, TrendLine,0,0);
      if(Open[0]>ObjectGetValueByShift("HL_1", 0) && Open[1]< ObjectGetValueByShift("HL_1",1) ) // BUY
         {
         if(iATR(NULL, 0, ATRPeriod,1)>ATRFilter)
            {
            buy();
            LastTrade = Time[0];
            }
         }
      if(Open[0]<ObjectGetValueByShift("LL_1", 0) && Open[1]> ObjectGetValueByShift("LL_1",1) ) // SELL
         {
         if(iATR(NULL, 0, ATRPeriod,1)>ATRFilter)
            {
            sell();
            LastTrade = Time[0];
            }
         }
        ObjectsDeleteAll();
      }
   if(scan_trades(0,0)>0)
      {
      trailing_stop();
      }
   return(0);
  }
 

Hi

Have you parameters to optimize ?

 
Matutin:

Hi

Have you parameters to optimize ?


Hi Matutin,

Not sure what you mean but I do simple optimization:
Take profit = 100, step 50, finish 150.

When optimizing takes 0 trades.


extern int        take_profit   =100;  
extern int        trailing_stop = 0;     
extern int        stop_loss     =600;
 
kanaps wrote >>

Hi Matutin,

Not sure what you mean but I do simple optimization:
Take profit = 100, step 50, finish 150.

When optimizing takes 0 trades.

And it's ok with just Testing ?

Nothing in the log ?

Do you use IsOptimization() in your code ?

 

Hi. Matutin, thanks for looking.


No. I do not use IsOptimization(). Indicator not using it as well.

Unfortunately when optimizing it doesn't return any messages so I can not test and see what part of the code doesn't work and why it doesn't buy/sell.

 
Make sure you have an optimisation parameter ticked and if it is profit make sure the profit of your runs does not exceed the optimisation profit value. I think it ignores runs that exceed the optimisation profit value so I always make sure the profit is 1000,000,000. You can't have too much profit :)
 
kanaps wrote >>

Hi. Matutin, thanks for looking.

No. I do not use IsOptimization(). Indicator not using it as well.

Unfortunately when optimizing it doesn't return any messages so I can not test and see what part of the code doesn't work and why it doesn't buy/sell.

Did you run in testing with Take profit = 100, then with Take profit = 150 and have some trade ? May be those parameters don't fit ?

also, check with some Print the value returned by iCustom(NULL,0,"Tredlines",AlertsOn, Comments, TrendLine,0,0);
when in optimization()

 
Ruptor:
Make sure you have an optimisation parameter ticked and if it is profit make sure the profit of your runs does not exceed the optimisation profit value. I think it ignores runs that exceed the optimisation profit value so I always make sure the profit is 1000,000,000. You can't have too much profit :)


Yep, I have used optimization in the past. Please see attached images.

Matutin:

Did you run in testing with Take profit = 100, then with Take profit = 150 and have some trade ? May be those parameters don't fit ?

also, check with some Print the value returned by iCustom(NULL,0,"Tredlines",AlertsOn, Comments, TrendLine,0,0);
when in optimization()


Yes, I run a few tests with different inputs but it seems EA doesn't take trades at all when optimizing.

Unfortunately Journal returns nothing when optimizing.  Do you know any way of getting a message out while optimizing?

It takes ages to do optimization. I think in optimization, iCustom has  limited time to run the indicator and it is not enough time for indicator.

I will try to strip the indicator. Do you have any other ideas?


you can see many trades done on normal testing (visual mode is off)

   

no trades when optimizing.

 
kanaps:


Do you know any way of getting a message out while optimizing?


All file functions work normally in optimization. Just output your debug messages to a simple text file.

 
gordon:

All file functions work normally in optimization. Just output your debug messages to a simple text file.


thanks, that could be a way of getting numbers back.
 

kanaps,

Did you ever solve this problem?  My original problem is, like yours, that Backtesting registers trades, Optimization registers ZERO trades.  In debugging, I've realized my EA oddly doesn't create an OBJECT during "Optimization" (which it successfully creates during Backtesting).  When I run "Optimization" and send the errors to a .txt file, according to the following code, I get error 4105 ("No order selected").  I'm confused--I believe I'm working with an OBJECT, not an ORDER.

I also fail to comprehend why this code successfully creates the OBJECT during Backtesting but fails during Optimization.

Any assistance would, as always, be greatly appreciated, jtd 

ObjectDelete("T1");
      if(!ObjectCreate("T1",OBJ_TREND,0,
                  Time_1, Y_1,
                  Time_2, Y_2)
                  )
      {
         int Error_code = GetLastError();

...
Reason: