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

orders not placed properly

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

    orders not placed properly

    Hi



    I have the attached strategies running and with the exception of some occasions they place orders when a reversal occurs however taking in account the strategies logic the orders should be placed whenever a bar close (as highlighted on the example of the attached picture) is bellow the previous bar close (in this case a short position) however this is not happening and as said only when a reversal occurs (and even that, not all the time).

    Also, the strategies should only open 1 position and they are opening 2


    What may be the reason for this?


    I already tried

    https://ninjatrader.com/support/helpGuides/nt8/?debugging_your_ninjascript_cod.htm
    https://ninjatrader.com/support/help...aceorders2.htm
    https://ninjatrader.com/support/help...andlingRulesTh atReduceUnwantedPositions
    https://ninjatrader.com/support/help...ryhandling.htm
    https://ninjatrader.com/support/help...rdirection.htm

    but it didn't help



    Thank you
    Last edited by ampf27; 09-06-2021, 09:32 AM.

    #2
    Hello ampf27,

    Thanks for your post. I am including my response from this morning that I have sent you via email for further context to this thread.

    Debugging Prints and TraceOrders should be used to understand the behavior of the strategy.

    Prints can be put along side order methods to confirm they are being reached.

    If you do not see the print, the order method is not reached and the condition controlling that action should be debugged with prints to see why it has not become true. This can be done by creating a new Condition/Action set that does not have any Conditions controlling it. Just an action that prints the values used in the previous condition.

    If you do see the print, and no additional order is fired, the strategy should tested with TraceOrders enabled (can be set in the Default Properties section of the Strategy Builder.) TraceOrders will tell you if an order is ignored and why. You can then reference the Managed Approach page of the Help Guide to review the internal rules of the managed approach

    Debugging Prints — https://ninjatrader.com/support/help...script_cod.htm

    TraceOrders — https://ninjatrader.com/support/help...aceorders2.htm

    Managed Approach internal rules —https://ninjatrader.com/support/help...antedPositions

    I can already note by reviewing the code that you are not allowing the strategy to make multiple entries. Please also review the EntryHandling and EntriesPerDirection sections of the Help Guide to understand how to make additional entries.

    EntryHandling — https://ninjatrader.com/support/help...ryhandling.htm

    EntriesPerDirection — https://ninjatrader.com/support/help...rdirection.htm
    You should be able to confirm with debugging prints that your logic is/is not reaching the order submission methods. Can you confirm by checking the NinjaScript output window and retesting with your prints added?

    If order submission methods are reached and the orders are not firing, did you retest with TraceOrders? Does TraceOrders mention why the order submission was ignored?

    I see that your attached code still is using EntryHandling set to AllEntries and EntriesPerDirection set to 1. This will not allow the strategy to re-enter in the same direction. If you test changing EntriesPerDirection value and remove/re-add the strategy so it processes State.SetDefaults again to load the new value, do you see additional orders submit in the same direction?

    The Playback Connection can also be helpful to retest your strategy with debugging prints and TraceOrders enabled so you can look specifically at when you expected the orders to fire to see why they did not.

    Playback - https://ninjatrader.com/support/help.../?playback.htm

    If you need additional help, please attach versions of the script showing how you have set up the debugging prints, and please provide the NinjaScript output detail and TraceOrder output detail so we can better direct you. This is because an order not submitting will either come down to the logic not allowing the order method to be reached, or the order method is ignored from an internal rule.

    One other note regarding the Close Position and the Buy/Sell Short executions. This is because when you make a reversal strategy (calling EnterLong when short or EnterShort when long,) the strategy closes the current position and submits another order to enter in the opposite direction.

    Another note is that if you are expecting the strategy to take actions are bar closes, Calculate should be set to Calculate.OnBarClose instead of Calculate.OnEachTick.

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kevinenergy, 02-17-2023, 12:42 PM
    118 responses
    2,778 views
    1 like
    Last Post kevinenergy  
    Started by briansaul, Today, 05:31 AM
    0 responses
    9 views
    0 likes
    Last Post briansaul  
    Started by traderqz, Yesterday, 12:06 AM
    11 responses
    28 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    8 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X