Download MetaTrader 5

Problems found during the back testing and can't find the root cause!

To add comments, please log in or register
Sell your applications via the Market. It is secure!
moonsboy
889
moonsboy 2015.04.24 09:33 

Please refer to the screenshot below after back testing.

3 questions on the strange things are shown in the picture too.

I read iCustom usage and check my EA and indicator again and again, finally can't find the root cause.

Please help urgently and thanks a lot ! 

 

(*. You can click the screenshot to open and enlarge it to see the questions more clearly) 

 

 

 

 This is the critical codes for the indicator "Reverse" (other codes were replaced with "..." so that it's clear for the critical codes):

int OnInit()
  {
   IndicatorBuffers(8);
   ....
   SetIndexBuffer(6,ExtBuffer1);
   ....
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   ...
   ...

   for(i=limit-1; i>=0; i--)
     {
      ...
      Value=...;
      ExtBuffer0[i]=MathLog((1+Value)/(1-Value));
      if(ExtBuffer0[i]>0) ExtBuffer1[i]=10;
      else ExtBuffer1[i]=-10;
     }

   ...
   ...
  }

 

 This is the critical codes in the EA to use the indicator(other codes were replaced with "..." so that it's clear for the critical codes):

 

...
...

void Reverse()
  {
   Joy1=iCustom(Symbol(),0,"Reverse",6,1);
   Joy2=iCustom(Symbol(),0,"Reverse",6,2);
  }

void openPosition()
  {
   ...
   if(Joy2<=-10 && Joy1>=10) 
    {
    r=OrderSend(Symbol(),OP_BUY,lotSize,Ask,slippage,0,0,TradeComment,MAGIC,0,clrMediumBlue);
    ...
    }
   else if(Joy2>=10&& Joy1<=-10) 
    {
    r=OrderSend(Symbol(),OP_SELL,lotSize,Bid,slippage,0,0,TradeComment,MAGIC,0,clrMediumVioletRed);
    ...
    }
   ...
   }
void closePosition()
  {
   ...
    if(openType==OP_BUY && Joy2>=10 && Joy1<=-10)
     for(i=OrdersTotal();i>=1; i--)
         if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==MAGIC)
           {
            r=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,clrDodgerBlue);
            ...
            }
   else if(openType==OP_SELL && Joy2<=-10 && Joy1>=10) 
    for(i=OrdersTotal();i>=1; i--)
         if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==MAGIC)
           {
            r=OrderClose(OrderTicket(),OrderLots(),Ask,slippage,clrDeepPink);
            ...
            }
   ...  
  }
void OnTick()
  {
   ...
   Reverse();
   openPosition();
   closePosition(); 

  } 

moonsboy
889
moonsboy 2015.04.24 10:24  

Now I re-create the indicator file and the yellow line drawing issue was resolved.

However, those another 2 issues still haven't any idea. Please help !  

ffoorr
1017
ffoorr 2015.04.24 11:04  

The problem probably come from your indicator

 if(ExtBuffer0[i]>=0) ExtBuffer1[i]=10;
      else ExtBuffer1[i]=-10;

check also your EmptyValue

moonsboy
889
moonsboy 2015.04.25 01:06  
ffoorr:

The problem probably come from your indicator

check also your EmptyValue

 

Dear ffoorr, there should be no empty value as you can see with the yellow line. 

 

ffoorr
1017
ffoorr 2015.04.25 08:59  

  what if    if(ExtBuffer0[i]==0)   

 following what is in your SetIndexEmptyValue, you would have a hole, a nothing,

The line would not be printed untill the next two data.


Otherwise check the index of your indicator, look like the signal is one bar late

Otherwise no one can know without seeing the indicator code


Are you using some fisher indicator ?

moonsboy
889
moonsboy 2015.04.27 10:58  

Dear ffoorr, thanks a lot for help. But I checked the indicator with codes and can confirm there is no empty value.

I re-installed tick story and MT4, the problem is still there. So I'm still checking.  

ffoorr
1017
ffoorr 2015.04.27 12:32  

jollydragon

if there is no SetindicatorEmptyValue, then the emptyvalue is EMPTY_VALUE

then if you code   if(  ExtBuffer1[i]  != 10 ) Open_Order()

if  ExtBuffer1[i] is ==  EMPTY_VALUE , you will have an order


But I can't know either if this is the cause of the problem

moonsboy
889
moonsboy 2015.04.28 02:07  

Dear ffoorr, I added codes to show the data of ExtBuffer1[i] if ExtBuffer1 isn't 10 or -10. Finally I got nothing and it proves ExtBuffer1 is 10 or -10 for every bar.  

I also updated the indicator to only 2 buffers with 2 lines. You can see 1 in white and 1 in yellow. I use the data of yellow line in my EA.

Please refer to the data below,  you can see when the order changes, it exactly was caused because the data of yellow line got is changing. '1' below means the yellow line data of the bar just before order opens or closes, '2' mean the yellow line data of the bar before '1'. That is also how I handle order opening and closing.  

I also checked the indicator code again and again, so I can confirm the indicator is calculated based on the bars before it and thereby not a fisher indicator.

However, you can see the orders change still not consistent with the yellow line(signal).  

It's so strange ! What can be the possible root cause? Who can help and I will be so grateful?

 

2013.04.30 04:00:00:    1: -10.0, 2:  10.0-error:       0

2013.04.30 08:30:01:    1:  10.0, 2: -10.0-error:       0

2013.04.30 08:30:02:    1:  10.0, 2: -10.0-error:       0

2013.04.30 09:30:00:    1: -10.0, 2:  10.0-error:       0

2013.04.30 09:30:00:    1: -10.0, 2:  10.0-error:       0

2013.04.30 16:30:00:    1:  10.0, 2: -10.0-error:       0

2013.04.30 16:30:00:    1:  10.0, 2: -10.0-error:       0

2013.05.01 18:00:00:    1: -10.0, 2:  10.0-error:       0

2013.05.01 18:00:00:    1: -10.0, 2:  10.0-error:       0

2013.05.01 22:00:00:    1:  10.0, 2: -10.0-error:       0

2013.05.01 22:00:00:    1:  10.0, 2: -10.0-error:       0

2013.05.01 22:30:00:    1: -10.0, 2:  10.0-error:       0

2013.05.01 22:30:00:    1: -10.0, 2:  10.0-error:       0

2013.05.02 15:30:00:    1:  10.0, 2: -10.0-error:       0

2013.05.02 15:30:00:    1:  10.0, 2: -10.0-error:       0

2013.05.02 16:03:26:    1:  10.0, 2:  10.0-error:       0

 

 

moonsboy
889
moonsboy 2015.04.28 08:51  
Oh, my god. I still haven't any idea with this. What's wrong?
whroeder1
14532
whroeder1 2015.04.28 12:38  
jollydragon: Oh, my god. I still haven't any idea with this. What's wrong?
  1. How the heck should we know? You haven't posted all the code.(No indicator, no iCustom, no loops)
  2. You say, the indicator still has a 10, but the (first) image shows gaps. We have no idea where you cursor was. Was it over the gap?
  3. You have no idea because you have no information. Add print statements before and inside if including variable values and track it down.
moonsboy
889
moonsboy 2015.04.29 07:28  

Dears, in fact I've subtracted the critical codes for you to save your time.

However, your help is highly appreciated and here let me attach the files of both EA and indicator.

Please note the file names changed automatically after attached. There is a random letter inserted between 2 words. In my computer, they are "Trade Joy" and "Solar Joy".  

 

Looking forward to the solution. :-)

Files:
tradebjoy.mq4 12 kb
trademjoy.ex4 17 kb
12345
To add comments, please log in or register