Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTMARKETPOSITION = Trouble / Bug

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

    NTMARKETPOSITION = Trouble / Bug

    I have spent the last 2 days grinding through what I have thought was coding problems on my TS EL strategy.

    By taking it apart and putting it back together, I found that ntmarketposition does not work properly.

    My code makes use of....
    NTMARKETPOSITION("") =0
    NTMARKETPOSITION("") =1,
    NTMARKETPOSITION("") =-1


    By replacing NTMARKETPOSITION with the TS function, marketposition, I was able (it seems) to get the strategy to work as it should.

    #2
    Can you please be a little more descriptive about the problem you are facing? Not sure what you mean at the moment. Also see if using NTMarketPosition("") instead of NTMARKETPOSITION("") helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      I did not go through the narrowing down process to be 100% sure of the problem. It feels like it reports nothing but 0.

      If I was short and I had a buy signal, no auto trades. If I took it flat manually, it would cause an automated buy. If I was short the reverse would happen.

      I was typing one handed and therefore the caps for NTMarketPosition.

      I had it in the code as NTMarketPosition("").

      Thanks,
      Don

      Comment


        #4
        Try just printing NTMarketPosition() on every bar without running logic.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          I created an EL indicator.

          The value of NTMarkettPositon("") = the net market position in size not in a 1 or -1 value.

          In my case my net position size is 10000. Being a reversal system, the indicator is either 10,000 or -10,000. I say net because I begin with a manual 10,000 position and then auto trade 20,000 long and 20,000 short and so on.

          Don

          Comment


            #6
            Right. That is what it is suppose to do.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Sorry for the trouble...

              In EL (similar name), it operates differently.

              I guess I have learned that I will do a print command or create an indicator for every function before using it!

              Thank you
              Don

              Comment


                #8
                This morning the indicator was only producing a zero result.

                Restarted the computer, Ninja and TS. Same thing.

                Reinstalled NT, no difference. NTMarketPosition("") is only putting out a value of "0" no matter the market position.

                Don

                Comment


                  #9
                  What NT version are you using?

                  Try passing in the account number and see if it makes a difference.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Ray,

                    I am running 6.5.0.9

                    That didn't work

                    While now the indicator is moving to correct values (used regedit and did fresh install of NT) , when used in this way....

                    Not as programmed in EL but to explain the issue

                    If NTMarketPosition("sim101") <= -10000 then begin;
                    Buy 10000 at market


                    It continues to buy over and over.

                    Thanks
                    Don

                    Comment


                      #11
                      That would be expected behaviour. Each call to any function to place an order *will* place an order. If you only want to place one, then you need to code for that.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        How can it place more than one order if it is being restricted by the current positon size? The order is conditional. The condition is being short 10,000 or more.

                        Comment


                          #13
                          Then the condition must continously be true for the order placement method to be continously called, maybe you are running the strategy on historical bars in which case it could place a tonne of orders before the first order is actually filled?

                          In any case, you will need to debug to see what is happening but what is certain is the order function is being called many times.
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            If the chart is on a long signal and my position has grown to 70k and keeps going, something is wrong with NTMarketPosition.

                            No argument it is being called many times, but if the code says to only allow a trade to take place if the position is less than 10,000 and the position size is 70000, then 80000 and so on, the function is not doing what is intended.

                            Comment


                              #15
                              Lets not mix apples and oranges.

                              - Orders are placed since the order function is called many times --> This works as expected

                              - What you are saying is that the NTMarketPosition() is not updating correctly. That is not the question you asked me.

                              Please create a strategy that has the following code:

                              Print(NTMarketPosition("Sim101"));

                              - Start NT
                              - Enable Automated Trading Interface
                              - Start TS
                              - Open a chart, does not matter what instrument as long as the market is trading
                              - Connect NT to whatever feed you are using
                              - In the Control Center Order Panel, select the same instrument that you have a chart open for
                              - Place an market order to buy
                              - Verify there is an open position in the Control Center Position tab
                              - Apply the strategy to the chart
                              - You should see in the EL output window the correct position size that is displayed in the NT Positions tab

                              --> If this is not the case let me know
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              16 responses
                              3,279 views
                              0 likes
                              Last Post Leafcutter  
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Working...
                              X