How do I control the number of "buy" ordersend?

 

Hi all...yes I'm a newbie and need some desparate help from some smart people :) Currently my EA places waaaaay too many trades while the conditions are met. It goes something like this:


if (conditions are true...)

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);

The problem, as I said above, is that the conditions may be true for 30 minutes...and in those 30 minutes it's placing one "buy" after another until the conditions stop being true. This is crazy!


How do I tell it to only place 1 "buy" and then another one 30 pips later and a 3rd one 30 pips after that ( no stop loss for now)?


Is that even possible??

 
rortiz77:

Hi all...yes I'm a newbie and need some desparate help from some smart people :) Currently my EA places waaaaay too many trades while the conditions are met. It goes something like this:


if (conditions are true...)

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);

The problem, as I said above, is that the conditions may be true for 30 minutes...and in those 30 minutes it's placing one "buy" after another until the conditions stop being true. This is crazy!


How do I tell it to only place 1 "buy" and then another one 30 pips later and a 3rd one 30 pips after that ( no stop loss for now)?


Is that even possible??

This very rough statement may help you on the right track:

if ( OrdersTotal() >=  MyMaxorders ) THEN there is NO place for more orders.

 
DayTrader:

This very rough statement may help you on the right track:

if ( OrdersTotal() >= MyMaxorders ) THEN there is NO place for more orders.

Once a ticket is placed...do how I move into buy1 the price that order 1 was at? I want to place a 2nd trade 30 pips after buy1. I have:


int ticket;
int buy_trade1=1;
int buy_trade2=1;
int buy_trade3=1;

int buy1;

int buy2;

int buy3;


while (count ==5)
{

if ( OrdersTotal() <= buy_trade1 ) // this allows me to enter the 1st trade...1 trade at a time
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);
count= 0;
}

 

Have a look at OrderSelect() and OrderOpenPrice(). In addition you may want to set a flag when order1 is sent, and another flag when order2 is sent, then

if flag 1 AND flag 2 is set place no more orders.

Are you trying to pyramide (scale into) a trade ?

Reason: