Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Take action based on existing position

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

    Take action based on existing position

    Can someone please point me toward some documentation for making a trading decision based on an exiting love position.

    For example if profit/loss of exiting position is X then initiated a another position etc

    Is that possible in NT?

    Both will have to be independent (separate strategies) but perhaps they can read each other's profit/loss?

    Thanks

    #2
    Originally posted by calhawk01 View Post
    Can someone please point me toward some documentation for making a trading decision based on an exiting love position.

    For example if profit/loss of exiting position is X then initiated a another position etc

    Is that possible in NT?

    Both will have to be independent (separate strategies) but perhaps they can read each other's profit/loss?

    Thanks
    Strategies do not cross communicate.

    It being just c#, there are ways to get data from one strategy to another, but they are all unsupported hacks. Here is one. You will have to adapt it to your circumstances.

    ref: http://www.ninjatrader.com/support/f...ons#post354670

    Comment


      #3
      Thanks

      Can one strategy analysis multiple positions?

      For example

      Logic 1= XYZ happens go long
      Logic 2= if logic 1 position is live then do ABC on a different symbol

      Essentially I'm working on a strategy between two symbols

      Comment


        #4
        Originally posted by calhawk01 View Post
        Thanks

        Can one strategy analysis multiple positions?

        For example

        Logic 1= XYZ happens go long
        Logic 2= if logic 1 position is live then do ABC on a different symbol

        Essentially I'm working on a strategy between two symbols
        There is a string property called Position.Instrument.Fullname. You can query that, and go from there.

        Comment


          #5
          Hello calhawk01,

          Thank you for your post.

          As accessing the other strategies is unsupported, I would provide you details on accessing a strategies current position to pull profit and loss using GetProfitLoss(): http://www.ninjatrader.com/support/h...profitloss.htm

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello calhawk01,

            Thank you for your post.

            As accessing the other strategies is unsupported, I would provide you details on accessing a strategies current position to pull profit and loss using GetProfitLoss(): http://www.ninjatrader.com/support/h...profitloss.htm
            thank you

            before i jump into trying to figure out how to do this; can you confirm that it is possible to store multiple symbols in the same strategy? what i'm trying to do is exactly:

            if symbol 1 profit= XYZ; then go long symbol 2; then if symbol 1 profit = ABC; then exit symbol 2.

            essentially i'm trying to create a hedge for symbol 1 position if the loss increases etc

            Comment


              #7
              so i tried:

              the strategy once compiled is being run on SPY.

              the additional intrument is FAS

              Add("FAS", PeriodType.Minute, 1);
              //go long SPY if the below crossover happens
              if (CrossAbove(RSI(14, 0), 30, 1))

              {
              EnterLong();
              }

              }
              //if SPY is long and loss is more than 10 cents; then go long FAS

              if (Positions[0].MarketPosition == MarketPosition.Long
              && Close[0] < Position.AvgPrice-.10)
              {
              EnterLong(1,1,"Buy FAS");
              }
              It seems to ignore the second logic "if long"

              how do i make a reference to buy FAS?


              btw; i looked at the sample multiple instrument strategy. it doesnt even execute trades on multiple symbols.. i'm not really sure why it's a sample called multiple instruments.
              Last edited by staycool3_a; 08-24-2014, 08:57 PM.

              Comment


                #8
                Hello calhawk01,

                Thank you for your response.

                Set EntriesPerDirection to more than 1: http://www.ninjatrader.com/support/h...rdirection.htm

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello calhawk01,

                  Thank you for your response.

                  Set EntriesPerDirection to more than 1: http://www.ninjatrader.com/support/h...rdirection.htm
                  still doesnt work. instead of buying the additional added instrument.. it buys the primary instrument when profit goes below 10 cents

                  Comment


                    #10
                    ok i got it to buy both positions.

                    Code:
                                if (Close[0] > 0)
                        {
                           
                             EnterLong(PrimaryQuantity, "PrimaryBuy");
                        }
                            if (Close[0] [B]< Position.AvgPrice[/B]-hedge)
                        {
                            EnterLong(1,HedgeQuantity, "HedgeBuy");
                        }
                            else if (Close[0] > Position.AvgPrice-hedge)
                        {
                            
                            ExitLong(1,"HedgeSell", "HedgeBuy");
                        }
                    seems to be the issue. is there a better way to reference Primary Buy and Hedge buy when creating an entry/exit signal?


                    meaning how can i get average entry price for ''primary buy". i'm unable to apply indexing to position.avgprice
                    Last edited by staycool3_a; 08-25-2014, 01:42 PM.

                    Comment


                      #11
                      protected override void OnBarUpdate()
                      {
                      if (Close[0] > 0)
                      {

                      EnterLong(0,PrimaryQuantity, "PrimaryBuy");
                      }
                      if (Close[0] < Position.AvgPrice-hedge)
                      {
                      EnterLong(1,HedgeQuantity, "HedgeBuy");
                      }
                      else if (Close[0] > Position.AvgPrice-hedge)
                      {

                      ExitLong(1,"HedgeSell", "HedgeBuy");
                      }
                      }
                      actually i take that back. i had to enter the bolded to execute the primary order first and then take actions based on the primary order. by adding the above bolded [0] now the logic is not executing the hedge position...

                      1) why is the hedge not executing? max entries is set to more than 1

                      2) how do i reference the entry price for the primary signal?

                      Comment


                        #12
                        Code:
                        {
                                  if (Position.MarketPosition == MarketPosition.Flat && Close[0] > 0)
                            {
                               
                                EnterLong(0,PrimaryQuantity, "PrimaryBuy");
                                 SetProfitTarget("PrimaryBuy", CalculationMode.Ticks, Profit);
                            }
                                [B]if (Position.MarketPosition == MarketPosition.Long 
                                    && Close[0] < (Position.AvgPrice-hedge))
                            {
                                EnterLong(1,HedgeQuantity, "HedgeBuy");
                            }[/B]
                                if (Close[0] > Position.AvgPrice-hedge)
                            {
                                
                                ExitLong(1,"HedgeSell", "HedgeBuy");
                            }
                        }
                        looks like the bold part keeps adding additional size to the hedge position everytime that condition is true. how can i make it so that it ends the position when close is > position.avgprice-hedge.. the last part of the script

                        i think i need to know how to reference the primary buy rather than saying ''avgprice''
                        Last edited by staycool3_a; 08-25-2014, 02:22 PM.

                        Comment


                          #13
                          Code:
                                   if (Positions[0].MarketPosition == MarketPosition.Flat && Positions[1].MarketPosition == MarketPosition.Flat && Close[0] > 0)
                              {
                                  EnterLong(0,PrimaryQuantity, "PrimaryBuy");
                                  SetProfitTarget("PrimaryBuy", CalculationMode.Ticks, Profit);
                              }
                                  if (Close[0] < (Positions[0].AvgPrice-hedge))
                              {
                                  EnterLong(1,HedgeQuantity, "HedgeBuy");
                              }
                              {
                          [B]        if (Positions[0].GetProfitLoss(Close[0], PerformanceUnit.Currency) == 0)
                              {
                                  
                                      ExitLong(1,"HedgeBuy", "HedgeSell");[/B]
                              }
                              }
                          does not end the position. even thoough the first position is flat and the unrealized pnl is 0; we're still long

                          Comment


                            #14
                            Hello calhawk01,

                            Thank you for your responses.

                            Please try Positions[0].AvgPrice.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by techgetgame, Yesterday, 11:42 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post techgetgame  
                            Started by sephichapdson, Yesterday, 11:36 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post sephichapdson  
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,613 views
                            0 likes
                            Last Post aligator  
                            Started by jaybedreamin, Yesterday, 05:56 PM
                            0 responses
                            10 views
                            0 likes
                            Last Post jaybedreamin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            6 responses
                            20 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Working...
                            X