Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

"Hybrid" Strategy. Is that possible ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    "Hybrid" Strategy. Is that possible ?

    I would like to have a “Hybrid” Strategy and I am asking if that's possible or not. Let me explain what I am looking for.

    That would be an Automated Strategy creating Automated Orders as usual, according to some Conditions
    (it could contain many Sets of Conditions and Actions),
    BUT at the same time that Strategy would also provide Buttons on the Chart allowing for Manual Orders placement
    directly from the User.
    Clicking the Buttons would create Manual Orders, instantly bypassing any Conditions running at the same time in the Strategy
    and taking therefore absolut priority, without cancelling or stopping the automated logic running at the background.

    Manual and Auto Order placement would coexist in the same Strategy and the User would have the ability to Enter or Exit Manually
    at any time he would want to do that, OR stay aside and leave the Strategy to execute their logic according to the programming.

    All kind of Orders (either Auto from the engine or Manual from the User) would be recognizable by the Strategy and valid,
    (updating accordingly the Position, the PnL, and the Account) regardless of the way they had initiated.

    That means we could have all the following possible combinations:
    1. Auto Enter and then Auto Exit
    2. Auto Enter and then Manual Exit
    3. Manual Enter and then Auto Exit
    4. Manual Enter and then Manual Exit
    The above combinations would be either on the Long or the Short direction.
    I repeat, manual Orders will not disturb the running program and the normal execution of automated ACTIONS according to CONDITIONS.

    Is that type of Hybrid Strategy possible ? Are there any working implementations or script Samples already available ?

    P/S
    I am fully aware of the script LONGSHORTToolbarButtonsB9 which exists in the Ecosystem and I have tested it,
    but that sample doesn’t meet the above specs.

    Last edited by KonstantinosNT; 01-27-2023, 08:10 AM.

    #2
    Hello KonstantinosNT,

    Yes you can do that, there is a sample of creating basic buttons in the help guide and also a sample strategy on the public user app share.

    https://ninjatrader.com/support/help...ub=usercontrol

    https://ninjatraderecosystem.com/use...bar-buttons-2/

    Making it work as you described would require altering the existing logic of the long short toolbar sample. You can program the buttons to perform whatever order actions you needed. You can still use existing strategy logic in combination with those buttons.

    As long as the strategy submits the orders or changes then it will work as you are expecting, a strategy otherwise can't manage any manually placed orders/positions that originated from outside that strategy.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you NinjaTrader_Jesse for your prompt reply.

      However as I wrote in the P/S:

      I am fully aware of the script LONGSHORTToolbarButtonsB9 which exists in the Ecosystem (written by NinjaTrader_ZacharyG)
      and I have tested it, but that sample doesn’t meet the above specs.


      I am kindly asking other Members of our Community, if anyone possibly knows about an already available script, capable to provide the functionality I have described, to inform me.

      Comment


        #4
        Hello KonstantinosNT,

        I understand I read that part, the answer is still to use that sample.

        To do any type of order submission/changes manually you would need to use a custom button so the strategy can submit those orders/changes its self. Strategies don't observe any manual orders, manual changes or external events.

        All of the goals you posted are possible while using that sample, you just have to work the logic out to do that.

        All kind of Orders (either Auto from the engine or Manual from the User) would be recognizable by the Strategy and valid,
        (updating accordingly the Position, the PnL, and the Account) regardless of the way they had initiated.
        This is possible by having the strategy do any of the manual actions its self. If a user manually submits an order from the superdom that won't be observed, the strategy instead needs to add a button on the chart so when that button is manually clicked the strategy submits a strategy order.

        That means we could have all the following possible combinations:
        Auto Enter and then Auto Exit
        Auto Enter and then Manual Exit
        Manual Enter and then Auto Exit
        Manual Enter and then Manual Exit
        These are all possible based on the reason described above. The strategy still needs to submit any of the manually placed orders via a button. It can otherwise use logic to submit orders automatically as well. ​


        if you had a problem executing your goal using that sample we would need more details about what you tried and what didn't work.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          the script “LONGSHORTToolbarButtonsB9” by NinjaTrader_ZacharyG doesn’t work as I would need according to my concept,
          and I can describe its functionality problem.

          Suppose that the User decides to Enter a Long position Manually, not waiting for the Automatic Entry Conditions of the Strategy
          to open the Long, because he believes the Market will be heading up. He clicks the “LONG” button and immediately a Long position
          is initiated. So far so good.

          After entering the Market, the User decides to have the Exit of that Long position executed by the Strategy Automatically.
          So, after a while, at some time the program itself decides to Exit Long (let say, as a Stop Loss) when the relevant Automatic Exit
          Conditions are met.

          This is the critical point: The Strategy successfully performs an Automatic Exit from Long position as it should, BUT at the very next tick
          a new Manual Long Entry is initiated without any new User click ! Do you know why this is happening ? I can tell you why.

          This is happening because after the first Manual Entry, the Button “LONG” has been remained pressed , waiting to be pressed again
          to Manually Exit from the Manual Entry.
          Once pressed, the Button will remain active and it will always enter a Manual Trade to the same direction, again and again,
          every time the Position gets Flat !

          This is a basic flaw and a very critical one, because at the time point the Strategy decided (according to the Automatic rules) that the
          Market was heading down and it should really Exit Long, the Button itself blindly insists to take again a NOW WRONG position,
          just because it has been pressed at some time before, and it was remained pressed since then !

          To reset the Button “LONG” or “SHORT” you must click it again. There is no other way.
          There is no way (at least for me) to modify the script in such a way to automatically reset the Button when the Strategy executes
          an Automatic Exit from a Manual Entry. It always needs a new manual click on the Button to reset it.

          So that script doesn’t meet my needs because it violates my concept rules [2] and [3].
          I would say it’s dangerous enough, because it enters in a wrong trade, at a wrong time.

          I wonder if we could find a way to simulate a "virtual" click of the Buttons to reset them, at the time the Strategy closes a former Manual Entry.

          If someone can modify that Script, allowing for automatically resetting of the Buttons (or if there is another Buttons Script working better),
          please let me know.

          Last edited by KonstantinosNT; 01-28-2023, 02:17 AM.

          Comment


            #6
            Hello KonstantinosNT,

            That sounds about right, nearly all scripts that you find online are not going to be intended to used as is or are likely to be incomplete in some way. ​I never suggest using any script from the app share for any kind of live trading because of that. Until you go through the code and make it yours it is likely not going to perform up to your expectations.

            The purpose of that sample is really just to show how to manually interact with a strategy orders and modify the user interface. The strategy uses variables to submit orders and also controls the state of the buttons. The bar events are still used for submitting orders based on the variables the buttons toggle. You will need to modify that code to actually use this in a real trading scenario because the sample is incomplete and just shows how to generally utilize the buttons but does not account for any kind of automatic resetting.

            One easy way to modify that script is to avoid doing the fancy changes it does using variables and states for the buttons. You can instead just add 1 event per button and not issue any UI changes to the button to make it much more simple. Here is a very simple example of submitting orders directly from a button handler without using the variables. That means it won't keep making new orders because you have to physically click the button for an order submission.


            Code:
            private void OnLongButtonClick(object sender, RoutedEventArgs rea)
            {
               TriggerCustomEvent(o =>
               {​
                  EnterLong();
               }, null);​
            }
            
            private void OnLongButtonClick(object sender, RoutedEventArgs rea)
            {
               TriggerCustomEvent(o =>
               {​
                  EnterLong();
               }, null);​
            }
            JesseNinjaTrader Customer Service

            Comment


              #7
              Yes, something like this could lead to a solution indeed. Thanks for your help.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by inanazsocial, Today, 01:15 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by rocketman7, Today, 02:12 AM
              0 responses
              6 views
              0 likes
              Last Post rocketman7  
              Started by dustydbayer, Today, 01:59 AM
              0 responses
              1 view
              0 likes
              Last Post dustydbayer  
              Started by trilliantrader, 04-18-2024, 08:16 AM
              5 responses
              23 views
              0 likes
              Last Post trilliantrader  
              Started by Davidtowleii, Today, 12:15 AM
              0 responses
              3 views
              0 likes
              Last Post Davidtowleii  
              Working...
              X