Anybody could help me?

 

Hello, I m be trading manual a system that could be profitable.

The system that I am trying to do (hedge) is open eurusd, gbpusd, usdchf and usdjpy (all BUY, and all 1 lot). When the sumatory of this 4 trades get a profit of 100 U$S, then I close all trades and re-open the same 4 trades.

I am using an e.a that close this orders when get the profit.

But I need another e.a (this) that open this 4 orders only when the other e.a close them.

I found this a script that could be program for open this 4 trades, and if I executed as an e.a, it open 4 trades once and again, and again, and again.

If I could add a code to open this trades only if there is no position open with each pair, I think that will work.

So... I writing expecting that someone could help me to add a code to open this orders ONLY if this pairs are not trading.

I m not speak english, and dont get a spanish book for programing mql4, so if anybody could help me, and the system works, we could have a nice profit.

Thank you very much, and sorry for my english.


//+------------------------------------------------------------------+
//|                                                 RapidFire.mq4 |
//|                               Copyright © 2006, Taylor Stockwell |
//|                                               stockwet@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Taylor Stockwell"
#property link      "stockwet@yahoo.com"

#property show_inputs
extern string Symbol_1 = "EURUSD";
extern bool S1_Buy = true;
extern double S1_Lots = 1.0;
extern string Symbol_2 = "GBPUSD";
extern bool S2_Buy = true;
extern double S2_Lots = 1.0;
extern string Symbol_3 = "USDCHF";
extern bool S3_Buy = true;
extern double S3_Lots = 1.0;
extern string Symbol_4 = "USDJPY";
extern bool S4_Buy = true;
extern double S4_Lots = 0;
extern string Symbol_5 = "USDCAD";
extern bool S5_Buy = true;
extern double S5_Lots = 0;
extern string Symbol_6 = "AUDUSD";
extern bool S6_Buy = true;
extern double S6_Lots = 0;
extern string Symbol_7 = "EURGBP";
extern bool S7_Buy = true;
extern double S7_Lots = 0;

int magic=9502;
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {

if(S1_Lots > 0)
{
   if(S1_Buy == 1)
   OrderSend(Symbol_1,OP_BUY, S1_Lots, MarketInfo(Symbol_1,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_1,OP_SELL, S1_Lots, MarketInfo(Symbol_1,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}

if(S2_Lots > 0)
{
   if(S2_Buy == 1)
   OrderSend(Symbol_2,OP_BUY, S2_Lots, MarketInfo(Symbol_2,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_2,OP_SELL, S2_Lots, MarketInfo(Symbol_2,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}

if(S3_Lots > 0)
{
   if(S1_Buy == 1)
   OrderSend(Symbol_3,OP_BUY, S3_Lots, MarketInfo(Symbol_3,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_3,OP_SELL, S3_Lots, MarketInfo(Symbol_3,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}
if(S4_Lots > 0)
{
   if(S1_Buy == 1)
   OrderSend(Symbol_4,OP_BUY, S4_Lots, MarketInfo(Symbol_4,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_4,OP_SELL, S4_Lots, MarketInfo(Symbol_4,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}
if(S5_Lots > 0)
{
   if(S1_Buy == 1)
   OrderSend(Symbol_5,OP_BUY, S5_Lots, MarketInfo(Symbol_5,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_5,OP_SELL, S5_Lots, MarketInfo(Symbol_5,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}
if(S6_Lots > 0)
{
   if(S1_Buy == 1)
   OrderSend(Symbol_6,OP_BUY, S6_Lots, MarketInfo(Symbol_6,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_6,OP_SELL, S6_Lots, MarketInfo(Symbol_6,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}
if(S7_Lots > 0)
{
   if(S7_Buy == 1)
   OrderSend(Symbol_7,OP_BUY, S7_Lots, MarketInfo(Symbol_7,MODE_ASK), 2, NULL, NULL, "RapidFire", magic, NULL, LimeGreen);
   else
   OrderSend(Symbol_7,OP_SELL, S7_Lots, MarketInfo(Symbol_7,MODE_BID), 2, NULL, NULL, "RapidFire", magic, NULL, FireBrick);
}
   

   return(0);
  }
//+------------------------------------------------------------------+
 
i got an idea & thought maybe u can use this for this
 
gabrejos:
So... I writing expecting that someone could help me to add a code to open this orders ONLY if this pairs are not trading.
int GetOrderCount(){
    int count=0;
    for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS)                    // Only my orders w/
    &&  OrderMagicNumber()  == magic.number                 // my magic number
    &&  OrderSymbol()       == symbolChart                  // and my pair.
    ){ 
        count++; 
    }
    return (count);
}
int start(){
   :
   if (GetOrderCount() != 0) return(0);
   :
 

WHRoeder:

gabrejos:
So... I writing expecting that someone could help me to add a code to open this orders ONLY if this pairs are not trading.
int GetOrderCount(){
    int count=0;
    for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS)                    // Only my orders w/
    &&  OrderMagicNumber()  == magic.number                 // my magic number
    &&  OrderSymbol()       == symbolChart                  // and my pair.
    ){ 
        count++; 
    }
    return (count);
}
int start(){
   :
   if (GetOrderCount() != 0) return(0);
   :

x
it's not gonna help him, because he is using one EA for multiple pairs, so.............
 

Thank you very much WHRoeder, I will try. But where have to insert it?

Sorry for mi ignorance.

Reason: