1 Buy and 1 Sell position per bar

 

Hi, this is manual for trade (buy or sell) only once per 1 bar.

Up at the top where you declare your veriables put


static bool ITradedOnThisBar;


then where you send your order put


if(your critera && ITradedOnThisBar!=Bars)
{
ticket=OrderSend(Symbol(),OP_BUY,... );
ITradedOnThisBar = Bars;

}

But what i have to chance to open maximum 1 buy and 1 sell (2 trades) position per one bar? Thank you.

 
Don't use Bars . . . it's not a reliable method, use time instead. You can use one variable for Buys, one for Sells.
 
RaptorUK:
Don't use Bars . . . it's not a reliable method, use time instead. You can use one variable for Buys, one for Sells.

How can i do it with time instead? thx
 
rozirozi:
How can i do it with time instead? thx
How do you THINK?
:
static datetime Time0Buy;
if (Time0Buy != Time[0]){ // Buy allowed
   ticket = OrderSend(OP_BUY...);
   if (ticket < 0) Alert("OrderSend failed: ", GetLastError());
   else Time0Buy = Time[0]; // No more buys this bar.
}
: