Code Help, please!

 

Hi all! I’m new in programming… and maybe more expericed members can give me a little help with this…

I’m trying to find out the best code to detect:

1- the number of pairs which have Open Orders at the moment, starting from OrdersTotal( )…”
2- And then for each of those pairs, the total of Sells, Buys, LongProfit and ShortProfit respectively.
First I need a way to detect which pairs are present with open orders and maybe give them a number according to their open time and date... if you see the example on the attached image, it would be:


usdjpy = pair1 (the pair with the oldest open order at 14:40 2008.04.04)
usdchf = pair2
gbpusd =pair3 (the most recent pair with open orders)

So, every time a new pair opens a new order the number of pairs would increase... and have a number by order of appearance.

Later on, I'll want to know the following variables for pair1 (for instance):
NumBuys= ? and respective LongProfit=?
NumSells=? and respective ShortProfit=?

how can I code this?


thanks anyway
 
See for example iExposure custom indicator. You can find it in the installation pack
 
stringo:
See for example iExposure custom indicator. You can find it in the installation pack

Thanks. I'm trying to simplify the following code... my intention is to automatically detect the number of pairs with open orders and sort them out according to their open time...

Since I'm still not familiar with arrays can you give me a help?


//---Sort pairs by oldest open orders & open pairs count (20 max):
OpenPairs=0;
t1=TimeCurrent(); t2=TimeCurrent();t3=TimeCurrent();t4=TimeCurrent();t5=TimeCurrent();t6=TimeCurrent();t7=TimeCurrent();
t8=TimeCurrent();t9=TimeCurrent();t10=TimeCurrent();t11=TimeCurrent();t12=TimeCurrent();t13=TimeCurrent();t14=TimeCurrent();
t15=TimeCurrent();t16=TimeCurrent();t17=TimeCurrent();t18=TimeCurrent();t19=TimeCurrent();t20=TimeCurrent();

for(i = 0; i <OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if (OrderOpenTime()<t1)
{t1=OrderOpenTime();p1=OrderSymbol();OpenPairs=1;}

if (OrderOpenTime()<t2 && OrderSymbol()!=p1)
{t2=OrderOpenTime();p2=OrderSymbol();OpenPairs=2;}

if (OrderOpenTime()<t3 && OrderSymbol()!=p1 && OrderSymbol()!=p2)
{t3=OrderOpenTime();p3=OrderSymbol();OpenPairs=3;}

if (OrderOpenTime()<t4 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3)
{t4=OrderOpenTime();p4=OrderSymbol();OpenPairs=4;}

if (OrderOpenTime()<t5 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4)
{t5=OrderOpenTime();p5=OrderSymbol();OpenPairs=5;}

if (OrderOpenTime()<t6 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5)
{t6=OrderOpenTime();p6=OrderSymbol();OpenPairs=6;}

if (OrderOpenTime()<t7 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6)
{t7=OrderOpenTime();p7=OrderSymbol();OpenPairs=7;}

if (OrderOpenTime()<t8 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7)
{t8=OrderOpenTime();p8=OrderSymbol();OpenPairs=8;}

if (OrderOpenTime()<t9 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8)
{t9=OrderOpenTime();p9=OrderSymbol();OpenPairs=9;}

if (OrderOpenTime()<t10 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8&& OrderSymbol()!=p9)
{t10=OrderOpenTime();p10=OrderSymbol();OpenPairs=10;}

if (OrderOpenTime()<t11 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10)
{t11=OrderOpenTime();p11=OrderSymbol();OpenPairs=11;}

if (OrderOpenTime()<t12 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11)
{t12=OrderOpenTime();p12=OrderSymbol();OpenPairs=12;}

if (OrderOpenTime()<t13 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12)
{t13=OrderOpenTime();p13=OrderSymbol();OpenPairs=13;}

if (OrderOpenTime()<t14 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13)
{t14=OrderOpenTime();p14=OrderSymbol();OpenPairs=14;}

if (OrderOpenTime()<t15 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14)
{t15=OrderOpenTime();p15=OrderSymbol();OpenPairs=15;}

if (OrderOpenTime()<t16 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14&& OrderSymbol()!=p15)
{t16=OrderOpenTime();p16=OrderSymbol();OpenPairs=16;}

if (OrderOpenTime()<t17 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14&& OrderSymbol()!=p15&& OrderSymbol()!=p16)
{t17=OrderOpenTime();p17=OrderSymbol();OpenPairs=17;}

if (OrderOpenTime()<t18 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14&& OrderSymbol()!=p15&& OrderSymbol()!=p16&& OrderSymbol()!=p17)
{t18=OrderOpenTime();p18=OrderSymbol();OpenPairs=18;}

if (OrderOpenTime()<t19 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14&& OrderSymbol()!=p15&& OrderSymbol()!=p16&& OrderSymbol()!=p17
&& OrderSymbol()!=p18)
{t19=OrderOpenTime();p19=OrderSymbol();OpenPairs=19;}

if (OrderOpenTime()<t20 && OrderSymbol()!=p1 && OrderSymbol()!=p2 && OrderSymbol()!=p3 && OrderSymbol()!=p4 && OrderSymbol()!=p5
&& OrderSymbol()!=p6 && OrderSymbol()!=p7 && OrderSymbol()!=p8 && OrderSymbol()!=p9 && OrderSymbol()!=p10&& OrderSymbol()!=p11
&& OrderSymbol()!=p12&& OrderSymbol()!=p13&& OrderSymbol()!=p14&& OrderSymbol()!=p15&& OrderSymbol()!=p16&& OrderSymbol()!=p17
&& OrderSymbol()!=p18&& OrderSymbol()!=p19)
{t20=OrderOpenTime();p20=OrderSymbol();OpenPairs=20;}
// add more ... (there must be another way to avoid this)