script help

 

I found this script on the forum for limiting open orders but I put it into metaeditor and it givevs me errors when i try to compile it. and would this work with an ea i have on a char like eur usd or usd jpy?

 

#define MAX_ORDERS 5
  
   ...

   if(OrdersTotal()>=MAX_ORDERS)
     {
      // Don't add new orders
     }
   else
     {
      // You can add new orders
     }
 

You need more than that for even the most basic script, so yes MetaEditor will give you errors.

As an aside, in MT4 terminology a "script" is something quite specific. You will most likely be wanting to use that snippet in an EA.

That code is also very basic. It doesn't cater for magic numbers or different symbols. But maybe you don't need that. You will find many, many threads on here about counting orders and restricting new ones. 

Reason: