Index futures automation

Can a fully automated trading strategy work in the long run?

  • YES!

    Votes: 56 67.5%
  • Hell naw.

    Votes: 14 16.9%
  • I don't know, I got my own trading to worry about.

    Votes: 13 15.7%

  • Total voters
    83
So open 1 lot on both instances? then close one manuallyusing same magic number? I think magic number wouldn't exist for manual trades, it's EA specific.

I'm not sure how to replicate that with the EAs, unless you're talking about closing with a script using the same magic number.

I'm just going to use unique magic number for each EA on the platforms that shares teh same VPS, and just go from there.

This happened literally 1 day after I added that second instance of MT5 on the same vps. 2 months prior to going back to MT5, no issues.

I've looked at journal and expert tabs to see what the issue is. All three platforms executed the trades within ms of each other, they all had the same exact EA alerts/messages/everything in same order.

Drives me nuts. Can't be this damn complicated lol
Here's a simple EA to sell 1 MNQ on 1 MT5 instance :
Code:
long magic_number=12345;

#include <Trade\Trade.mqh>

CTrade m_trade;       // trading object


int OnInit()
  {

   m_trade.SetExpertMagicNumber(magic_number);

   m_trade.Sell(1,"MNQZ23",0,0,0);  

   return(INIT_SUCCEEDED);

  }

void OnDeinit(const int reason)
  {

  }

void OnTick()
  {

  }
Once this is done, fire up another EA on the second instance to buy 1 MNQ by replacing "m_trade.Sell(1,"MNQZ23",0,0,0);" with "m_trade.Buy"l(1,"MNQZ23",0,0,0);". Compile both beforehand in the MQL5 editor.

If you want to go the manual route, remember that all manual trades have magic number of 0.
 
Here's a simple EA to sell 1 MNQ on 1 MT5 instance :
Code:
long magic_number=12345;

#include <Trade\Trade.mqh>

CTrade m_trade;       // trading object


int OnInit()
  {

   m_trade.SetExpertMagicNumber(magic_number);

   m_trade.Sell(1,"MNQZ23",0,0,0); 

   return(INIT_SUCCEEDED);

  }

void OnDeinit(const int reason)
  {

  }

void OnTick()
  {

  }
Once this is done, fire up another EA on the second instance to buy 1 MNQ by replacing "m_trade.Sell(1,"MNQZ23",0,0,0);" with "m_trade.Buy"l(1,"MNQZ23",0,0,0);". Compile both beforehand in the MQL5 editor.

If you want to go the manual route, remember that all manual trades have magic number of 0.

I mean if manual trades have magic number 0, one sell would close the other buy. In this case, that's not what really happned. One closed early, and the other didn't.

I think I might go insane over this...
 
I mean if manual trades have magic number 0, one sell would close the other buy. In this case, that's not what really happned. One closed early, and the other didn't.

I think I might go insane over this...
Whatever the reason, it's almost certain that the 2nd MT5 instance is the culprit.
 
Here's a simple EA to sell 1 MNQ on 1 MT5 instance :
Code:
long magic_number=12345;

#include <Trade\Trade.mqh>

CTrade m_trade;       // trading object


int OnInit()
  {

   m_trade.SetExpertMagicNumber(magic_number);

   m_trade.Sell(1,"MNQZ23",0,0,0);

   return(INIT_SUCCEEDED);

  }

void OnDeinit(const int reason)
  {

  }

void OnTick()
  {

  }
Once this is done, fire up another EA on the second instance to buy 1 MNQ by replacing "m_trade.Sell(1,"MNQZ23",0,0,0);" with "m_trade.Buy"l(1,"MNQZ23",0,0,0);". Compile both beforehand in the MQL5 editor.

If you want to go the manual route, remember that all manual trades have magic number of 0.


I'm out of my knowledge area since I know NOTHING about MT5 or it's language,but I am an experienced coder. 2 things hit me right off...

1) MNQ is quoted in quarter increments.
magic_number as a long DEmotes the actual MNQ quote, and loses all decimal places.
Any comparison that takes place internally would be affected, as well as B/A spreads that straddle handles.

2) the OnInit event returns the success/fail of the event, BUT
m_trade.Sell(1,"MNQZ23",0,0,0) MAY be throwing or returning a trade success/fail that is not being dealt with at all.


The computer was born to solve problems that did not exist before ~~ Bill Gates
 
Last edited:
I'm out of my knowledge area since I know NOTHING about MT5 or it's language,but I am an experienced coder. 2 things hit me right off...

1) MNQ is quoted in quarter increments.
magic_number as a long DEmotes the actual MNQ quote, and loses all decimal places.
Any comparison that takes place internally would be affected, as well as B/A spreads that straddle handles.

2) the OnInit event returns the success/fail of the event, BUT
m_trade.Sell(1,"MNQZ23",0,0,0) MAY be throwing or returning a trade success/fail that is not being dealt with at all.


The computer was born to solve problems that did not exist before ~~ Bill Gates
1) The magic number is an integer data type associated with and identifying a particular order and has nothing to do with the actual price quotes.

2) The simple EA's are just to open a trade in one MT5 instance and to see if it's possible to close it in a 2nd MT5 instance using the same magic number. This can be done manually as well. It therefore didn't warrant any error handling in my opinion.

Good points, nonetheless.
 
1) The magic number is an integer data type associated with and identifying a particular order and has nothing to do with the actual price quotes.

2) The simple EA's are just to open a trade in one MT5 instance and to see if it's possible to close it in a 2nd MT5 instance using the same magic number. This can be done manually as well. It therefore didn't warrant any error handling in my opinion.

Good points, nonetheless.


Thank you.
Now I can say I know almost nothing about MT5 language. LOL!

Good automation to all!
 
So I'm trying to figure any change I did to cause this. Now I did bring a new instance of MT5 last week onto the VPS (the one my account is running on). So I have 2 MT5 instances running on one, and my wife's running on a separate VPS.

I didn't bother to change anything about the algos running on those 2 instances. But I'm thinking now that since they both share magic number, I'm wondering if that caused my EA to mess up.

I thougt MT5 magic number doens't get shared across different MT5s runnign separately. I don't think that's the issue, but I'm going to make sure both instances have different magic numbers going forward.

Magic number is for identify orders from different EA. I guess if you use two separate instances you don't need different magics because the order history is local.. but maybe I'm wrong, never try use two instances with same broker account and same EA
 

upload_2023-11-14_7-28-48.png


upload_2023-11-14_7-29-10.png


As I've said, keeping yesterday's outlier out. It SHOULD'VE been a normal b/e day.

This is what the real account looks like. There were 2 positive outliers I didn't include in this performance.

upload_2023-11-14_7-32-33.png
 
I did some speed/ping test of my vps and found some inconsistencies in the speed (under 100mb/s. I actually think it's the vps that's screwing things up. My other vps is consistenly faster (+150mb/s) and it's the same package.

I'm using forexvps.net

If you are using a different service, let me know and i'll try it out.
 
I did some speed/ping test of my vps and found some inconsistencies in the speed (under 100mb/s. I actually think it's the vps that's screwing things up. My other vps is consistenly faster (+150mb/s) and it's the same package.

I'm using forexvps.net

If you are using a different service, let me know and i'll try it out.

Speed shouldn't be an issue, what is the ping on both?
 
  • Like
Reactions: rb7
Back
Top