I've just seen that my new multipair advisor is opening and closing orders from another symbols in some tests (EURUSD does not give this problem) and also in the test drive demo account . For example, GBPUSD is opening and closing EURUSD and EURGBP orders and don't actually know why. This is the way I get _Symbol value:
Anybody can help on this matter? Thanks in advance.
So where is the code?
Please post compileable code - don't try to post chunks of code.
Better yet: describe what you want from your advisor and I will guide you through the steps.
I've just added that Symbols loop and changed _Symbol by SName, and the same for _Point (SPoint). What I need is an advisor to work multisymbol from all of them from the marketwatch but it should manage each one unique.
So where is the code?
Please post compileable code - don't try to post chunks of code.
Hello World()
Ok I don't know which was the problem I got it working fine now.
You must create the SName variable as an array, to hold and list all symbol names when you loop SymbolsTotal().
Then if you make a transaction, you must loop, checking that the m.symbol.Name() is the same as the symbol name in the SName array.
You must create the SName variable as an array, to hold and list all symbol names when you loop SymbolsTotal().
Then if you make a transaction, you must loop, checking that the m.symbol.Name() is the same as the symbol name in the SName array.
double BuyOrders=0,SellOrders=0; for(int i=0;i<PositionsTotal();i++){ ulong iTicket=PositionGetTicket(i); if(PositionSelectByTicket(iTicket)&& PositionGetString(POSITION_SYMBOL)==SName){ if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY){BuyOrders++;} if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL){SellOrders++;} } }
if(ADX[0]<ADX_Limit&&Spread<MaxSpread){ if(/*Condition1*/){ if(/*Condition2*/&&BuyOrders<1){ if(!trade.PositionOpen(SName,ORDER_TYPE_BUY,LotSize,Ask,SL,TP,CustomComment)){ Print("PositionOpen error ",trade.ResultRetcode()); return; } } } if(/*Condition1*/){ if(/*Condition2*/&&SellOrders<1){ if(!trade.PositionOpen(SName,ORDER_TYPE_SELL,LotSize,Ask,SL,TP,CustomComment)){ Print("PositionOpen error ",trade.ResultRetcode()); return; } } } }
double ClosePrice=0; for(int i=0;i<PositionsTotal();i++){ ulong iTicket=PositionGetTicket(i); if(PositionSelectByTicket(iTicket)&& PositionGetString(POSITION_SYMBOL)==SName){ if(PositionsTotal()>1){ // Close at reversal if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY){ClosePrice=Bid;} if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL){ClosePrice=Ask;} if(!trade.PositionClose(iTicket,ULONG_MAX)){ Print("PositionClose error ",trade.ResultRetcode()); return; } } } }
This is the code, orders are opening and closing continuously, this is not happening in the backtests.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've just seen that my new multipair advisor is opening and closing orders from another symbols in some tests (EURUSD does not give this problem) and also in the test drive demo account. For example, GBPUSD is opening and closing EURUSD and EURGBP orders and don't actually know why. This is the way I get _Symbol value:
Anybody can help on this matter? Thanks in advance.