The problem is
I practically don't know the language, I need to automate the opening of orders for a few vp, I put out this simple code (file attached), but it turned out to be clumsy,
According to the plan should open 6 vp, but opens only 3 vp, but sometimes opens all 6, but then again no longer works as it should (I think this may be due to the number of digits after the decimal point, as in the block, where there is no JPY, all works fine.
Please help solve this problem.
If i'm not hard i need help to write it so i can switch trades to Buy or Sell only.
file: DANGER FILE REMOVED
The file should be attached using the button .
The problem is
I practically don't know the language, I need to automate the opening of orders for a few vp, I put out this simple code (file attached), but it turned out to be clumsy,
According to the plan should open 6 vp, but opens only 3 vp, but sometimes opens all 6, but then again stops working as it should (I think this may be due to the number of decimal places in the price, as in a block with no JPY, all works fine.
Please help solve this problem.
And also, if it's not difficult prompt how to prescribe, that it was possible to switch the opening of trades only Buy or Sell.
There are a number of reasons that prevent you from opening an order. Suppose, on the first tick, 3 orders are opened
On the next tick, at the very beginning of the program, if(OrdersTotal() >= OrderCount) return; this will be returned since the number of orders is greater than OrderCount, which = 1.
The rest of the program will be ignored.
Judging by these lines:
//| Copyright 2021, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Software Corp." #property link "https://www.mql5.com"
The program was developed by MetaQuotes Software Corp. Ask them for advice!
- www.mql5.com
There are a number of reasons that prevent an order from opening. Suppose that on the first tick, 3 orders are opened
On the next tick, at the very beginning of the program, if(OrdersTotal() >= OrderCount) return; this will be returned since the number of orders is higher than OrderCount, which = 1.
The rest of the program will be ignored.
Judging by these lines:
The program was developed by MetaQuotes Software Corp. Please consult them!
Do you mean that extra orders are opened?
Try it this way - Shorter and more precise. If you figure it out on your own, you'll be a coryphaeus of programming. Put your cursor on the word and press F1
//+------------------------------------------------------------------+ //| Test 3.mq4 | //+------------------------------------------------------------------+ #property strict extern double Lot = 0.01; extern int Slip = 3; extern int Magic = 777; string name[10]={"AUDJPY","CHFJPY","CADJPY","AUDCAD","AUDCHF","CADCHF"}; int cnt[6]; void OnTick() { ArrayInitialize(cnt, 0); // Обнуление счетчиков // Подсчет ордеров по каждому торговому инструменту for(int n=OrdersTotal()-1; n>=0; n--) { if(!OrderSelect(n,SELECT_BY_POS))continue; for(int k=0; k<6; k++) if(OrderSymbol()==name[k]) cnt[k]++; } // Открытие ордеров по каждому торговому инструменту for(int k=0; k<6; k++) if(!cnt[k]) int ticket = OrderSend(name[k],OP_BUY, Lot, MarketInfo(name[k],MODE_ASK), Slip, 0, 0, "", Magic); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The problem is
I practically don't know the language, I need to automate the opening of orders for a few vp, I put out this simple code (file attached), but it turned out to be clumsy,
According to the plan should open 6 vp, but opens only 3 vp, but sometimes opens all 6, but then again no longer works as it should (I think this may be due to the number of digits after the decimal point, as in the block, where there is no JPY, all works fine.
Please help solve this problem.
If i'm not hard i need help to write it so i can switch trades to Buy or Sell only.
file: DANGER FILE DELETED