need help

 

Hi friends, i need help to code this simple EA, but it doesnt work on strategy tester, when i compile it it doesnt show any error, but just  a warning "return value of ordersend should be checked". So what should i do to 

this work? thanks

 

 

int OnInit()
  {
//---
   double Lot=0.01;
   bool cond1=false;
   double ichimoku= iIchimoku(NULL,5,9,26,52,5,0); // pegar o valor do ichimoku1
  
          
   if(Bid==ichimoku)

     { cond1=true;}

  if (cond1=true)

      { OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid -10 *Point,Ask+10 *Point);}


   return(INIT_SUCCEEDED);
  }
 
Google for this error: mt4 "return value of ordersend should be checked".
 
mrluck1:
   if(Bid==ichimoku)

Unlikely to happen - can price != price? 

mrluck1:

but just  a warning "return value of ordersend should be checked". 

 What are function return values? How do I use them?

 
mrluck1:

Hi friends, i need help to code this simple EA, but it doesnt work on strategy tester, when i compile it it doesnt show any error, but just  a warning "return value of ordersend should be checked". So what should i do to 

this work? thanks


OnInit is the wrong section for this code

 

1- I tried to google it yesterday, but only found issues related to builders, but its a code created by me, when i put on tester it doesnt make any trade.

2- if (bid==ichimoku) i think can happen, because ichimoku line is != than price for the most part of time. iIchimoku gets the ichimoku value, right?

3- So Oninit isnt recommended, so in what fuction it will work best?

 

Can anyone show me a code that can work, i would really apreciate, thanks for the help 

 

It's a warning and not an error.

It should still place the order.

It is just warning you hey, you did not check whether the order was successful or not.

Of course if you put it in oninit then there will only be one order so put it in OnTick() function.

 
mrluck1:

1- I tried to google it yesterday, but only found issues related to builders, but its a code created by me, when i put on tester it doesnt make any trade.

2- if (bid==ichimoku) i think can happen, because ichimoku line is != than price for the most part of time. iIchimoku gets the ichimoku value, right?

3- So Oninit isnt recommended, so in what fuction it will work best?

 

Can anyone show me a code that can work, i would really apreciate, thanks for the help 

Several reasons why it is very unlikely: 

  • Unless Bid is EXACTLY equal to ichimoku during the OnInit() call... no order. OnInit() is only called once.
  • Even if you move it to OnTick(), you will still find it unlikely that Bid is EXACTLY equal to ichimoku.
  • You set ichimoku to 5 (MODE_CHIKOUSPAN) and call shift 0. This will always be 0.
 
honest_knave Unless Bid is EXACTLY equal to ichimoku during the OnInit() call... no order. Bid is EXACTLY equal to ichimoku.
The == operand. - MQL4 forum
 

Can someone provide me a functional code, if price= ichimoku tenkansen, then ordersend  

for educational purpose. Thank you very much 

 

Your code is close.

1. Move it all from OnInit() to OnTick()

2. Change the mode:

double ichimoku= iIchimoku(NULL,5,9,26,52,MODE_TENKANSEN,0);

 3. Simplify:

if(Bid==ichimoku)
      { OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid -10 *Point,Ask+10 *Point);}

4. Correct your TP and SL

5. Understand that == is not good to use when comparing doubles. Check for a cross instead.

6. Understand that you should check your lotsize before placing an order

7. Understand that you should check the return code of OrderSend()

 

I did all you said, put on Ontick, changed to tenkansen mode, with still only that warning message, but no trade at all, could you help me again?

void OnTick()
  {
//---
     double Lot=0.01;
   bool cond1=false;
   double ichimoku= iIchimoku(NULL,5,9,26,52,MODE_TENKANSEN,0); // pegar o valor do ichimoku1
  
          
   if(Bid==ichimoku)

     { OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid -10 *Point,Ask+10 *Point);}
  }


 

Reason: