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

Enter Extra Contracts On Pullback While Conditions Are Still True

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

    Enter Extra Contracts On Pullback While Conditions Are Still True

    Hello,

    I have been trying to figure out which option is best for what I am trying to accomplish before I spend a lot of time trying to get it done on my own. I am trying to enter extra contracts on a pullback while I am still in a trade that direction. How I have it coded, I can use trade 1, trade 2, trade 3 which will be based off trade 1's entry signal.

    Option 1: Use Limit Orders
    I can have Trade 1 enter right as my conditions are true.
    Now I could place limit orders with an offset wherever I want for trade 2
    Then even further for trade 3.


    I have been trying to work on limit orders for awhile and have had to use live until cancelled true for now since I have struggled with getting orders cancelled and then allow rentry after cancelled. I know this has to do with on orderupdate but I just haven't had the time to fix it since my strategy still works well on other parameters without it. For this new system I am working on it takes more trades so it would be bigger task and good for me to figure out longer term.

    Option 2: Trigger States/EntryFlag/Bools (If that is the right terminology)

    For this I figured I can have all the on bar update logic nested and then when it becomes true enter trade 1.
    Then for trade 2 I was thinking have my entry flag or whatever I choose be true, then when the (close[0]<= Positions[0].AveragePrice - trade2offset*Ticksize) becomes true it will activate trade 2 and then repeat with a similar logic for trade 3.

    Coding wise will one be easier to accomplish? I have been learning a lot of coding over the last 2 years just by trial and error and have had systems running live without any issues after extensive market replay and live testing. Essentially just want to know which option could be better

    #2
    Hello durdcash,

    That depends on what overall logic you need to complete for the extra orders. OnExecutionUpdate can be used to trigger orders, that would generally be where you submit custom targets from that use live until cancelled. That would also be used if you need entry fills to directly influence submitting any other order.

    OnBarUpdate is generally reserved for bar related logic, submitting extra orders would be submitted at the rate OnBarUpdate is called and not based on the entry fill. In your example the close being less than the average price that would need to go in OnBarUpdate. If you called that from OnExecutionUpdate the close may or may not be below the average at the time of the entry fill so that may or may not be submitted. OnExecutionUpdate is only called one time for each execution or fill. You can continously check that condition in OnBarUpdate to make sure the next order fills while the condition is true.

    You likely need to use a combination of both logic in OnBarUpdate and OnExecutionUpdate for a complete strategy.

    JesseNinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Jesse I use internal logic that waits for the bid/ask to run by any of those level since I do not use the set method for my profit target, trail, breakeven, or my stop. One of the previous strategies I created I essentially used a multi data series to submit NQ and RTY off of my ES trade signal. Then, I have had it just exit when looking at Position of the primary data series. If I use that type of simple exit, is there anything I should be careful of? So by doing this, would I only be using on bar update or would it still need to have on execution update used as well?

      If you would like any more detail, just let me know.

      Comment


        #4
        Hello durdcash,

        I really couldn't speculate on anything to be careful of, you would have to test the strategy in the use case you plan to use it and make sure the logic you used works as intended.

        Where you put your code largely depends on how you want that code to work. OnExecutionUpdate is called for order executions, if you want to drive logic based on executions you would need to use that override. If you don't want to drive logic based on executions you don't have to use that override.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pecunianonolet, 11-28-2016, 03:34 AM
        5 responses
        4,510 views
        0 likes
        Last Post Futurestrader00  
        Started by reynoldsn, Today, 07:23 AM
        4 responses
        9 views
        1 like
        Last Post reynoldsn  
        Started by bee1943, Today, 09:55 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by FAQtrader, 04-25-2024, 12:00 PM
        7 responses
        103 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by giulyko00, Yesterday, 11:49 AM
        4 responses
        28 views
        0 likes
        Last Post giulyko00  
        Working...
        X