Hi everyone
Please help professors
How can I use the dimensions in my expert as I mentioned above.
Whenever the expert starts to take a position, start from number 1 to the top
But when all closing positions take positions again from the first number
Global thanks .
hi,
first thing you should declare your arrays like this in your case:
double BuyLotsArray[5]; int OnInit() { BuyLotsArray[0]=Postion_Buy_No1; BuyLotsArray[1]=Postion_Buy_No2; .... }
than create the function lotBuy() like this:
double lotBuy() { int i=MathMod(BuysTotal(),5); return BuyLotsArray[i]; }
where BuysTotal() is the number of opened buy trades. (the coming trades never count)
and same for sell
Ok, Thanks
hi,
first thing you should declare your arrays like this in your case:
than create the function lotBuy() like this:
where BuysTotal() is the number of opened buy trades. (the coming trades never count)
and same for sell
Thank you for your help
Can you please tell me where I am wrong?
No buy positions are made.
extern int Postion_Buy_No1 =0.01; extern int Postion_Buy_No2 =0.02; extern int Postion_Buy_No3 =0.03; extern int Postion_Buy_No4 =0.04; extern int Postion_Buy_No5 =0.05; //+------------------------------------------------------------------+ double BuyLotsArray[5]; int OnInit() { BuyLotsArray[0]=Postion_Buy_No1; BuyLotsArray[1]=Postion_Buy_No2; BuyLotsArray[2]=Postion_Buy_No3; BuyLotsArray[3]=Postion_Buy_No4; BuyLotsArray[4]=Postion_Buy_No5; } //+------------------------------------------------------------------+ double lotBuy() { int i=MathMod(5,5); return BuyLotsArray[i]; } //+------------------------------------------------------------------+ void Pendbuy() { OrderSend(Symbol(),OP_BUY,lotBuy(),Ask,slippage,Ask-stoploss*MathPow(10,-Digits),Ask+takeprofit*MathPow(10,-Digits),"Ghobar",Magic1,0,Blue); } //---------------------------------------------------------------------
Global thanks.
Thank you for your help
Can you please tell me where I am wrong?
No buy positions are made.
Global thanks.
hi,
you didn't create the function "
BuysTotal()
it is supposed to calculate the number of buys instantanly in any moment.
using what you have written it will open trades always using the lot 0.01.
and something else is that this
MathPow(10,-Digits)
can be replaced by this
Point()
hi,
you didn't create the function "
it is supposed to calculate the number of buys instantanly in any moment.
using what you have written it will open trades always using the lot 0.01.
and something else is that this
can be replaced by this
No buying position is open
Thank you for following up
Coding too hard (too hard)
I created the function and called it that way
But Expert still does not open any buying positions
//--------------------------------------------------------------------- void Pendbuy() { OrderSend(Symbol(),OP_BUY,lotBuy(),Ask,slippage,Ask-stoploss*Point(),Ask+takeprofit*MathPow(10,-Digits),"Ghobar",Magic1,0,Blue); } //--------------------------------------------------------------------- void Pendsell() { OrderSend(Symbol(),OP_SELL,lotBuy(),Bid,slippage,Bid+stoploss*Point(),Bid-takeprofit*MathPow(10,-Digits),"Ghobar",Magic2,0,Red); } //+------------------------------------------------------------------+ double BuyLotsArray[5]; int OnInit() { BuyLotsArray[0]=Postion_Buy_No1; BuyLotsArray[1]=Postion_Buy_No2; BuyLotsArray[2]=Postion_Buy_No3; BuyLotsArray[3]=Postion_Buy_No4; BuyLotsArray[4]=Postion_Buy_No5; } //+------------------------------------------------------------------+ double lotBuy() { int i=MathMod(BuysTotal(),5); return BuyLotsArray[i]; } //+------------------------------------------------------------------+ int BuysTotal() { int num=5; for(int i=OrdersTotal()-1;i>=5;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()==Magic1) num++; } return(num); } //---------------------------------------------------------------------
Global thanks.
No buying position is open
Thank you for following up
Coding too hard (too hard)
I created the function and called it that way
But Expert still does not open any buying positions
Global thanks.
hi, it should be like this:
int BuysTotal() { int num=0; for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i,SELECT_BY_POS))continue; if(OrderMagicNumber()==Magic1&&Symbol()==OrderSymbol()) num++; } return(num); }and you should do same functions for sell to have sell lots because i see you are using the buy's function in the sell's ordersend.
hi, it should be like this:
and you should do same functions for sell to have sell lots because i see you are using the buy's function in the sell's ordersend.Thank you, but the expert still does not open any Buy positions
extern double lot=0.1; extern int Postion_Buy_No1 =0.01; extern int Postion_Buy_No2 =0.02; extern int Postion_Buy_No3 =0.03; extern int Postion_Buy_No4 =0.04; extern int Postion_Buy_No5 =0.05; //+------------------------------------------------------------------+ int start() { if(Volume[0]<=1) { if(Stoch1()=="buy") { close2(Magic2); Pendbuy(); } if(Stoch1()=="sell") { close2(Magic1); Pendsell(); } } } //+------------------------------------------------------------------+ void Pendbuy() { OrderSend(Symbol(),OP_BUY,lotBuy(),Ask,slippage,Ask-stoploss*Point(),Ask+takeprofit*MathPow(10,-Digits),"Ghobar",Magic1,0,Blue); } //--------------------------------------------------------------------- //+------------------------------------------------------------------+ double BuyLotsArray[5]; int OnInit() { BuyLotsArray[0]=Postion_Buy_No1; BuyLotsArray[1]=Postion_Buy_No2; BuyLotsArray[2]=Postion_Buy_No3; BuyLotsArray[3]=Postion_Buy_No4; BuyLotsArray[4]=Postion_Buy_No5; } //+------------------------------------------------------------------+ double lotBuy() { int i=MathMod(BuysTotal(),5); return BuyLotsArray[i]; } //+------------------------------------------------------------------+ int BuysTotal() { int num=0; for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i,SELECT_BY_POS))continue; if(OrderMagicNumber()==Magic1&&Symbol()==OrderSymbol()) num++; } return(num); } //---------------------------------------------------------------------
But when I use this, the expert starts to take a position
But all order is 0.01
extern double lot=0.01; //--------------------------------------------------------------------- void Pendbuy() { OrderSend(Symbol(),OP_BUY,lot,Ask,slippage,Ask-stoploss*Point(),Ask+takeprofit*MathPow(10,-Digits),"Ghobar",Magic1,0,Blue); } //---------------------------------------------------------------------
Global thanks.
Thank you, but the expert still does not open any Buy positions
But when I use this, the expert starts to take a position
But all order is 0.01
Global thanks.
first thing:
int BuysTotal() { int num=0; for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i,SELECT_BY_POS))continue; if(OrderMagicNumber()==Magic1&&Symbol()==OrderSymbol()&&!OrderType()) num++; } return(num); }
sorry for that.
else it should send trades even with the last syntax.
anyway, please send me your code in PM to check it, or just copy it here (the full code).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone
Please help professors
How can I use the dimensions in my expert as I mentioned above.
Whenever the expert starts to take a position, start from number 1 to the top
But when all closing positions take positions again from the first number
Global thanks .