One trade per rule

To add comments, please log in or register
tito.vinicius
231
tito.vinicius  

Hi Guys,

How can I coding an EA so that it trades only 1 times and once that trade is close? i.e take profit is hit then don't trade again until the next rule signal...let me explain it in detail....If the trade has hit its TP then wait for other buy or sell signal. If another signal is not achieved, do not place any further trades...but at the moment my EA achieved another signal, opens another trade... 

Thanks

Tito.

Basic Principles - Trading Operations - MetaTrader 5
Basic Principles - Trading Operations - MetaTrader 5
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
Onarius Mandel
35
Onarius Mandel  

Dear Tito

Seeing your code would help since what u are saying is not really logical, i mean its like this if(something happens u want){open trade} then u just modify the the IF(....) to your need, but if u put your code here then i can help ya better!

the code is not doing something u didnt wrote so :D

hope it helps, if not then i await for your code

Onarius

tito.vinicius
231
tito.vinicius  

Thanks for your tip Onarius.

As you asked, follow the code:

void OnTick()

  {

//---

   

   if(PointA()>0 && PointA()<PointB() && PointA()>PointC())

     {

      if(UseRevTrade==false && Count(0)==0) OpenOrder(0);

      if(UseRevTrade==true && Count(1)==0) OpenOrder(1);

     }

   if(PointA()>0 && PointA()>PointB() && PointA()<PointC())

     {

      if(UseRevTrade==false && Count(1)==0) OpenOrder(1);

      if(UseRevTrade==true && Count(0)==0) OpenOrder(0);

     }


Supposes that buy rule is achieved "if(PointA()>0 && PointA()<PointB() && PointA()>PointC())" ok? And let's supposes that the price hit my TP. When the prices hit my TP the Long position is closed. However, if the buy rule is configured yet, another buy position will be open immediately.  

I don't wanna this. I wanna open another buy position if another buy or sell signal is configured. 

Thanks again bro. 

Files:
whroeder1
17942
whroeder1  
tito.vinicius: As you asked, follow the code: … another buy position will be open immediately. 
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Your code is if(condition) open. That will open an order every tick. Are you checking for previously open orders?
  3. You are looking at a signal. Act on a change of signal.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
tito.vinicius
231
tito.vinicius  
whroeder1:
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Your code is if(condition) open. That will open an order every tick. Are you checking for previously open orders?
  3. You are looking at a signal. Act on a change of signal.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum

Thanks for the advice. About question 2, i'm not checking for previously open orders.

To add comments, please log in or register