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

 
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.

HELLO SIR

 THE FUNCTION IS TESTED TODAY AND IT WORKED LIKE CHARM

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
Predefined Macro Substitutions - Named Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Please don't post in capital letters, it is considered shouting and very rude!

I am surprised that it is working like a charm as I don't see that it will even compile.

string SellSymbols= USDJPY,USDCAD;
string BuySymbols= GBPUSD,EURUSD;

The highlighted are not strings

 
Keith Watford:

Please don't post in capital letters, it is considered shouting and very rude!

I am surprised that it is working like a charm as I don't see that it will even compile.

The highlighted are not strings

it compiled and it worked, you know I split the symbols in the BuySymbols variable to BuySymbolsArray[] and used a for loop to loop over all the index of the  BuySymbolsArray[]  (same for sell) to check if they is signal in each symbol, if true then EA place trade on the Symbol.

But I don't know why it keep trading on the current chart symbol that the EA is added, even the chart symbol is not in the symbolsArray .

Can you please connect to my computer via anydesk to check why it place trade on the current chart?

 
Emmanuel Emmanuel Tom:

it compiled and it worked, you know I split the symbols in the BuySymbols variable to BuySymbolsArray[] and used a for loop to loop over all the index of the  BuySymbolsArray[]  (same for sell) to check if they is signal in each symbol, if true then EA place trade on the Symbol.

But I don't know why it keep trading on the current chart symbol that the EA is added, even the chart symbol is not in the symbolsArray .

Can you please connect to my computer via anydesk to check why it place trade on the current chart?

First of all you shout at me, gloating that your code works like a charm.

Now you say that the code doesn't do what you want it to do, so it is not working like a charm, is it?

I don't believe that your code compiles.

string SellSymbols= USDJPY,USDCAD;
string BuySymbols= GBPUSD,EURUSD;

These are not strings.

I suggested that you write a function to begin with.

//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);
}
//+------------------------------------------------------------------+

but you have ignored me.

The main thing with the function is to calculate all the values that you use in the OrderSend(). At the moment all the parameters seem to be Globalscope variables and that can't be right. The values should be calculated according to which symbol is being traded.

 
Keith Watford:

First of all you shout at me, gloating that your code works like a charm.

Now you say that the code doesn't do what you want it to do, so it is not working like a charm, is it?

I don't believe that your code compiles.

These are not strings.

I suggested that you write a function to begin with.

but you have ignored me.

The main thing with the function is to calculate all the values that you use in the OrderSend(). At the moment all the parameters seem to be Globalscope variables and that can't be right. The values should be calculated according to which symbol is being traded.

Hello sir I didn't shout at you sir, my caplock was on and I discovered it when i already type and ready to send.

so sorry for that sir

 
Keith Watford:

First of all you shout at me, gloating that your code works like a charm.

Now you say that the code doesn't do what you want it to do, so it is not working like a charm, is it?

I don't believe that your code compiles.

These are not strings.

I suggested that you write a function to begin with.

but you have ignored me.

The main thing with the function is to calculate all the values that you use in the OrderSend(). At the moment all the parameters seem to be Globalscope variables and that can't be right. The values should be calculated according to which symbol is being traded.

string SellSymbols= USDJPY,USDCAD;
string BuySymbols= GBPUSD,EURUSD;

I made a mistake here when I type the code here__ correct is "USDJPY,USDCAD" etc

 
      for(int s=0; s<=NumInBuyArray; s++)//BUY ORDER BASE ON BEAST INDICATOR====================================||
      {
         if(NumInBuyArray==0)
         {
            break;
         }
         else
         {
            if(BeastSupperSignal(BuySymbolsArray[s],BeastTimeframe,beastShift)=="buy" && !OpenOrdersByMagicNB_InSymbols(MagicNumber,BuySymbolsArray[s]) && BeastSignal==ON)
            { 
                  double Entry= SymbolInfoDouble(BuySymbolsArray[s],SYMBOL_ASK);
                  double SL=0;
                  double TP=0; 
                  double lot;
                  double sl= Entry-RiskPoint*Point;     
                  
                   if(UseOptimalLotSize==1)//CHECKING LOT TYPE....................................+
                     lot=OptimalLotSize(RiskPerTrade_Percent,Entry,sl);
                  else
                     lot=LotSize;
                  if(lot<0.01)Alert("Your account equity cannot risk " + RiskPerTrade_Percent+ "% or " +RiskPerTrade_Percent+ "%, is too low, Please reduce or increase RiskPerTrade_Percent");            
                  //.....................................................+
                  if(MaximumOpenOrders==0)//CHECKING HOW MANY MAX POSITION SELECTED BY THE USER. 0 means NO MAX
                  {
                    ticket= OrderSend(BuySymbolsArray[s],OP_BUY,lot,Entry,EntrySlipage,SL,TP,"pip_master Beast",MagicNumber,clrGreen);
                    continue;
                    if(SendSignalToTelegram==1)tms_send("PIP_MASTER. "+BuySymbolsArray[s]+ " Beast buy @ "+Entry+ " In "+Period()+" Mins TimeFrame",TelegramGroupID);
                  }
                  else if(MaximumOpenOrders>0)//CHECKING HOW MANY MAX POSITION SELECTED BY THE USER. 0 means NO MAX
                  {
                     if(OrdersTotal()<MaximumOpenOrders) 
                     {
                        ticket= OrderSend(BuySymbolsArray[s],OP_BUY,lot,Entry,EntrySlipage,SL,TP,"pip_master Beast",MagicNumber,clrGreen);
                        continue;
                        if(SendSignalToTelegram==1)tms_send("PIP_MASTER. "+BuySymbolsArray[s]+ " Beast buy @ "+Entry+ " In "+Period()+" Mins TimeFrame",TelegramGroupID);
                     }
                  }  
                    
            }     
         }

      }

Sir check the code and the picture, am doing exactly what you said I should do but it require me to code in this way because I don't select any symbols in the input rather EA select by itself and when new symbols are selected the previous ones in the variable will be replaced by the new once

Look at the picture and the code you will see that all data is calculated in each symbols during each loop. But I don't still know why it place trade on the current symbols of the chart even the symbol is not in the list of the symbols variable!

Files:
2020-12-22.png  115 kb
 
Emmanuel Emmanuel Tom:

I made a mistake here when I type the code here__ correct is "USDJPY,USDCAD" etc

Why would you type the code here?

Just copy and paste it.

 
Sir you assisted me from the beginning and and am so grateful.... Thank you so much 
 
Keith Watford:

Why would you type the code here?

Just copy and paste it.

So sorry,  I typed because I wanted to use a variable name that  any reader will understand