Download MetaTrader 5

constantly spams trades, but i want just one.

To add comments, please log in or register
1000 developers are involved in Freelance service activity. Sign up!
Nauris Mucenieks
839
Nauris Mucenieks 2015.05.21 16:00 

hey guys, was wondering if anyone could correct my mistake here -

i want the code to read what types of orders are opened more - long's or short's - and then open an opposite trade, with an equal amount of lot sizes.

i know the build is wrong, for it checks the total number of trades, not the lotsizes, but ill fix that later - for now the issue is following -

when the X % percentage is reached, it just constantly opens trades, till it reaches maximum.

i presume i've managed to loop it, but dont know how to make it check for the condition once.


help much appreciated.


if(AccountEquity()<=accountbalance-(accountbalance/100*KICKER_Percent)){
     
  
      
   
     
   
     
     if ( nSell   >  nBuy )                
      return  OrderSend(Symbol(),OP_BUY,( kicker_mul*(OrderLots() ) )    ,Ask,Slippage,0,(Ask + (TP * reopen_dis_mul)*_Point*mult),"BUY",MagicNumber,0,clrGreen); 
      if ( nSell = nBuy )
     return; 
   
     
     if( nBuy   >  nSell  )          
      return    OrderSend (Symbol(),OP_SELL,(kicker_mul*(OrderLots() ) )    ,Bid,Slippage,0,(Bid -  (TP * reopen_dis_mul)*_Point*mult),"SELL",MagicNumber,0,clrGreen);
     if ( nSell = nBuy )
     return; 
     
 
     
 }}
     
Alain Verleyen
Moderator
30721
Alain Verleyen 2015.05.21 16:13  
Not enough information to help you.
Dr.Trader
3783
Dr.Trader 2015.05.21 19:20  

If I understand correctly, this is hedging advisor which will hedge all open orders if equity drawdown reaches certain percent?

I can see couple of problems:

1) you should update nSell and nBuy after ordersend

2) single "=" cannot be used for comparison. I don't know how this is done in mql, but in c++  "if ( nSell = nBuy )" will be executed following way:

nSell = nBuy;

if(true)
  ... 

 

 use this instead:

if ( nSell == nBuy )

 

I have no idea if this will help or not :) Need more source code. 

Nauris Mucenieks
839
Nauris Mucenieks 2015.05.22 13:15  
Dr.Trader:

If I understand correctly, this is hedging advisor which will hedge all open orders if equity drawdown reaches certain percent?

I can see couple of problems:

1) you should update nSell and nBuy after ordersend

2) single "=" cannot be used for comparison. I don't know how this is done in mql, but in c++  "if ( nSell = nBuy )" will be executed following way:

 

 use this instead:

 

I have no idea if this will help or not :) Need more source code. 

Yup, that's the grand idea.
I'll check out later whether it works or not, but thanks!

Also, that's pretty much there is, asides all the other stuff - for this function that's it.
To add comments, please log in or register