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

Identifying entry signal of current position

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

    Identifying entry signal of current position

    My strategy uses multiple entry signals (e.g., Signal1, Signal2, etc.). I'd like to have different stoploss modifications for these entries (e.g., Signal1 stoploss modification, etc.), so when I have an existing position, I need to be able to determine which entry signal generated that position in order to apply the correct stoploss adjustment.

    Is there an easy way to determine this within OnBarUpdate (i.e., without having to get into OnOrderUpdate)?

    #2
    Hello dolomite,

    Thank you for your post.

    You would likely want to associate the Position.AvgPrice with the order that you submitted, that is if the two entries used different price levels. However, this is not exact - what if both orders fill at the same price? Plus if both orders fill and not at the same price level we would pull the average price of the two fills.

    What are you trying to adjust? A SetStopLoss() or an Exit method?

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      What are you trying to adjust? A SetStopLoss() or an Exit method?
      SetStopLoss

      So I'm something like . .

      If [have an existing position from Signal1]
      SetStopLoss("Signal1", CalculationMode.Price, some calculated price, false)

      If [have an existing position from Signal2]
      SetStopLoss("Signal2", CalculationMode.Price, some other calculated price, false)
      Last edited by dolomite; 02-19-2015, 12:59 PM.

      Comment


        #4
        Hello dolomite,

        Thank you for your response.

        Track the execution of the entry in OnExecution(), store the values of the fill price and/or track that a position is opened by a signalName. Then check these value sin OnBarUpdate().

        For information on OnExecution() please visit the following link: http://www.ninjatrader.com/support/h...nexecution.htm

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello dolomite,

          Thank you for your response.

          Track the execution of the entry in OnExecution(), store the values of the fill price and/or track that a position is opened by a signalName. Then check these value sin OnBarUpdate().

          For information on OnExecution() please visit the following link: http://www.ninjatrader.com/support/h...nexecution.htm
          I was hoping to keep this simple and stay in OnBarUpdate, but if I must mess around with OnExecution, I guess I will.

          What happens if I don't check to see which signal a position was created from, and simply execute the following:
          SetStopLoss("Signal1", CalculationMode.Price, some calculated price, false)
          SetStopLoss("Signal2", CalculationMode.Price, some other calculated price, false)

          If there is no position created by Signal1 entry, will this throw an error?

          Comment


            #6
            Hello dolomite,

            Thank you for your response.

            It would generate a message in the log but should not affect the functionality of the other SetStopLoss().

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            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  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            23 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X