Manage 5 pairs on 1 chart

 
Hello,

I have a plan to manage 5 pairs on 1 chart. 1 order at a time. If some pairs give buy signal at the same time, it will choose pair with the lower spread to trade on.
I can make it with a large number of "if" for every possibility, but is there any better way to do this? I'm thinking to use an array, but I haven't use it before.
Any idea to help me?

Thank you.
 

D

As ever, I admire your ambition!

You can indeed access any pair/s on any chart - the chart merely provides the ticks to drive your start() function

I quite like running an H4 EA on an H1 chart cos you get 4 easily controlled 'check points' per actual bar you are trading, but IMHO - 5 pairs means 5 EA's to me - by reasons:

  • Each will benefit from a different permutation of indicators &/or indicator settings
  • Effectiveness of debugging & testing
  • Less complex coding - in this plan, a single incorrect > or <, or a wrong && or || will be VERY difficult to spot
  • Efficiency in monitoring successes/failures in live trading
  • Its hard enough to get a long-term profitable EA going on one pair, let alone 5!

Does this correspond to a proven live trading system that you are coding up?

Generally, spread is not a big issue compared to position gain (or loss!), unless you have a mega-scalper - which will be built specifically for a low-ish spread pair anyway.

Also in general, a way to solve a difficult programming problem is to change the problem - to a larger number of simpler problems!


My 2c worth :)

-BB-

 
Hello BB,

Thanks for your respond and your insights. Honestly, it's a friend of mine who ask me to do it :)

Yes it's a scalping strategy, he says that it's a proven strategy and since he has to monitoring 5 pairs at the same time, he prefer to use an EA. For me, it will be a good knowledge. Well, that's it.
 

D

Fair enough :)

Dont blame him for requesting an EA with 5 pairs to monitor!

For the both of you, you simply must read 'An Expert Advisor Made to Order. Manual for a Trader'

Made me sigh - and laugh til i cried :D

I've had 15 years experience of trying to get (complete or even... adequate) specifications from potential users of new proposed systems (in banking, health & telecomms).

I was once asked if I could program... 'maybe' & 'sometimes' :eek:


Seriously though, if your friend is an effective trader, his talents are not the same as a good programmer. He probably wont (consciously) know all he is doing...

It takes a lot of effort to bridge the gap between trader & programmer.

I see many great programmers working on here - not too sure how many of us are great traders - I know I'm not, I'm OK, but prefer to automate it, make a little less but no stress :)


Good Luck

-BB-

 
Thanks BB,
I guess he need to read that article :D

Personally I think I can do that, but with a lot of "if" statement, I thought we can do it better using array, well maybe.
Any idea everyone?

Thank you
 
Any other generous people? Phy? please?

Thanks
 

"I'm thinking to use an array, but I haven't use it before."


Arrays aren't difficult.

Take a time-out and play with them for a bit...

Write some litlle test scripts/indicators/experts to learn obout them.

---

... and you HAVE used them before... Close[i], High[i], etc, are arrays...

 
phy:

"I'm thinking to use an array, but I haven't use it before."


Arrays aren't difficult.

Take a time-out and play with them for a bit...

Write some litlle test scripts/indicators/experts to learn obout them.

---

... and you HAVE used them before... Close[i], High[i], etc, are arrays...

I've been playing around with this code :

   double a=5;
   double b=6;
   double c=10;
   double d=4;
   double e=9;
   double ar[5];
   
   ar[1]=a;
   ar[2]=b;
   ar[3]=c;
   ar[4]=d;
   ar[5]=e;
   int max=ArrayMaximum(ar);
   Alert("Max = "+max+"  MaxValue = "+ar[max]+"");
a,b,c,d,and e will be dynamic variables, I make it constant in this example just for to make it simple.
The alert will be " Max = 3 MaxValue = 10", my question is how to make it to " Max = c MaxValue = 10"?

Thank you
 

Error

You are overwrting the end of the allocated storage:

double array[5] allocates memory for array[0] through array[4].

Writing into array[5] is illegal and may cause strange behavior in your tool,
but is not caught by the MT4 compiler.

You can overallocate without a problem, for instance:

double array[100] and only use a part of it, but not allocating enough space
leads to strange problems as other code or values get overwritten "by mistake"

 
phy:

Error

You are overwrting the end of the allocated storage:

double array[5] allocates memory for array[0] through array[4].

Writing into array[5] is illegal and may cause strange behavior in your tool,
but is not caught by the MT4 compiler.


Thanks for that, I've change it and the alert is "Max = 2 MaxValue = 10" now. How to make it " Max = c MaxValue = 10".
I'll use a,b,c,d and e to choose a pair to trade.
I hope I don't asking anything obvious to make me looks stupid :)

Thank you
 
You can try this:
   double a=5;
   double b=6;
   double c=10;
   double d=4;
   double e=9;
   double ar[5];
   string text [5]={"a","b","c","d","e"};

   ar[0]=a;
   ar[1]=b;
   ar[2]=c;
   ar[3]=d;
   ar[4]=e;
   int max=ArrayMaximum(ar);
   Alert("Max = "+text[max]+"  MaxValue = "+ar[max]+"");
Reason: