Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network is a distributed computing network. Just give it a try!
hhchenfx
886
hhchenfx 2014.06.09 23:28 

Hi,

I have a simple EA that take entry,sl,tp from some indicators and trade. 

It works fine. And then, I make few extension to my indicators.

When I run the EA again, on the chart, I see many wrong trades where: there is NO BUY Arrow on chart (from my indicator). Somehow, it still assign Entry price, TP, SL to that point.

One more note. Previously, I had this kind of problem when indicator has the format for(i=0...). I think the bar should be complete for signal to be calculated, so I turn into for(i=1...). I solved the problem. Now it show up again and I am out of trick. 

 Can you guess what cause the problem?

Thank you so much.

SCFX 

if(nearest!=Time[0])
{ 
  if(iCustom(NULL,0,"w_scratch4",6,12,9,18,0,1)!=EMPTY_VALUE   
      )
   {OrderSend(Symbol(),OP_BUY, 0.1, Ask, 30, 
      iCustom(NULL,0,"w_scratch4",6,12,9,18,2,1), 
      iCustom(NULL,0,"w_scratch4",6,12,9,18,3,1), 
      "robot buy", 123, 0, Blue);
   nearest=Time[0];
   }    

   else if(iCustom(NULL,0,"w_scratch4",6,12,9,18,1,1)!=EMPTY_VALUE 
      )
   {OrderSend(Symbol(),OP_SELL, 0.1, Bid, 30, 
      iCustom(NULL,0,"w_scratch4",6,12,9,18,2,1), 
      iCustom(NULL,0,"w_scratch4",6,12,9,18,3,1), 
   "robot sell", 123, 0, Red);
   nearest=Time[0];
   } 
Rodrigo Malacarne
Moderator
9742
Rodrigo Malacarne 2014.06.10 01:01  
hhchenfx:

Hi,

 Can you guess what cause the problem?

Thank you so much.

SCFX 

Hello hhchenfx, I'm still trying to understand what is the "trading logic" behind your code. I see not only a problem with the trading logic itself, but also from the programming point of view there are several mistakes in your code. For instance, try to use the function CopyBuffer if you need to take decisions according to values returned from custom indicators, instead of calling the iCustom function all the time.
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
hhchenfx
886
hhchenfx 2014.06.10 04:57  
Malacarne:
Hello hhchenfx, I'm still trying to understand what is the "trading logic" behind your code. I see not only a problem with the trading logic itself, but also from the programming point of view there are several mistakes in your code. For instance, try to use the function CopyBuffer if you need to take decisions according to values returned from custom indicators, instead of calling the iCustom function all the time.

Hi Malacarne,

I never used that CopyBuffer before. I will check it out.

With the problem at hand, I think I find the cause for that but do not know the solution yet.

I will post it on a different thread below.

http://forum.mql4.com/63469 

Thank you for your help.

SCFX 

Issue when buffer assign to bar (i+1) - MQL4 forum
  • www.mql5.com
Issue when buffer assign to bar (i+1) - MQL4 forum
Alain Verleyen
Moderator
29391
Alain Verleyen 2014.06.10 14:34  
Malacarne:
Hello hhchenfx, I'm still trying to understand what is the "trading logic" behind your code. I see not only a problem with the trading logic itself, but also from the programming point of view there are several mistakes in your code. For instance, try to use the function CopyBuffer if you need to take decisions according to values returned from custom indicators, instead of calling the iCustom function all the time.
Rodrigo, this is mql4 code. You can't use CopyBuffer.
Rodrigo Malacarne
Moderator
9742
Rodrigo Malacarne 2014.06.10 16:30  
angevoyageur:
Rodrigo, this is mql4 code. You can't use CopyBuffer.

My bad... didn't realized that! Thanks. 

Trinh Dat
36266
Trinh Dat 2014.06.11 06:05  
i think problem from indicator.
/
To add comments, please log in or register