
Originally Posted by
jpsaltuc
Hi,
I looking for a code. When my option is once order per bar "false", multiple trade per bar is. That is ok. I like what lots decreased from first order to last order. Is it possible? Sorry, my english is very poor. Thanks for all. Thanks funyoo. You understand me?
JP
Hi jpsaltuc and welcome,
In the functions, add :
Code:
int CountOrders(int Type,int Magic)
{
int _CountOrd;
_CountOrd=0;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CountOrd++;
}
}
return(_CountOrd);
}
Before the Buy OrderSend function, add :
Code:
ILots=Lots-CountOrders(OP_BUY,Magic)*DecreaseLots;
Before the Sell OrderSend function, add :
Code:
ILots=Lots-CountOrders(OP_SELL,Magic)*DecreaseLots;
Inline in each OrderSend function replace :
By :
After the extern parameters, add :
In the extern parameters, Add :
Code:
extern double DecreaseLots=0.01;
Also replace Magic by your magic number's name.