MQL4 - automated forex trading   /  

Forum

How to find total number of symbols traded

Back to topics list To post a new topic, please log in or register

avatar
101
ejoi 2008.06.11 05:47 

How to find total number of symbols traded.

eg. I am trading buy and sell GBPUSD, EURUSD, EURJPY and USDJPY

and I want this to return total of 4 pairs traded. Anyone know?

article

The Automated Trading Championship: 2006 and 2007

Automated trading is undoubtedly one of the most prospective spheres in modern trading. The popularity of this technology continually grows. Considering this fact, we decided to organize the Automated Trading Championship.


avatar
179
tradeigel 2008.06.11 13:46 
at least from reading your post once, I have no idea what you mean, sorry. Please elaborate.

avatar
101
ejoi 2008.06.11 13:55 
From the orderstotal, I only want to extract 4 pairs from the example above. It should only count the number of pairs only.

avatar
396
ukt 2008.06.11 15:46 

maybe this (or your mods make it 'this') - gives u launch point anyway...

edit.1: silly me! forgot check if trade or pending... hey! great mistake - maybe u can put in the 1 extra line or maybe 2 ;), in .... the function ;)

hint: OrderType()

good luck...

//+------------------------------------------------------------------+
//|                                                         ejoi.mq4 |
//|                                                              ukt |
//|                                      http://forum.mql4.com/13216 |
//+------------------------------------------------------------------+
#property copyright "publicDomain"
#property link      "http://forum.mql4.com/13216"


//------------------------------------------------------------------------------
//  program global declarations
//-
string saSymbols[] = {"GBPUSD","EURUSD","EURJPY","USDJPY"};        //can add or remove entries...


//------------------------------------------------------------------------------
//-
int start ()
{ /******

    COMMENT
        Life, the universe and all that - get's sorted out here ;)
    */
    Print("iOrderTotal=",iGetOrderTotal(saSymbols));

    return(0);

}//start()


//------------------------------------------------------------------------------
//-
int iGetOrderTotal (string& saSymbols[])
{ /***************

    COMMENT
        Given list of symbol pairs, we look in trading pool for 'active/at market' order entries
        that have same symbol pair as one in given input list - this is a 'hit'.
        Count all 'hits' and return count to caller as function value
    */
    int iOrderCount = OrdersTotal();
    int iOrderTotal = 0;
    int iSyms2Test = ArraySize(saSymbols);
    string sSym;

    for(int iPos=0;iPos<iOrderCount;iPos++)
    {
        if(!OrderSelect(iPos,SELECT_BY_POS)) continue;
        //ok, here we have mapped trading pool entry of type: open/pending
        //-
        //let us see: IF entry has one of our symbol pairs THEN increment "total number of symbols traded"
        //-
        sSym = OrderSymbol();
        for(int i=0;i<iSyms2Test;i++)                    //scan each sym list entry looking for match
            if(sSym==saSymbols[i]) iOrderTotal++;        //found! so bump counter
    }

    return(iOrderTotal);
    
}//iGetOrderTotal()



/* quicky test results.........

2008.06.11 12:39:44    ejoi EURUSD,M15: removed
2008.06.11 12:39:44    ejoi EURUSD,M15: uninit reason 0
2008.06.11 12:39:44    ejoi EURUSD,M15: iOrderTotal=3
2008.06.11 12:39:44    ejoi EURUSD,M15: loaded successfully

*/


quicky test: trade orders tab on terminal

Back to topics list  

To add comments, please log in or register