Index futures automation

Discussion in 'Journals' started by hilmy83, Jul 3, 2022.

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

  1. YES!

    56 vote(s)
    66.7%
  2. Hell naw.

    15 vote(s)
    17.9%
  3. I don't know, I got my own trading to worry about.

    13 vote(s)
    15.5%
  1. 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.
     
    #731     Nov 13, 2023
    hilmy83 likes this.
  2. hilmy83

    hilmy83

    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...
     
    #732     Nov 13, 2023
  3. Whatever the reason, it's almost certain that the 2nd MT5 instance is the culprit.
     
    #733     Nov 13, 2023
    hilmy83 likes this.
  4. tiddlywinks

    tiddlywinks


    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: Nov 13, 2023
    #734     Nov 13, 2023
  5. 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.
     
    #735     Nov 13, 2023
  6. tiddlywinks

    tiddlywinks


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

    Good automation to all!
     
    #736     Nov 13, 2023
  7. Piter

    Piter

    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
     
    #737     Nov 14, 2023
  8. hilmy83

    hilmy83

    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
     
    #738     Nov 14, 2023
  9. hilmy83

    hilmy83

    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.
     
    #739     Nov 14, 2023
  10. p0box4

    p0box4

    Speed shouldn't be an issue, what is the ping on both?
     
    #740     Nov 14, 2023
    rb7 likes this.