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. hilmy83

    hilmy83

    What I have so far...


    Error checks


    This algo will initiate the following error checks while the algo is in session (within Time start and Close time. After the alert, perform the action.


    • NO STOP OR NO TARGET- A position has no stop or target or both (naked position)
      • Action: Resend the missing target or stop loss orders.
    • PHANTOM ORDER - Open orders that are still active after the position is already flat.
      • Action: Cancel all orders.
    • INCORRECT STOP LOSS OR TARGET LOTS - Lot quantity for stop loss and target does not match the open position lots.
      • Action: Cancel orders and resend new orders to match the open position lots.
    • DUPLICATE INITIAL STOP ORDERS - Algo sends out duplicate stop orders (instead of just 1 buy/sell stop orders, there are 2x buy/sell stop orders.
      • Action: Cancel all orders and resend orders per the rules.

    The following scenarios can happen in a live market environment. Orders go from “In Transit” to “Working” in live trading. Sometimes, there may be latencies as well that can cause these errors to occur. If they happen, check for errors and perform the action:

    • Delayed orders:
      • Example: Buy stop order has executed, but the sell stop order is still in Transit and placed later (therefore has not been canceled per rules leaving it open).
        • Action: Cancel the sell stop order since buy stop order is already triggered
      • Stop order is executed, but as the target is being placed (in Transit), price has already crossed the target.
        • Action: Exit the position at market since the price is already at target price
    • VPS/internet disconnection
      • Action: check to make sure the above errors did not trigger. If it does, perform the respective actions.
     
    #611     Sep 20, 2023
  2. hilmy83

    hilmy83

    #612     Sep 20, 2023
  3. rb7

    rb7

    If I may, all this sounds very complicated.
    Maybe your architecture was not well done at the beginning, or maybe it's a limitation of QT.
    IMO, you don't do your things all at once and then look at the overall results.
    You do one thing, wait for the result, and then if the result is what you were expected, you do the next step. If the result is not what you were expected, then you do the exception (whatever that is).
    Also, each time you execute an exception, your algo should send an alert to you (via sms, email, etc.).
     
    #613     Sep 20, 2023
  4. hilmy83

    hilmy83

    I think what I would end up doing is basically insert the error check at the relevant steps within the algo. Like you said, after an event, what possible error can occur? If the error is valid, that's where I will have the alert sent out (through QT's internal Telegram bot), then do the exception (action) like you said.

    I'm actually rewriting my requirements for the algo rebuild. Making sure I cover the issues i've seen so far and whatever else that could go wrong.
     
    #614     Sep 20, 2023
    rb7 likes this.
  5. Bad_Badness

    Bad_Badness

    Please take this is a positive note. This is amateur hour stuff. Simple put it is backwards.

    What one does is create classes, using the formal mathematical meaning, of issues. Then one tries to create the "minimum cover", again in the formal meaning, to cover all the instances in that class.

    For example, some classes are
    • Transaction failure.
    • Order generation failure.
    • Reporting failure.
    Each one of these classes has dozens-hundreds of instances and-or sub classes. You write code to cover the entire class (or subclass) and not pick and poke at the various instances. Otherwise your code will be a mess and become un-: testable, debug-able, scalable, portable.

    It is not about putting in a block here and a block there. That is the amateur part. It is about having a structure-architecture, to handle groups of issue.

    This is software engineering 101a. Use a backhoe, not a shovel.
    Hope this helps.

    PS: As RB7 says, can just get an error log to get a feel for the "universe" of errors. Then take those errors and identify which classes those instances belong too.
     
    #615     Sep 20, 2023
    hilmy83 likes this.
  6. hilmy83

    hilmy83

    First, don't need to preface your posts as if i'm going to be offended. I'm basically at ground zero (or maybe even below) with coding/algo/software development knowledge. So whatever you want to share, it'll probably go over my head, but I'm going to try to understand.

    FYI, I'm actually going through the Foundational C# from freecodecamp. And I'm exactly at the point where they are talking about call methods and creating instances, using libraries etc.

    This is probably going to take me months or even couple of years to get it right. Plus I'm not terribly bright (IQ 100 last time I checked). So bear with me.

    Good thing is that I had my MT5 coded by this Ukranian (most likely Russian) before I switched over to QT. The EA itself looks like it's working fine before I switched over, so now I'm using it full time until I get this QT stuff figured out.

    But maybe I would switch to something else. There's NT, multicharts, sierra charts...etc. Honestly I don't know if QT is the best since my algo user experience is limited to MT5 and QT.

    This journal is turning from "can this algo work long term?" to "watch this fool try to code".

    Lesssgoo
     
    #616     Sep 20, 2023
  7. Bad_Badness

    Bad_Badness

    Good attitude!!!

    From my review of the bug reports and fixes, I cannot recommend NT. It looks good but the type of bugs indicate it is not a stable platform and is continually making code infrastructure changes. MC desktop has its order handling limitations, but it seems a reasonable choice for prototyping. QT visa vi C is probably equivalent to others. It is the order handling engine in MC desktop that has "limitations", but I would assume all do.

    BTW: Now that you have some experience, you have reached the first step. Now you have a better understanding of what to spec out if you want to go with a dev again.

    Best of luck!
     
    #617     Sep 20, 2023
  8. hilmy83

    hilmy83

  9. hilmy83

    hilmy83

  10. hilmy83

    hilmy83

    With +100 hrs so far in Baldur's gate 3, I'm seeing a lot of similarities between witcher 3 and bg3. But this, this is just outright copycat.
    Witcher 3 is 100% better I think...

    Singing girl





    Immortality



     
    #620     Sep 24, 2023