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

Contract Size Problem

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

    Contract Size Problem

    I have a simple strategy that is working well except for one thing. I have EnterLong(1);
    and
    EnterShort(1);
    in the code at the appropriate locations. Orders are executed ok except that the order is executed with 2 contracts instead of 1. I wanted to be sure the number of contracts was entered exactly as I wanted which is why I'm using EnterShort(1);

    So, can you please tell me why it enters with 2 contracts.

    Thanks,
    Mike

    #2
    Mike,

    When you go EnterShort after you already have a long position it will automatically close your long first then sell 1 to go short. This is why you see it being done with 2. If you want to just close that long position with sell 1 you would want to use ExitLong() instead of EnterShort(). The vice versa case is the same thing as well.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I see said the blind man...It just confused me when my strategy entered a position and in my second chart that I use to monitor the trade with Chart Trader, I see the number of contracts as 2 and my PNL increments twice the amount it should. So in other words, I see 2 contrack in Chart Trader and I also see my PNL for the current trade as being $100 instead of $50. Like right now I have a long on EMD at 490.5 with current price at 500.5. That means I have 10 points in this trade which translates to $1000 but my PNL shows $2000.

      My Account Performance seems to show what you described. So, what am I overlooking on the Chart Trader?

      Thanks,
      Mike

      Comment


        #4
        Not sure what you mean Mike. Chart Trader is independent from a strategy. It may show 2 because it is two contracts.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I understand the difference between chart trader and strategies. Let me be a bit more specific and hopefully this will help.

          I have my strategy running on one chart and obviously WITHOUT chart trader on that chart. The strategy is running against one of my simulation trading accounts called "MySimAcct".

          I have another chart up WITH chart trader on that chart. Chart Trader on this chart is using the same account as my strategy. So chart trader is looking at the "MySimAcct" simulation account.

          Using my charts like this I can see exactly where the orders are and how it's progressing without interfering with the strategy. This second chart is what I was referring to in my previous post that shows 2 contracts and twice the amount of PNL on the current trade. Further, the positions tab on the control center shows the same thing as my second chart. Please realize that my second chart is only being used to monitor the strategy generated trades. There is no ATM Strategy on that chart nor is the quantity set to 2...it is set to 1.

          Hopefully this clears up my question. Regardles what the Chart Trader is showing for PNL, the Positions Tab during the trade shows the same thing.

          Mike

          Comment


            #6
            So what does it say on your first chart? How many contracts do you have there?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              it shows Close position [email protected] and Buy [email protected].

              Comment


                #8
                If it is correct on the Strategy then it should be fine. For Chart Trader it is most likely showing 2 because the strategy made a trade of 2. Because the Chart Trader does not know that one of them was to close a prior position there is no way it will show 1 instead of 2.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  what about the Positions tab in control Center...it shows the same as chart trader. I'll do an audit at the end of the day to see if the reports show anything other than what they're supposed to and let you know.

                  Mike

                  Comment


                    #10
                    Could be the same reason. See how the audit goes first.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      I figured it out...i wasn't doing anything to only take one trade at a time. So, I added a boolean keeping track of when i'm in a trade.

                      Mike

                      Comment


                        #12
                        I thought i'd figured it out but no luck. Still having the same problem. So, I loaded the sample MACrossover to see how it works. It does the same thing. So, can you please take a look at that one. Looks like it works perfectly when backtesting but when on a live market, it enter multiple contracts.

                        Comment


                          #13
                          Not sure what you mean Mike. As long as the strategy keeps track correct it is right. The SampleMACrossOver makes all necessary trades. If it were long it goes short with 2 contracts. One to close the long and one to get short.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            I haven't replied because I've been troubleshooting this problem and getting more and more confused as to what is going on. I understand that EnterLong() and EnterShort() will cause an open position to be closed and a new position to be placed. And all that is supposed to happen with whatever number of contracts i specifiy. So in other words, if I am currently short and the conditions for a long are fired, EnterLong() will use one contract to close the short position and another contract to enter long. That is very simple and understandable. That isn't what is happening with your SampleMACrossOver strategy when running in a live market. When using the Strategy Analyzer on historic data, it performs exactly the way I described. But not in a live market. Here's what happens in a live market.

                            Let's say I'm short and the conditions for a long are met. The short position is closed and a long position is opened with 2 contracts not 1 as it should. Again, same thing in the Strategy Analyzer on historic data enters with 1 contract as it should. I hope this is clear because I don't know how to say it any more clearly. by the way, entering with 2 contracts happens every time.

                            As of this afternoon something new has started happening. The SampleMACrossOver strategy won't enter any short positions, only longs. I noticed this with my own very simple strategy and so I place a print statement in the same block of code where the EnterShort() is to make sure it was getting to that block and it is. I messed around with this for a while and even closed NT and restarted it. That didn't fix it. So, I closed my strategy and place the SampleMACrossOver strategy on a chart and I get the same results. It will only enter longs, no shorts.l

                            Very frustrated and begging for a miracle.

                            Mike

                            Comment


                              #15
                              Mike,

                              I do not know what you mean. Please post screenshots, logs, etc. outlining what you feel is wrong. You will also need to include reproducible steps. Again, you need to compare apples to apples. Just look at what the strategy is doing and nothing else.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              14 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Yesterday, 07:51 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,983 views
                              3 likes
                              Last Post jhudas88  
                              Working...
                              X