Pls someone Help in Coding

 

Hi all,

I was doing EAs using EAbuilder website and wonder that the magicnumber dont work.

I been generate 2 Eas which one Buy when price above 100SMA, another Buy when price above 200SMA. with diffrent MagicNum.

As theory, when i place them in diffrent chart althou same pair, 2 EA should open their own trade independently??? But fact is they dont,

Only either one open trade and another one don't, What happen?

I attach them here, can anyone pls modify for me? I need these to be kept as template for future reference. I need to do few EAs to run togther with diffrent strategy but same pair... pls anyone help me

Files:
 

GH

Change this line

      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {

to this

      if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber) {

Good Luck

-BB-

 
BarrowBoy:

GH

Change this line

to this

Good Luck

-BB-

I m totally Thanks to -BB- I really mean that. I been asking for help in many forums but only get helped here. Thanks again. U the man!

Oh yea, additional, If i want this EA to work " X trade only per day", "x" is variable for number, will that complicated?

 

> If i want this EA to work " X trade only per day", "x" is variable for number, will that complicated?

Not too bad once you have decided what 'a day' is.... Brokers server day, your local time, whatever..

It would be better IMHO to look at trading hours within the day that are best for your strategy rather than an arbitrary number of trades..

FWIW

-BB-

 
You could do something like:
start() {
  static datetime Time.newBar;
  bool newBar	= (Time[0] > Time.newBar);	if (newBar) {	// A new bar began.
    Time.newBar	= Time[0];					// Reset static.
    static int	openAllowed;	openAllowed = TradesPerBar;	// Allow new trades.
  }
  //...
  //---- Open a new order?
  if (openAllowed <= 0) return(0);				// No new orders this bar.

  //...
  OrderSend(...)
  openAllowed--;
 

Whoa... Thanks to both BB and WHRoeder, i m indeed a slow learner sorry. Not so unstd above Coding...

@_BB_, the "Per day" is Broker Time 00:00 till 23:59(what ever broker dont care). Some strategy is only avail once a day. I m done with "start hour to end hour", just, i need only one trade that happen within that trade period. Is that ok? I already set it trade from 00:00 till 12:00, just i need additional that ONLY X Trade within that period...

@ WHRoeder, errr, that code above is 4 what purpose actually? I sorry if u feel ok to explain a little? My background is Art, and involve FX only 2 years ago, so coding is too alien to me, i just could input my Logic with EA Builder website to generate EA, and copy paste some addon from other EA like MM, hours start stop. Hope u guys forgive my stupidity...

 
Alrite, things r done. Thanks for ur assistance. answr found in ForexFactory. Case close.
Reason: