Hi coders, I'm trying to learn 2D Array to store the OrderOpenPrice() for each symbol.
Existingly, I have 3 symbols that with open orders :-
1) AUDNZD : 10 BUY open orders
2) EURUSD : 8 SELL open orders
3) XAUUSD : 12 BUY open orders and 3 SELL open orders
The following are my codes :-
After storing the OrderOpenPrice() into respective arrays, I need to sort it in MODE_DESCEND and MODE_ASCEND (If in Ascending order, how to exclude the 0 values ? I don't know how to deal with this issue, please advise).
The problem now is if I print / call out from the arrays, I can get the correct output for the 1st pair (AUDNZD), but I cannot get the output for other pairs.
Lastly, there are total of 3 symbols that with open orders. For bSymOpPxAr[][99], there are only 2 symbols with BUY orders (AUDNZD and XAUUSD) and for sSymOpPxAr[][99], there are only 2 symbols with SELL orders (EURUSD and XAUUSD), how to turn the :-
1) bSymOpPxAr[][99] to become bSymOpPxAr[][2] ?
2) sSymOpPxAr[][99] to become sSymOpPxAr[][2] ?
Kindly have a look into my codes, please help and correct my codes, thank you.
Existingly, I have 3 symbols that with open orders :-
1) AUDNZD : 10 BUY open orders
2) EURUSD : 8 SELL open orders
3) XAUUSD : 12 BUY open orders and 3 SELL open orders
The following are my codes :-
Inserted Code
string opSym[]={"AUDNZD","EURUSD","XAUUSD"}; double symOpPxAr[][99], bSymOpPxAr[][99], sSymOpPxAr[][99]; // Store Each Symbol's Open Prices ArrayResize(symOpPxAr,OrdersTotal()); // Both BUY & SELL Prices for Each Symbol ArrayResize(bSymOpPxAr,OrdersTotal()); // Only BUY Prices for Each Symbol ArrayResize(sSymOpPxAr,OrdersTotal()); // Only SELL Prices for Each Symbol for(int h=0; h<ArraySize(opSym); h++) { for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==opSym[h] && OrderMagicNumber()==mn) { symOpPxAr[i,h]=OrderOpenPrice(); if(OrderType()==OP_BUY) bSymOpPxAr[i,h]=OrderOpenPrice(); if(OrderType()==OP_SELL) sSymOpPxAr[i,h]=OrderOpenPrice();} }} if(ArraySize(symOpPxAr)>0) ArraySort(symOpPxAr,WHOLE_ARRAY,0,MODE_DESCEND); // Big ... Small Print("Pair1: "+DoubleToStr(symOpPxAr[0,0],5)+","+DoubleToStr(symOpPxAr[1,0],5)+","+DoubleToStr(symOpPxAr[2,0],5)+","+DoubleToStr(symOpPxAr[3,0],5)); Print("Pair2: "+DoubleToStr(symOpPxAr[0,1],5)+","+DoubleToStr(symOpPxAr[1,1],5)+","+DoubleToStr(symOpPxAr[2,1],5)+","+DoubleToStr(symOpPxAr[3,1],5)); Print("Pair3: "+DoubleToStr(symOpPxAr[0,2],5)+","+DoubleToStr(symOpPxAr[1,2],5)+","+DoubleToStr(symOpPxAr[2,2],5)+","+DoubleToStr(symOpPxAr[3,2],5));
After storing the OrderOpenPrice() into respective arrays, I need to sort it in MODE_DESCEND and MODE_ASCEND (If in Ascending order, how to exclude the 0 values ? I don't know how to deal with this issue, please advise).
The problem now is if I print / call out from the arrays, I can get the correct output for the 1st pair (AUDNZD), but I cannot get the output for other pairs.
Lastly, there are total of 3 symbols that with open orders. For bSymOpPxAr[][99], there are only 2 symbols with BUY orders (AUDNZD and XAUUSD) and for sSymOpPxAr[][99], there are only 2 symbols with SELL orders (EURUSD and XAUUSD), how to turn the :-
1) bSymOpPxAr[][99] to become bSymOpPxAr[][2] ?
2) sSymOpPxAr[][99] to become sSymOpPxAr[][2] ?
Kindly have a look into my codes, please help and correct my codes, thank you.