need help, code doesnt work

 

'im new in mql4, and need help, this code doesnt work, but why?

it should open a trade if the price cross ichimoku, why it doesnt work? thanks

void OnTick()
  {

  
  double up= iIchimoku (NULL, 5,9,26,52,3,0);
  double down= iIchimoku (NULL,5,9,26,52,4,0);

  
  if (up && down < Bid  )
  
  { OrderSend (NULL,0,0.01,Ask,3, Bid-15*Point, Bid+10*Point);}
  
  
  }
 
if(MathMax(up,down)<Bid)
Check the return from the OrderSend() look it up in the documentation.

Your SL and TP are almost certainly too small. Bid+10*Point is most likely below the Ask opening price.
 
Keith Watford:
if(MathMax(up,down)<Bid)
Check the return from the OrderSend() look it up in the documentation.

Your SL and TP are almost certainly too small. Bid+10*Point is most likely below the Ask opening price.

i didn change the return ( dont know where to find it), but i changed SL and TP, i put two more 0, so that was the problem. Thanks

 

But now the strategy tester appears to open multiple orders, so how could i solve this new problem? Could you provide a code to limit to just 1 ordersend?

thanks 

 
mrluck1:

i didn change the return ( dont know where to find it),


Keith Watford:
Check the return from the OrderSend() look it up in the documentation.
mrluck1:

But now the strategy tester appears to open multiple orders, so how could i solve this new problem? Could you provide a code to limit to just 1 ordersend?


Check whether you already have an open order before placing a new order.

Every question that you may have has been asked and answered many times. Read some old posts and you can learn a lot.

You say that you don't know where to find out about the return from OrderSend(), yet right there in the documentation for OrderSend is

int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
   if(ticket<0)
     {
      Print("OrderSend failed with error #",GetLastError());
     }
   else
      Print("OrderSend placed successfully");



I told you to look it up in the documentation, but you obviously couldn't be bothered to read it.

I am sorry, but I am not going to write your code for you a line at a time. You have to do some research yourself.
Reason: