How to stop a secuence in a EA

 

Hello,

I´m making my own EA. So far I want to open 3 positions at the same time, but what happens is the EA get a bucle and starts to repeat that process a lot of times. I mean, the EA works fine, open the 3 positions, but after a second or less, it continues opening the same positions. I just want to open that positions once. So I tried to set a command to stop the loop, but it doesn´t work. Please anyone can help me? Here is the code that I have, but I get a error. Thanks.

<CODE REMOVED>

 
zenithb: I just want to open that positions once.
  1. So check if you have open positions and don't open more.

  2. Play video
    Please edit your post.
    For large amounts of code, attach it.
 
zenithb:

Hello,

I´m making my own EA. So far I want to open 3 positions at the same time, but what happens is the EA get a bucle and starts to repeat that process a lot of times. I mean, the EA works fine, open the 3 positions, but after a second or less, it continues opening the same positions. I just want to open that positions once. So I tried to set a command to stop the loop, but it doesn´t work. Please anyone can help me? Here is the code that I have, but I get a error. Thanks.

You need to read the Documentation for the functions you are trying to use.  OrderSend()  doesn't return a bool and doesn't take NULL for those parameters.

While you are at it,  read this:   What are Function return values ? How do I use them ?

 

Hi,


Thank you guys for your answer. WHRoeder, I don´t understand what that video means.


RaptorUK, I´m a newbie, actually I just start to program the EA yesterday. The EA that I need is pretty simple, I just want to open a few positions at the same time, without TP or SL. That´s why I set NULL.

I had on the link OrderSend(), but I didn´t get what I need. What I need is just to stop the bucle.

I know for experts programmers it sound like weird, but is just what I need.

I appreciate any help, thank you.

 
zenithb:

Hi,

Thank you guys for your answer. WHRoeder, I don´t understand what that video means.

It shows you how to correctly post code to this Forum,  please edit your first post using the   SRC  button  as per the animated GIF  (movie)
 
zenithb:


RaptorUK, I´m a newbie, actually I just start to program the EA yesterday. The EA that I need is pretty simple, I just want to open a few positions at the same time, without TP or SL. That´s why I set NULL. 

NULL is wrong, read the documentation and use the correct parameters.
 
int start()                               
  {  
  OrderSend("EURUSD",OP_BUY,0.1,NULL,NULL,NULL,NULL);                                  
  OrderSend("AUDUSD",OP_SELL,0.1,NULL,NULL,NULL,NULL);
  OrderSend("GBPUSD",OP_BUY,0.1,NULL,NULL,NULL,NULL);

 
if (OrderSend("EURUSD",OP_BUY,0.1,NULL,NULL,NULL,NULL)==true);  {
   stoptrading=true;
  } 
  
   return;

    }

I guess now I posted the code correctly.

Anyway RaptorUK, if I have posted my question here, is because I was reading and researching in this site about how to set up my EA properly before and I didn´t success.

I know how to program in CSS and HTML. When someone ask for help, I give him the exact code that he need, not a link.

And I don´t why you are saying NULL is wrong. My EA it works, it opens correctly the pairs that I want. The only thing that I have to do, is to stop the bucle.

 
zenithb:

I guess now I posted the code correctly.

Anyway RaptorUK, if I have posted my question here, is because I was reading and researching in this site about how to set up my EA properly before and I didn´t success.

I know how to program in CSS, HTML, ActionScript and PHP. When someone ask for help, I give him the exact code that he need, not a link.

And I don´t why you are saying NULL is wrong. My EA it works, it opens correctly the pairs that I want. The only thing that I have to do, is to stop the bucle.

then use condition stoptrading

if(!stoptrading)
  {
   OrderS....
   .....
   ....
  }
NULL is a string  not 0 or zero   read documentation about double, int, datetime, string......
 
zenithb:

I guess now I posted the code correctly.

Anyway RaptorUK, if I have posted my question here, is because I was reading and researching in this site about how to set up my EA properly before and I didn´t success.

I know how to program in CSS and HTML. When someone ask for help, I give him the exact code that he need, not a link.

And I don´t why you are saying NULL is wrong. My EA it works, it opens correctly the pairs that I want. The only thing that I have to do, is to stop the bucle.

I did say please when I asked you to edit your first posting . . .  if you had done that there would have been no need to post your code again.

Just because your code works doesn't mean it is correct.  If you look at the documentation for NULL it says . . .   "Indicates empty state of the string." Open Price, TP, SL, Slippage  are not strings.  How are you managing to place a market order at a price of NULL ?

What is "bucle" ?  loop ?  start() is called on each tick,  if you want to stop your 3 OrderSend() calls then check how many trades you currently have open, if more than x  don't place your new orders,  use OrdersTotal()  but bear in mind this is all orders not just the ones placed by your EA.

 

If you want someone to write your code for you go here:  MT4 & MT5 coding 

 
int start()                                  
  {   
  OrderSend("EURUSD",OP_BUY,0.1,0,0,0,0);                                  
  OrderSend("AUDUSD",OP_SELL,0.1,0,0,0,0);
  OrderSend("GBPUSD",OP_BUY,0.1,0,0,0,0);
  
if (OrderSend("EURUSD",OP_BUY,0.1,0,0,0,0)==true)  {
   Alert( "WORKS");
  }  

    }

Ok I changed NULL for 0.

I tried to see if the condition works, but it doesn´t. Do you know why?

 
zenithb:
I guess now I posted the code correctly.
I know how to program in CSS and HTML. When someone ask for help, I give him the exact code that he need, not a link.
  1. You could have edited your original post as requested, instead of reposting using SRC.
  2. We are not going to give you the exact code because that way you learn nothing and will ask again at the next trivial problem.
  3. Read the documentation and links that RaptorUK gave you and fix the existing code. Then do my suggestion for your problem.
  4. This is what you posted:
    Your code.
    Engrish equivalent.
    if(OrderSend("EURUSD",OP_BUY,0.1,NULL,NULL,NULL,NULL)==true); {
       stoptrading=true;
    } 
    
    To Broker: Please buy 10,000 Euros at Orange plus or minus Lemon, if market goes above Banana or below Strawberry sell them.
    If broker's reply is Blue, do nothing.
    Always stop trading

    Now get off your high horse, "I give him the exact code, wah wah wah." You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
Reason: