EA added in one chart but trade different selection symbols (HELP)

 

Hello follow developer,

I have MT4 EA that automatically select weak and strong currency pairs and add it to a variable named : 

string SellSymbols = "USDCAD,CADJPY,";
string BuySymbols= "EURUSD,GBPCAD,";

I want to code my EA in a way that it is in one chart and trade all the selected symbols  for example :

// for sell...
ticket= OrderSend(SellSymbols,OP_SELL,lot,Entry,EntrySlipage,SL,TP,"EA Trade",MagicNumber,clrRed);

// for buy....
ticket= OrderSend(BuySymbols,OP_BUY,lot,Entry,EntrySlipage,SL,TP,"EA Trade",MagicNumber,clrGreen);

EA will be added to one chart and it will automatically sell USDCAD/CADJPY and buy EURUSD/GBPCAD when they is signal on the chart of those symbols.

Am actually using custom indicator in which I will code it this way: 

if(CustomIndicator(SellSymbols,TimeFrame)=="sellSignal"
{
  ticket= OrderSend(SellSymbols,OP_SELL,lot,Entry,EntrySlipage,SL,TP,"EA Trade",MagicNumber,clrRed);
}
// for buy...
if(CustomIndicator(BuySymbols,TimeFrame)=="buySignal"
{
  ticket= OrderSend(BuySymbols,OP_BUY,lot,Entry,EntrySlipage,SL,TP,"EA Trade",MagicNumber,clrGreen);
}

Please anyone who know how to code EA to be in on chart and trade different selected symbols? please help me, share the code to me here

Your Support will be highly appreciated. Thank you

Documentation on MQL5: Market Info / SymbolSelect
Documentation on MQL5: Market Info / SymbolSelect
  • www.mql5.com
SymbolSelect - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Topics concerning MT4 and MQL4 have their own section.

You have been told this before!

In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:

Topics concerning MT4 and MQL4 have their own section.

You have been told this before!

In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
But when ever I click log in in mql4.com it redirect me to mql5.com
I don't know how to specify it for mql4

 
Emmanuel Emmanuel Tom:
But when ever I click log in in mql4.com it redirect me to mql5.com
I don't know how to specify it in mql4

Click on forum at the top of the page and then click on the correct section.

 
  1. Emmanuel Emmanuel Tom: But when ever I click log in in mql4.com it redirect me to mql5.com
    I don't know how to specify it for mql4

    The site is mql5.com. Nothing to do with which forum you post on.

    You posted your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Emmanuel Emmanuel Tom: I want …please help me

    Help you with what? You haven't stated a problem, you stated a want.
         How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

    You have only four choices:

    1. Search for it. Do you expect us to do your research for you?

    2. Beg at:

    3. MT4: Learn to code it.
      MT5: Begin learning to code it.

      If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

    4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
                Hiring to write script - General - MQL5 programming forum 2019.08.21

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help 2017.04.21

 

Emmanuel Emmanuel Tom:

The First thing that you should do is to code a function to open a trade with a single symbol.

//Open Sell Function
//+------------------------------------------------------------------+
int OpenSellTrade(string symbolToTrade)
{
// Here calculate values
// for all the variables in the
// OrderSend()
   
   int ticket= OrderSend(symbolToTrade,OP_SELL,lot,Entry,EntrySlipage,SL,TP,"EA Trade",MagicNumber,clrRed);
   if(ticket==-1)
      Print("OrderSend (Sell) failed with error #",GetLastError()); //add extra details to the print that may help you pinpoint any problems

   return(ticket);
}
//+------------------------------------------------------------------+

Once you have done that you can create a loop to call the function with various symbols.

Please complete the above function and post it here.

 
Keith Watford:

The First thing that you should do is to code a function to open a trade with a single symbol.

Once you have done that you can create a loop to call the function with various symbols.

Please complete the above function and post it here.

Ok sir, I highly appreciate your support, I will create the function and post again
 
William Roeder:
  1. The site is mql5.com. Nothing to do with which forum you post on.

    You posted your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Help you with what? You haven't stated a problem, you stated a want.
         How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

    You have only four choices:

    1. Search for it. Do you expect us to do your research for you?

    2. Beg at:

    3. MT4: Learn to code it.
      MT5: Begin learning to code it.

      If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

    4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
                Hiring to write script - General - MQL5 programming forum 2019.08.21

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help 2017.04.21

Okay sir
 
Keith Watford:

The First thing that you should do is to code a function to open a trade with a single symbol.

Once you have done that you can create a loop to call the function with various symbols.

Please complete the above function and post it here.

I have done it this way , but not tested yet but I believe it will work

string SellSymbols= USDJPY,USDCAD;
string BuySymbols= GBPUSD,EURUSD;
string BuySymbolsArray[];
string SellSymbolsArray[];

// BuySymbols varieble split to BuysymbolsArray
ushort seperator=StringGetCharacter(",",0);
int StrSplit=StringSplit(BuySymbols,seperator,BuySymbolsArray);

// SellSymbols varieble split to SellsymbolsArray
ushort sep=StringGetCharacter(",",0);
int Split=StringSplit(SellSymbols,sep,SellSymbolsArray);


for(int s=0; s<=ArraySize(BuySymbolsArray); s++)//BUY ORDER
{
  if(indicator(BuySymbolsArray[s],Timeframe,Shift)=="buy")
  {
     ticket= OrderSend(BuySymbolsArray[s],OP_BUY,lot,Entry,EntrySlipage,SL,TP,"COMMENT",MagicNumber,clrGreen);
  }
}


for(int s=0; s<=ArraySize(SellSymbolsArray); s++)//SELL ORDER
{
  if(indicator(SellSymbolsArray[s],Timeframe,Shift)=="sell")
  {
     ticket= OrderSend(SellSymbolsArray[s],OP_SELL,lot,Entry,EntrySlipage,SL,TP,"COMMENT",MagicNumber,clrRed);
  }
}
 
Emmanuel Emmanuel Tom:

I have done it this way , but not tested yet but I believe it will work

It won't work for various reasons.

As you don't want to take notice of my advice, I'll leave it at that.

 
Keith Watford:

It won't work for various reasons.

As you don't want to take notice of my advice, I'll leave it at that.

how?? But i just loop over the symbols in the Arrays sir