Download MetaTrader 5

What are wrong in my Ea?

To add comments, please log in or register
80613536
23
80613536  

This is my first EA. This contains two "ordersend" one after other. If I run Ea in debug mode step by step all is ok. If I run EA in debug mode via F5 EA seize up on the second "ordersend". If I run Ea in normal mode it seize up on second "ordersend". There is someone that can help me? Tanks for every help. 

This is the code of my two ordersend:

Ticket_Buy=OrderSend(Symb, 4, Lot, prezzo_buy, 2, SL_buy, TP_buy); //invio ordine buy al server

       if(Ticket_Buy == -1)

          {

           gest_errore();

          } else

          {

           Alert ("Opened order Buy ",Ticket_Buy);

          }

        if(Fine == true)

          {

           break;

          }              

       Alert("The request was sent to the server. Waiting for reply..");

       Alert("Sleep prima");

       Sleep(2000);

       Alert("Sleep dopo");

       Ticket_Sell=OrderSend(Symb, 5, Lot, prezzo_sell, 2, SL_sell, TP_sell); // invio ordine al server

      

      if(Ticket_Sell == -1)

          {

           gest_errore();

          } else

          {

           Alert ("Opened order Sell ",Ticket_Sell);

          }

        if(Fine == true)

          {

           break;

          }        

Tanks for all Help. 

GBWT094114
3356
GBWT094114  
80613536:

This is my first EA. This contains two "ordersend" one after other. If I run Ea in debug mode step by step all is ok. If I run EA in debug mode via F5 EA seize up on the second "ordersend". If I run Ea in normal mode it seize up on second "ordersend". There is someone that can help me? Tanks for every help. 

This is the code of my two ordersend:

Ticket_Buy=OrderSend(Symb, 4, Lot, prezzo_buy, 2, SL_buy, TP_buy); //invio ordine buy al server

       if(Ticket_Buy == -1)

          {

           gest_errore();

          } else

          {

           Alert ("Opened order Buy ",Ticket_Buy);

          }

        if(Fine == true)

          {

           break;

          }              

       Alert("The request was sent to the server. Waiting for reply..");

       Alert("Sleep prima");

       Sleep(2000);

       Alert("Sleep dopo");

       Ticket_Sell=OrderSend(Symb, 5, Lot, prezzo_sell, 2, SL_sell, TP_sell); // invio ordine al server

      

      if(Ticket_Sell == -1)

          {

           gest_errore();

          } else

          {

           Alert ("Opened order Sell ",Ticket_Sell);

          }

        if(Fine == true)

          {

           break;

          }        

Tanks for all Help. 

I don't know what is wrong, but I think it will take long time for any EA to work profitably in MQL programming. I think we need this heavy code practises changed into much lighter code.
Omar Alkassar
2843
Omar Alkassar  

What bool fine do???

break use within loop sentence.

use return instead of break if you don't use loop

show us the full of the function code

if you don't use Fine to do something your code must be like this

Int ticket =OrderSend......
If(ticket >0)
{
  Alert("done");
  return; // return ticket if you use int function
  }
Else{
Alert(GetLastError());
.   }
80613536
23
80613536  
Omar AlKassar:

What bool fine do???

break use within loop sentence.

use return instead of break if you don't use loop

show us the full of the function code

if you don't use Fine to do something your code must be like this

Int ticket =OrderSend......
If(ticket >0)
{
  Alert("done");
  return; // return ticket if you use int function
  }
Else{
Alert(GetLastError());
.   }
Hi Omar AlKassar. I attach my mq4 file. Tanks for all help. Fabio Crippa
Files:
To add comments, please log in or register