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

Strategy using PositionAccount vs Strategy Position

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

    Strategy using PositionAccount vs Strategy Position

    Where as Strategy looks for a strategy position to verify flat prior to enter a trade that conditions have triggered

    I want to look at the Trading Account Position prior to entering a trade

    THIS WILL ALLOW manual exits, then the Strategy knows that PositionAccount is flat and the next trigger can be triggered if conditions are met

    i am using

    StartBehavior = StartBehavior.AdoptAccountPosition;

    IsAdoptAccountPositionAware = true;

    Thanks


    #2
    Hello DTSSTS,

    Thanks for your post.

    Regarding, "I want to look at the Trading Account Position prior to entering a trade", you would use PositionAccount: https://ninjatrader.com/support/help...ionaccount.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      i was given that info yesterday and recoded about 4 ways and never could get rid of the errors





      Comment


        #4
        i added all these items with no errors but the strategy still trade on Strat position and NOT PositionAccount

        Print("The average entry price is " + PositionAccount.AveragePrice);
        Print(PositionAccount.Quantity);
        // protected override void OnBarUpdate()
        //{
        // Raise stop loss to breakeven when there is at least 30 ticks in profit

        if (Close[0] >= PositionAccount.AveragePrice + 30 * TickSize)
        ExitLongStopMarket(PositionAccount.Quantity, PositionAccount.AveragePrice);
        if (Close[0] <= PositionAccount.AveragePrice - 30 * TickSize)
        ExitShortStopMarket(PositionAccount.Quantity, PositionAccount.AveragePrice);
        if (PositionAccount.MarketPosition != MarketPosition.Flat)
        Print("Open PnL: " + PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit.Points, Close[0]));
        if (PositionAccount.MarketPosition != MarketPosition.Flat)
        Print("Open PnL: " + PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit.Points, Close[0]));
        // Prints out the current market position
        Print(PositionAccount.MarketPosition.ToString() + " " + PositionAccount.Quantity.ToString());

        WHEN TESTING strategy creates position, but when manually exit position Strategy still shows position and we are no longer insync



        thanks

        Comment


          #5
          My issue may be in this statment

          else if (AtmStrategyId[Direction].Length > 0 && GetAtmStrategyMarketPosition(AtmStrategyId[Direction]) == Cbi.MarketPosition.Flat)
          AtmStrategyId[Direction] = string.Empty;

          Comment


            #6
            Hello DTSSTS,

            Thanks for your replies.

            Can you provide an overall context of what you are trying to do?
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              MANUALLY EXIT A POSITION AND HAVE THE STRATEGY POSITION BE ZERO JUST LIKE THE live account
              Strategy using PositionAccount vs Strategy Position

              01-17-2020, 03:15 PM
              Where as Strategy looks for a strategy position to verify flat prior to enter a trade that conditions have triggered

              I want to look at the Trading Account Position prior to entering a trade

              THIS WILL ALLOW manual exits, then the Strategy knows that PositionAccount is flat and the next trigger can be triggered if conditions are met

              i am using

              StartBehavior = StartBehavior.AdoptAccountPosition;

              IsAdoptAccountPositionAware = true;

              Thanks

              Comment


                #8
                Hello DTSSTS,

                Thanks for your reply.

                I may not be fully understanding what you are trying to do however:

                The start behavior only effects when the strategy is started for the first time and would only impact the transition from historical to live data. Managed approach enter/exit methods follow the strategy position. AdoptAccountPosition would just inherit the account position, it does not tell the strategy to follow the account position, and does not support new manual orders.

                You may want to add chart "buttons" to place manual orders through the strategy so that these effect the strategy position.

                Note: The atm strategy position would be unrelated to the strategy position because it is a unique strategy, and using Enter/Exit Managed Approach methods would affect the strategy that is calling those methods, not the atm.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Chart buttons meaning a custom indicator with buttons on the chart. in the code some where the buttons are directed at the strategy?

                  Comment


                    #10
                    Hello DTSSTS,

                    Thanks for your reply.

                    No, buttons that your strategy would place on the chart. Here is a link to an example: https://ninjatraderecosystem.com/use...bar-buttons-2/ Please note: The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      so i can manually close position with these buttons

                      does the position have to be opened from an open chart or can they be from the control panel Strategies tab

                      I see this file is 2015 I ask all about this over and over to manually close strategy trades over 2 years ago, never say this before

                      Comment


                        #12
                        Hello DTSSTS,

                        Thanks for your reply.

                        The buttons can be programmed to enter or exit trades within the context of the strategy. This means the strategy position and its account position would be in sync (assuming the entries were made in the context of the strategy).

                        The buttons would only work on a chart, they would not work if the strategy was created from the strategies tab.

                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          OK installed buttons, but i do not find anything in Indicator list about this, What is the Name and Where find
                          Thanks

                          Comment


                            #14
                            Hello DTSSTS,

                            Thanks for your reply.

                            If you installed the download from the forums link I provided called LongShortToolbarbutton, it will be found in the strategies folder of the Ninjascript editor as it is a strategy.


                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Got It Have a nice weekend

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              26 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              163 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Started by Mizzouman1, Today, 07:35 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X