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

Understanding start behavior

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

    #16
    I apologize for the intrusion.
    Is there a function to close a historical position manually without unlocking the script? I need historical order traces, but most of the time when I enable the strategy it has historical position which should be closed only by the end of session. Thus the strategy will not work during the day at all... Can I kind of "clean-up" or "make it flat" manually at any time of the session?
    P.S. I can not submit+synchronize account because there are limit orders in my strategy that shall be fired either above or below market which will cause the error and disable the strategy automatically. So it is a dead end...

    Comment


      #17
      The strategy is quite simple just find the historical points every time whenever it is enabled.

      Thanks.
      https://watchseriesonline.live/ https://internetspeed.onl/
      Last edited by veronimolly; 04-07-2020, 01:00 AM.

      Comment


        #18
        Hello Aporshnev,

        Unfortunately, this would not be possible without unlocking the script first.

        The order must be submitted from the strategy itself to affect the strategy position. This could be with a button added to the chart by the strategy or with internal strategy logic. Both approaches are advanced and neither are possible in the Strategy Builder.


        veronimolly,

        Welcome to the NinjaTrader forums!
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Bionian,

          The strategy will process historical data before real-time data.
          Historical orders will appear on the chart.
          https://ninjatrader.com/support/foru...442#post782442

          With Wait until flat, if the strategy calculates a historical position open, it will wait until a virtual order closes the historical position before placing any real-time orders.
          Once the strategy has become flat or crossed through flat, the strategy name will become green indicating the strategy is now sending real-time orders.
          https://ninjatrader.com/support/foru...541#post811541

          To prevent a strategy from processing any historical data use:
          if (State == State.Historical)
          return;

          To exit a position on the last historical bar use:
          if (State == State.Historical && CurrentBar == Count - 2)
          {
          if (Position.MarketPosition == MarketPosition.Long)
          ExitLong();
          if (Position.MarketPosition == MarketPosition.Short)
          ExitShort();
          }
          It would be great to have an additional marker in the menu "Close Historical Position on Next Bar" or "Do not process historical Data". This will make a lot of lives much easier on your side as well as on our side. I believe we can collect a lot of voices for this add-on in future releases - would you kindly initiate a ticket for developers?

          Click image for larger version

Name:	HistoricalDataCloseHistoricalPosition.jpg
Views:	188
Size:	104.1 KB
ID:	1085790

          Comment


            #20
            Hello Aporshnev,

            I will put in a feature request for both of these items however the option for not processing historical data is already something you can program into the builder. I don't see that we provided the steps for this so I just wanted to post it here for the time being.

            To prevent historical orders you could add the following condition to any set which should only work in realtime:

            Left: Misc -> Current State
            Center: Equals
            Right: Misc -> State -> Realtime

            I realize this is extra code that is added for the purpose and the checkbox would be easier so I will also request that. You may be able to use a UserInput with this to create your own checkbox as another step.


            I look forward to being of further assistance.
            Last edited by NinjaTrader_Jesse; 01-31-2020, 04:29 PM.
            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