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

Simplest of questions.

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

    #31
    Thanks Ben,

    This is going to be the silliest first "contribution" (addind something instead of constantly benefitting from the kindness of all the folks at NinjaTrader Customer service).

    I don't know if it's NT, or the .net framework that is used in conjunction but simply closing and reopening the NT application sometimes isn't enough to get back to the default values. The perserved values for me lasted through 3 NT restarts. Then I tried rebooting my machine and then starting up NT and the values reset to their defaults.

    Thought I would share that in case anyone else encounters the issue.


    Originally posted by NinjaTrader_Ben View Post
    Hello,

    What exactly is the issue you are experiencing now?

    If you are having issues with your inputs changing settings in backtesting will not change your code, but the vlaue of 100 will be perserved until the next time you open NT.

    If you having issues with the BarsInProgress please post code.

    Comment


      #32
      Hello,

      Which setting won't reset? Can you provide screen shot of it?
      Can you reproduce the behavior?
      DenNinjaTrader Customer Service

      Comment


        #33
        I don't know. I haven't tried. I can if you want me to.

        The last time this happened (the event that prompted me to ask), Windows had to force and end program on something called ctfmon.exe. I don't know what that does, but thought it might be a clue.

        I've included screen shot. Basically the numbers in the green box don't reflect the supposed defaults as listed in the red box. This is even after I shut down NT and started it back up again. No big deal. Restarting the computer did the trick.

        Hope this is the information you wanted.

        Thank you very kindly for your help.

        Originally posted by NinjaTrader_Ben View Post
        Hello,

        Which setting won't reset? Can you provide screen shot of it?
        Can you reproduce the behavior?
        Attached Files

        Comment


          #34
          Hello,

          I have no idea why this happened. Try rebooting your PC and seeing if it happens again.

          If you NT did not shut down properly, that is probably why.
          DenNinjaTrader Customer Service

          Comment


            #35
            Another doozy...

            I remember reading something regarding this topic, but I can't seem to manage to find the thread that it was in.

            Is it possible to submit both EnterLongLimit(); and ExitLongStop(); in the same "if" statement?

            I've tried it and it doesn't seem to work for me. For example, code as simple as if close price of a 15 min bar crosses the 50 SMA then buy at the low of the bar that closes above the SMA. But at the same time I want a stop in there in case the next bar opens above the buy price, hits the buy price, and then goes through the stop price in the same bar. I don't want to have to wait for the strategy to form the next bar to trigger the stop many points away from where I wanted it to execute as the price gets further and further away.

            Thanks much.

            Comment


              #36
              8DTK8,

              Due to potential race conditions that may not be viable. If you want to submit a stop loss why don't you try using SetStopLoss() tied to the particular entry signal.

              If you do not wish to use the Set() methods, you can try using OnPositionUpdate() method and submitting an ExitLongStop() immediately after you acquire a long position. This way you are not waiting for the next bar, but rather a fill on your entry order.
              Josh P.NinjaTrader Customer Service

              Comment


                #37
                I'm okay with that and I will try the OnPositionUpdate() method next.

                But first I'm having another issue. The stops that I'm placing aren't executing properly. I have taken a screen shot. The routine that marks the stop level as it moves are the yellow and green arrows. The yellow arrows are the value that the initial ExitLongStop(); are (just an extra line of code in the routine) and the green arrows are the value that the trailing stop gets raised to as a position moves in the favor of the long.

                The trailing stops are working fantastic. Is there any reason why the trades in yellow highlighted boxes have price action below the yellow arrows where the stops should have triggered.

                It's hit and miss. As can be seen in the green boxes, sometimes it works). I have a feeling it has something to do with the fact that every time the price action of the bar that the orignial buy is on exceeds the stop value to the downside, some glich makes the rest of the initial (yellow) arrow stops not work correctly.

                Any suggestions?

                Thank you again in advance.

                Originally posted by NinjaTrader_Josh View Post
                8DTK8,

                Due to potential race conditions that may not be viable. If you want to submit a stop loss why don't you try using SetStopLoss() tied to the particular entry signal.

                If you do not wish to use the Set() methods, you can try using OnPositionUpdate() method and submitting an ExitLongStop() immediately after you acquire a long position. This way you are not waiting for the next bar, but rather a fill on your entry order.
                Attached Files

                Comment


                  #38
                  Update regarding post below.

                  I know it's rather ridiculous to pat oneself on the back for finding another clue, but right now, it's all that I have.

                  Regarding my post below - it seems that whenever the bar that the open long position gets executed on has a low that exceeds the point at which the initial stop should have been placed, the system voids all ExitLongStop() orders until the close of the bar exceeds the the original stop point (yellow arrows). When a bar finally does exceed the stop point, the order is reinstated and either stopped out on the next bar if it is hit, or the trade keeps going if the price action of the following bar is all above the stop point.

                  I have gone and tested this in multiple time frames (it's a one time frame strategy.. I just changed the one timeframe) and it's the case all the time.

                  Is this a glitch, or designed to be this way? And if it is designed to be this way, is there a way around it.

                  Thank you kindly.

                  Comment


                    #39
                    Hi 8DTK8,

                    You will want to use TraceOrders = true to understand why your ExitLongStop() order is ignored at those points. Also, due to the nature of a stop order you are not guaranteed to fill at the stop price. Stop orders become market orders and as such they can be filled at any price.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #40
                      Gotcha.
                      Just tried that.
                      Here's the response that it spit out for one of the times that it was ignored.
                      ---
                      4/25/2008 6:45:00 AM Entered internal PlaceOrder() method at 4/25/2008 6:45:00 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1397.00 StopPrice=0 SignalName='' FromEntrySignal=''

                      4/25/2008 7:00:00 AM Entered internal PlaceOrder() method at 4/25/2008 7:00:00 AM: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1395.00 SignalName='' FromEntrySignal=''

                      4/25/2008 7:00:00 AM Ignored PlaceOrder() method at 4/25/2008 7:00:00 AM: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1395.00 SignalName=Sell' FromEntrySignal='' Reason='Invalid order price, please see log tab'
                      ---

                      The first is the buy, the second is the placing of the stop order, the third is the cancelling of the stop order.

                      Where is the "log tab" that it wants me to see so I can find out why it's an invalid price?

                      I'm okay with it stopping me out at market below my stop price if that's the limitation of the OnBarUpdate method of order handling. I just want to know why it won't stop me out at market when the price action is well below my stop price.

                      As always, thanks a million and I hope you are having a great Friday morning.

                      Originally posted by NinjaTrader_Josh View Post
                      Hi 8DTK8,

                      You will want to use TraceOrders = true to understand why your ExitLongStop() order is ignored at those points. Also, due to the nature of a stop order you are not guaranteed to fill at the stop price. Stop orders become market orders and as such they can be filled at any price.

                      Comment


                        #41
                        8DTK8,

                        The log tab will be in the Control Center. An "invalid order price" can occur if you submit a stop loss order at a price above the current market price.

                        Stopping you out at market is not a limitation of OnBarUpdate(). It is the nature of stop orders. Stop orders are converted into market orders once the price action crosses the stop price. This is what happens at your broker/exchange.

                        If you are well below your stop price and your stop order was not triggered it may be related to your stop being ignored to begin with. You may not have even had a stop order in play at that point in time.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #42
                          Just tried OnPositionUpdate() and it worked brilliantly.

                          As I look at the TraceOrders output, I see the following.

                          ---
                          8/6/2008 10:45:00 AM Entered internal PlaceOrder() method at 8/6/2008 10:45:00 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1283.25 StopPrice=0 SignalName='' FromEntrySignal=''

                          8/6/2008 10:45:00 AM Amended open order: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1283.25 StopPrice=0 SignalName=Buy' FromEntrySignal=''

                          8/6/2008 10:45:00 AM Entered internal PlaceOrder() method at 8/6/2008 10:45:00 AM: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1281.25 SignalName='' FromEntrySignal=''

                          ---

                          This is the print out of what it looks like to be stopped out on the same bar that the entry took place on which is exactly what I want.

                          2 questions:

                          1) How long does the order that I placed in OnPositionUpdate() last for?

                          2) Why is Quantity=0 in the third section of the read out "0"? (it works & stops me out properly, I'm just curious)

                          My gratitude for all of your help keeps piling up,

                          DK


                          Originally posted by NinjaTrader_Josh View Post
                          8DTK8,

                          Due to potential race conditions that may not be viable. If you want to submit a stop loss why don't you try using SetStopLoss() tied to the particular entry signal.

                          If you do not wish to use the Set() methods, you can try using OnPositionUpdate() method and submitting an ExitLongStop() immediately after you acquire a long position. This way you are not waiting for the next bar, but rather a fill on your entry order.

                          Comment


                            #43
                            1) It lasts until the next OnBarUpdate() unless you renew it in OnBarUpdate() or if you used liveUntilCancelled = true.

                            2) Maybe race conditions depending on how you submitted your order.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #44
                              First question of the day.

                              I'm going to keep it easy and dumb to everyone else but me.

                              How do you call the simulated account value in a backtest?
                              For example, I want to print the account value to the output after a trade gets closed and the account goes flat.

                              Print(???);

                              It would also be useful to know this for position sizing based on current account size.

                              Thank you & happy Saturday.

                              Comment


                                #45
                                Accessing account values are currently not supported however, this will be introduced in NT7 early next year. At this time, you can only access performance values related to a strategy.

                                RayNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by haas88, 03-21-2024, 02:22 AM
                                18 responses
                                207 views
                                0 likes
                                Last Post haas88
                                by haas88
                                 
                                Started by Board game geek, Today, 02:20 AM
                                0 responses
                                1 view
                                0 likes
                                Last Post Board game geek  
                                Started by knighty6508, Today, 01:20 AM
                                2 responses
                                13 views
                                0 likes
                                Last Post knighty6508  
                                Started by franatas, Today, 01:53 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post franatas  
                                Started by knighty6508, Today, 01:17 AM
                                0 responses
                                9 views
                                0 likes
                                Last Post knighty6508  
                                Working...
                                X