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

Help with reversal

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

    Help with reversal

    Hello,
    I am attempting to enter into a reversal trade if the current trade I am in goes against my strategy.

    Here is how I currently understand it:
    1. I enter a Short trade with EnterShortStopLimit at 100. Normally you would want to put a SetStopLoss somewhere above since we are going Short; let's assume 105.25, which would be one tick above the High on that candle in this scenario. Instead of doing that I would want to put a EnterLongStopLimit at 105.25 so if it's hit we assume the trend is going against our initial strategy. Additionally I'll set a SetProfitTarget to exit the trade if we get X number of ticks.
    2. Now we are in a Long trade because our Short trade went against the direction we thought it might go; after the long trade is in I'd like to set a SetProfitTarget and a SetStopLoss because we do not want to ping pong between a short and long trade.
    I have written some code but it is not working how I think it should be working; are there any examples of what I mentioned above that code be reference or maybe a snippet that I can reference?

    I can share my code if you feel it might be I wrote it incorrectly.

    Thank you for any help!
    Travis Sloneker
    Last edited by travisloneker; 04-12-2021, 01:20 PM.

    #2
    Hello travisloneker,

    The description provided is a little confusing, you mentioned entering Short with EnterLongStopLimit which should enter a Long position and not short.

    If you are trying to use exit orders instead of the SetStopLoss you can do that, there is a sample of exiting with Exit orders in the following post.



    To reverse a position you can just call the opposite entry, for example if you are short you can call EnterLong and that would reverse the position.

    If part of what you made is not working it may be helpful to use Print statements to further identify what specific part is not working correctly. That could help to know what code to ask about in future posts or help to provide more targeted examples of what you tried.

    If you are trying something which you think should be working you may also want to enable TraceOrders to see if you are doing something which conflicts with the managed order handling rules. https://ninjatrader.com/support/help...lightsub=trace

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,
      Sorry to be confusing; I'll make it more simple. I enter a LONG with EnterLongStopLimit at let's say 100; I would normally set a SetStopLoss one tick below the Low of the entry, let's say 98.5, but instead I would like to reverse at that one tick below.

      Would I use a EnterShortLimit at 98.5 in place of the SetStopLoss so when it hits that price I would have closed my LONG position and am now in a SHORT position?

      Comment


        #4
        Hello travisloneker,

        Thank you for the reply.

        Thats right, Entry methods will reverse the position automatically. For example if you are in a 1 contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position.

        EnterShortLimit can be expired if you only call that for 1 OnBarUpdate call, for example your condition is true to submit the EnterShortLimit but then stops being true before its filled, the order is expired. You can either make the condition remain true until it fills or use LiveUntilCancelled .




        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        43 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        25 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        46 views
        0 likes
        Last Post jeronymite  
        Working...
        X