To complex?

 

Existing system on MT4:

Based on a number of criteria ("Swing Trading" system)

4 orders are placed and 3 of them are scaled out at predetermined levels. The last one runs with a trailng stop.

When the first part is scaled out the remaining  are set to break even. From here on this setup is  a "free ride" so to speak.

That means that its ok to start a new setup since all risk is eliminated.

In MT4 this is staightforward since thjese orders are separate entities and can be handled individually.

I have it ported to MT5 except for the scalping out part.

In order to keep track of this in MT5  both StopLoss and Take Profit  has to be hanlded with Limit orders including the trailing stop part

Since an EA can be momentarily out of service Ican not really save information about the status of the varying parts in the EA. I have to ask the

server for what is going on. I have read a few articles and ideas but I must confess that I really dont see how to accomplish this in a reasonably safe way.

It really seems like the simplest way is to have an MT5 EA that creates the setup and sends it to an MT4 EA that performs the execution.

 
ingvar_e:
...

In order to keep track of this in MT5  both StopLoss and Take Profit  has to be hanlded with Limit orders including the trailing stop part

Since an EA can be momentarily out of service Ican not really save information about the status of the varying parts in the EA. I have to ask the

server for what is going on. I have read a few articles and ideas but I must confess that I really dont see how to accomplish this in a reasonably safe way.

It really seems like the simplest way is to have an MT5 EA that creates the setup and sends it to an MT4 EA that performs the execution.

Accomplish what exactly ?

I have an EA running for almost 1 year. Though you have to take into account that an EA can be momentarily out of service, it's rare.

 
angevoyageur:

Accomplish what exactly ?

I have an EA running for almost 1 year. Though you have to take into account that an EA can be momentarily out of service, it's rare.

  Sorry. Not clear. What I meant was to handle the complexity of the Limit orders for multiple scale out and possibly more than one order by continously

  interrogate the server on what has got to SL in order to kill the appropiate TP and vice versa. None of that is needed in MT4. an OCO functionality would

be really nice

 
ingvar_e:

  Sorry. Not clear. What I meant was to handle the complexity of the Limit orders for multiple scale out and possibly more than one order by continously

  interrogate the server on what has got to SL in order to kill the appropiate TP and vice versa. None of that is needed in MT4. an OCO functionality would

be really nice

I agree about OCO orders but this has been discussed on Russian forum, and the CEO of Metaquotes said : "No."

So you have 2 choices for this kind of trading with mql5, use stop/limit orders and manage them by detecting when one is triggered. I already do that, and it's not so hard to do. Other choice is to manage your trades entirely in your EA and using TP/SL of the position as a security in case of loss of connection with the server.

 
angevoyageur:

I agree about OCO orders but this has been discussed on Russian forum, and the CEO of Metaquotes said : "No."

So you have 2 choices for this kind of trading with mql5, use stop/limit orders and manage them by detecting when one is triggered. I already do that, and it's not so hard to do. Other choice is to manage your trades entirely in your EA and using TP/SL of the position as a security in case of loss of connection with the server.

  Since I probably need a mirror from MT5 to MT4 anyway I will start with that. Then I will decide which path to take. Trying to handle multiple TP/SL with limit orders or just send the order setup to MT4. Why do not run it in MT4 directly?

Simple answer. 3 reasons. Backtesting. MultiCurrency. OOP.   Getting addicted to MQL5

I will try to figure it out for MQL5 first. Critical point is. Where should I look in order to get a signal for SL and TP.  I would assume that "OnTrade" would be the logical place but when I read the documetation I get overwhelmed.  Information overload.

 
ingvar_e:

  Since I probably need a mirror from MT5 to MT4 anyway I will start with that. Then I will decide which path to take. Trying to handle multiple TP/SL with limit orders or just send the order setup to MT4. Why do not run it in MT4 directly?

Simple answer. 3 reasons. Backtesting. MultiCurrency. OOP.   Getting addicted to MQL5

I will try to figure it out for MQL5 first. Critical point is. Where should I look in order to get a signal for SL and TP.  I would assume that "OnTrade" would be the logical place but when I read the documetation I get overwhelmed.  Information overload.

I agree with you and will reprogram my MT4 EA also to benefit from backtesting and multicurrency. However OOP is now available with MT4 too in the new version (last phase of beta).

I suggest you to use OnTradeTransaction instead of OnTrade. You then have to analyse the provided parameters MqlTradeTransaction, MqlTradeRequest and MqlTradeResult. The difficulty is to manage successive events : when an SL or TP is triggered you receive 4/5 events to process in a row.

MetaTrader 4 Build 574 with Updated MQL4 Language and Market of Applications Released - MQL4 forum
  • www.mql5.com
MetaTrader 4 Build 574 with Updated MQL4 Language and Market of Applications Released - MQL4 forum
 
angevoyageur:

I agree with you and will reprogram my MT4 EA also to benefit from backtesting and multicurrency. However OOP is now available with MT4 too in the new version (last phase of beta).

I suggest you to use OnTradeTransaction instead of OnTrade. You then have to analyse the provided parameters MqlTradeTransaction, MqlTradeRequest and MqlTradeResult. The difficult is to manage successive events : when an SL or TP is triggered you receive 4/5 events to process in a row.

  Thanks angevoyageur.

  Your nick with "voyageur" in it reminds me of my new kindle ebook.  I started to reread "The Hitchhikers Guide to the Galaxy" that I read in normal book format many tears ago.  Its very funny and is a good way to disconnect from all programming during the day even if I am a "compulsory programmer" :-)

  And as before.

<when an SL or TP is triggered you receive 4/5 events to process in a row.

 Why make anything simple when............

 
ingvar_e:

  Thanks angevoyageur.

  Your nick with "voyageur" in it reminds me of my new kindle ebook.  I started to reread "The Hitchhikers Guide to the Galaxy" that I read in normal book format many tears ago.  Its very funny and is a good way to disconnect from all programming during the day even if I am a "compulsory programmer" :-)

  And as before.

<when an SL or TP is triggered you receive 4/5 events to process in a row.

 Why make anything simple when............

In fact, each trade operation leads to 4/5 OnTradeTransaction() been processed. Nothing personal for SL/TP
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types - Documentation on MQL5
 
angevoyageur:

I agree with you and will reprogram my MT4 EA also to benefit from backtesting and multicurrency. However OOP is now available with MT4 too in the new version (last phase of beta).

I suggest you to use OnTradeTransaction instead of OnTrade. You then have to analyse the provided parameters MqlTradeTransaction, MqlTradeRequest and MqlTradeResult. The difficult is to manage successive events : when an SL or TP is triggered you receive 4/5 events to process in a row.

  Unified compiler. Now that's  terrific. Way to go!

 Next would be meta-meta statements to include different classes depending on what platform you are aiming at

 
ingvar_e:

  Unified compiler. Now that's  terrific. Way to go!

 Next would be meta-meta statements to include different classes depending on what platform you are aiming at

There is already new compiler directive.
 
angevoyageur:
There is already new compiler directive.

  Of course! Stupid me  :-)  checked it out. Beautiful

 Downloaded MT4 from metaquotes.  Changed server to demo.metaquotes.net:443

No connection.  Friday night?

Anyway I will lay down and enjoy The hitchakrs guide now.  Local Time Las Palmas G.C is 22:30

Reason: