Is there a way to pass a variable into OrderSend()

 

Hi!

I am coding an EA that would help me manage multiple Forex Accounts.

My EA is almost it connects with a Telegram Bot and I send him a message and the EA calculates my lot size, opens the trade, sometimes with more than one TP and it even moves SL to BE when TP1 hits, so very nice and easy.

Problems comes here:

Sell_TicketNumber = OrderSend(SYMBOL_msg,OP_SELL,Lots,Ask,MAX_Slippage,SL_msg,TPs,"BOT",MagicNumber);"

"SYMBOL_msg" is a variable that gets his value from parsed Telegram messages. Is there a way to bypass this? Or to somehow trick the function into thinking it is a const?

The EA works great if I manually set the SYMBOL_msg before compiling but as soon as I get it from the Telegram messages it does not work.


Thanks!

 
  1. Why did you post 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? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Robert Ozsvath: "SYMBOL_msg" is a variable that gets his value from parsed Telegram messages. Is there a way to bypass this? Or to somehow trick the function into thinking it is a const?

    When in doubt, think! Pass what you want. It is constant for the duration of the call.

  3. You use the predefined symbol Ask. That will not work unless the symbol passed is the current chart.
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Robert Ozsvath:

Hi!

I am coding an EA that would help me manage multiple Forex Accounts.

My EA is almost it connects with a Telegram Bot and I send him a message and the EA calculates my lot size, opens the trade, sometimes with more than one TP and it even moves SL to BE when TP1 hits, so very nice and easy.

Problems comes here:

"SYMBOL_msg" is a variable that gets his value from parsed Telegram messages. Is there a way to bypass this? Or to somehow trick the function into thinking it is a const?

The EA works great if I manually set the SYMBOL_msg before compiling but as soon as I get it from the Telegram messages it does not work.


Thanks!

Print the variable to journal and see what's actually being in there...

I am sure, you are sending something invalid to OrderSend.

Also, check the error code after OrderSend.
 
Robert Ozsvath: I am coding an EA that would help me manage multiple Forex Accounts.

Can't be done. The terminal is only connected to one account.

 

Hello all!


Thanks for all the information you have given me. I managed to solve this problem by making the EA change the chart before my ExecuteOrder() is called.

If anyone needs it 

   void ChartChange()
   {
   string s=SYMBOL_msg;

   for (long i = ChartFirst(); i!=-1; i = ChartNext(i))

   {

      ChartSetSymbolPeriod(i,s,ChartPeriod(i));

   }
   }

I got it from a forum. This way I pass everything from the chart except the TP and SL

 
William Roeder #:

Can't be done. The terminal is only connected to one account.

To solve this problem I add many bots to a telegram group and I add the EA to different terminals with differnt Tokens.
 
Robert Ozsvath #:
To solve this problem I add many bots to a telegram group and I add the EA to different terminals with differnt Tokens.

ingenius.