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

Indicator OnOrderupdate Verify Position

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

    Indicator OnOrderupdate Verify Position

    Hello,

    I want to ask please if it is possible in an indicator to get the marketposition of the instrument the indicator is attached.

    Couldnt find a solution about this topic.

    Thank you!
    Tony

    #2
    Hello tonynt ,

    Thank you for the post.

    An indicator does not have an account associated with it so it is not possible to access specific trading values like Position without knowing the account first. You can use the addon methods to access an account directly to view its positions. the Addon framework can be used in other places besides the Addon type, this code could be executed from an indicator if you wanted.




    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply.

      With if (e.Order.OrderType==OrderType.Limit)
      {
      if (e.Order.OrderAction==OrderAction.Buy) .........

      I get what I need and it works ok with my bools...

      But with if (e.Order.OrderType==OrderType.Limit)
      {
      if (e.Order.OrderAction==OrderAction.SellShort) ......... my bools do not work.

      Why? We have "...Buy" for Buy-Limit and "....SellShort" for Sell-Limits (because BuyToCover would be closing a short position)


      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        I am not certain I understand the question, I would need more context on what you are speaking about. What are you referring to with "my bools do not work"? Do you mean your condition was not true?

        If something is not happening as expected, please use Prints to output what is actually happening. This data can help in understanding the problem.

        Code:
        Print(e.Order.OrderType);
        if(e.Order.OrderType .......
        In addition to the print output, I would need to know what you are doing. Are you observing an accounts order updates? If so, what event was used and what type of order did you submit? What tool was used to submit the order and what did it show up as in the control center?



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          thank you for your reply. After posting the quesition here I found out - so please confirm or correct it - that it is not OrderAction.SellShort but its OrderAction.Sell. From the helpguide and forum my understanding was that the limit for new short position is SellShort. But as non of my debugging variables worked I added print statements to the output window and there I saw that it is not SellShort. it is Sell. And since I changed this for the ordertype the indicator is working (same as it was working before with OrderAction.Buy). Interesting.

          Tony

          Comment


            #6
            Hello tonynt,

            You may see a variety of OrderAction's in this event depending on the order which was placed. In what you are specifically doing, it looks like the order type is a Sell order and not a SellShort. For an Entry you would see the Buy or Sell actions.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse,

              thank you for your reply. Its an indicator from a programmer where shorts did not work. So I changed this. For fully understanding can you please add to your information when it is a SellShort?

              Thank you!
              Tony

              Comment


                #8
                Hello tonynt,

                The information surrounding the OrderAction is pretty limited, when using the addon account methods to submit or otherwise observe orders it is expected you know what order types should be used for the types of actions you wanted to do. If you are just observing orders, I would suggest using a chart trader to submit various types of orders to see what the print output is, this will help in understand what each order type is reported as. Depending on the specifics of the order and situation it is being used for, that will change what OrderAction is being used. A SellShort can be seen when reversing a long position.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jclose, Today, 09:37 PM
                0 responses
                6 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,414 views
                0 likes
                Last Post Traderontheroad  
                Started by firefoxforum12, Today, 08:53 PM
                0 responses
                11 views
                0 likes
                Last Post firefoxforum12  
                Started by stafe, Today, 08:34 PM
                0 responses
                11 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by sastrades, 01-31-2024, 10:19 PM
                11 responses
                169 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X