
#property copyright "Copyright © 2009, Aiman"
#property link      ""
#property show_inputs

string gsa_76[] = {"GBPJPY", "EURJPY", "AUDJPY", "NZDUSD", "GBPUSD"};
extern double Lots = 0.01;
int gi_88 = 3;
string gs_92 = "";
extern int MagicNumber = 10020;

int init() {
   gs_92 = gs_92 + "|" + DoubleToStr(MagicNumber, 0);
   return (0);
}

int start() {
   string ls_0 = StringSubstr(Symbol(), 6, 1);
   for (int li_8 = 0; li_8 < ArraySize(gsa_76); li_8++) OpenPOS(gsa_76[li_8] + ls_0, "Sell");
   Comment("");
   return (0);
}

void OpenPOS(string as_0, string as_8) {
   double ld_24;
   double ld_32;
   int li_16 = 0;
   bool li_20 = FALSE;
   while (!li_20) {
      ld_24 = MarketInfo(as_0, MODE_BID);
      ld_32 = MarketInfo(as_0, MODE_ASK);
      Comment("Placing Order ", as_8, " for ", as_0);
      if (as_8 == "Buy") li_16 = OrderSend(as_0, OP_BUY, Lots, ld_32, gi_88, 0, 0, gs_92, MagicNumber);
      if (as_8 == "Sell") li_16 = OrderSend(as_0, OP_SELL, Lots, ld_24, gi_88, 0, 0, gs_92, MagicNumber);
      if (li_16 > 0) {
         if (as_8 == "Buy") Print("BUY PLACED Ticket=" + li_16 + " Ask=" + ld_32 + " Lots=" + Lots);
         if (as_8 == "Sell") Print("SELL PLACED Ticket=" + li_16 + " Bid=" + ld_24 + " Lots=" + Lots);
         li_20 = TRUE;
      }
      Wait();
   }
}

void Wait() {
   while (IsTradeContextBusy()) Sleep(50);
}