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

EnterShort/EnterLong clarification

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

    EnterShort/EnterLong clarification

    Hi,

    I am a newbie and have been playing around with a couple of strategies that I have been developing myself.

    I am basically looking for a trigger then wanting to go into a trade using EnterShort(0, quantity, "MyShort") or EnterLong(0, quantity, "MyLong").

    I call these functions once when the conditions are met from within "OnBarUpdate"

    This works fine most of the time but sometimes I get a "Close position" appear on my chart. At this point my strategy becomes say "$-200 Realised" and the trade seems to carry on. i.e. the 'Unrealised' again starts accumulating.

    Eventually when the trade reaches the Profit target the trade ends. By that time I could have already lost $600 if I had three of these 'close positions' come up.

    I have set the profit and stops in my Initialize routine as follows...
    SetProfitTarget("", CalculationMode.Ticks, profit);
    SetStopLoss(
    "", CalculationMode.Ticks, stop, false);

    I am sorry to be asking such a stupid question but looking for an answer in the help files on this just confuses me more as it seems to be very complicated to just place a simple order.

    If you could just point me in the right direction I will really appreciate it.

    Thanks

    #2
    TrevorE, it seems you're not correctly synched up in your account vs strategy positions thus impacting the realtime trading of your strategy, here is good background info on this topic -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Thanks for your quick response Bertand. I restarted the strategy (in between trades) and it all seems fine now.

      If I was willing to forfeit the trade in progress when the strategy starts up would 'flatten everything' sort the problem out instead of having to manually create an order to synchronise them?

      Comment


        #4
        TrevorE,

        No, Flatten Everything would also stop your strategy.

        If you do not want the trade you can go to Tools>Options>Strategies>NinjaScript and select Wait Until Flat. Using that will disregard any preexisting strategy positions and not make any real trades till the strategy crosses a flat state.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh, you guys ROCK!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NRITV, Today, 01:15 PM
          2 responses
          6 views
          0 likes
          Last Post NRITV
          by NRITV
           
          Started by frankthearm, Today, 09:08 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by maybeimnotrader, Yesterday, 05:46 PM
          5 responses
          26 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by quantismo, Yesterday, 05:13 PM
          2 responses
          19 views
          0 likes
          Last Post quantismo  
          Started by adeelshahzad, Today, 03:54 AM
          5 responses
          33 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X