Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Wrong Execution Price

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

    Wrong Execution Price

    This is a similar issue as discussed in http://www.ninjatrader.com/support/f...p/t-49136.html

    however, the solution proposed doesn't solve the problem!

    ------------------------------------------------------------------------------------------------------------
    I am running EnterLongLimit() which sometimes enters a position where the price isn't right ! the ticker simply doesn't reach the limit-price, but the position is filled nonetheless.

    At first i thought this was a problem with my data provider, so I've resorted to using the sample data from BackTestData.com. Sample data can be downloaded from


    This yielded the same result. The position is filled at a price much higher than the actual price shown in chart-data. This is also shown in the attached screenshot where the order is executed much higher than the graph itself.

    I've also attached the code which is very straight forward.
    First import the data in the zip file, then run the Backtest on the ticker at 5 minutes bars, on 12/23/2012.

    Note that running the Liberal Fill-Type as suggested in the above thread, enters the position at a price on the graph, but it is well BELOW the requested limit.
    Attached Files

    #2
    Micronezia,

    Thank you for posting and welcome to the Forums!

    I took a look at your code and can see that you have set the limit price of the EnterLongLimit to 1433.
    Since, this is a hard value inside the code it will buy limit orders at 1433.

    Per order definitions, a limit order will try to fill you in at the limit price or better. Since the market is well below that, it gets automatically filled at the price you specified - 1433.

    Where are you wanting to place the trade at?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Ohh sorry about that,
      I meant to issue a stop-order but issued a limit order instead..

      Comment


        #4
        How to avoid the case where the entry and exit are obtained in one bar? Is it possible to execute the Stop Loss by set price and not by close of the bar?
        Click image for larger version

Name:	Enter_Exit_one_Bar.PNG
Views:	1
Size:	10.5 KB
ID:	869185

        Comment


          #5
          Hi Alexstox,

          Thank you for posting.

          You can set the StopLoss to have a price calculation instead of a tick or percentage with the following example -

          SetStopLoss(CalculationMode.Price, 1705.00);

          This will set my a stop loss at the 1705.00 price.
          http://www.ninjatrader.com/support/h...etstoploss.htm

          Additionally, if you want to have it set that you exit on the next bar and not the same bar as you have set up, you can use an Exit Order instead of the Stop Loss and use BarsSinceEntry() to determine how long you want to wait for the bars to be completed before exiting.
          http://www.ninjatrader.com/support/h...sinceentry.htm

          Let me know if I can be of further assistance.
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            1. Unfortunately Price or Ticks methods generates wrong exits. I just can't understand why?

            2. Do you mean ExitShort, ExitLong?

            Comment


              #7
              Alexstox,

              1. Unfortunately Price or Ticks methods generates wrong exits.
              Can you explain a little further by what you mean "generates wrong exits"?

              2. Do you mean ExitShort, ExitLong?
              Correct, I was referring to the Exit methods.
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                I mean in both cases (Price or Ticks) there are some abnormal Stop Loss exits, that differ from strategy rules.

                Comment


                  #9
                  Alexstox,

                  The Price calculation will be an absolute price that would be set, while ticks would be the number of ticks that the stop loss or profit target will be placed at.
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10
                    1/ Well. As I wrote earlier, in both cases (Price or Ticks) sometimes Stop Order price does not match the price of the SetStop rule in strategy. For some reason price executed on Open, if the stop loss is triggered on the entry day.
                    2/ How can I set strategy to trigger protective TrailStop=5 ticks if price back to Entry price, and TrailStop=50pp if price go in right direction?

                    Comment


                      #11
                      Alexstox,

                      You can have your code dynamically change your SetTrailStop to a new value for trailing your market.
                      Take a look at this reference sample on Modifying for your StopLoss and Profit Target to get an idea -
                      http://www.ninjatrader.com/support/f...ead.php?t=3222

                      Is the price mismatch in realtime or back test?

                      Can you provide a screenshot of what you are seeing?

                      To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and attach the file by clicking Go Advanced and then the paperclip in the top toolbar

                      For detailed instructions please visit the following link

                      http://take-a-screenshot.org/
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Trail Stop via NT script. liveUntilCancelled. CancelOrder()

                        1. Unfortunately didn't find there how to implement me needs. Because I need protective stop and trail stop and stop loss =). How to write Trail Stop by using NT script?
                        2. If I try to use liveUntilCancelled, there is no way except CancelOrder() to cancel existing order?
                        Is there any opportunity except liveUntilCancelled to continue Stop Long order?
                        3. How to cancel existing order via some rules in script?

                        Comment


                          #13
                          Trade # . Set ProfitLoss manually.

                          3. How to show "Trade #" on the chart in Strategy Analyzer along with enter quantity and price, that are shown.
                          4. How to set Profit or Loss "manually" for some cases in Strategy Analyzer? For example, if it's impossible to execute because of "CalculateOnBarClose" for Strategy Analyzer on historical data.

                          Comment


                            #14
                            SetTrailStop

                            5. SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
                            If simulated is true - this order will trigger as Stop market order. What if false?

                            Comment


                              #15
                              Alexstox,

                              1) SetTrailStop() will allow you to have a trailing stop order.
                              SetTrailStop()

                              2)Correct, you will need to use CancelOrder()

                              3)You can use conditions to tell your script when you would want to cancel your orders if they have not been filled.

                              4)Using Performance.AllTrades.Count will get the total number of trades the strategy took. You can then use DrawFixedText to print out the Number of contracts that the strategy took on the chart
                              AllTrades

                              5)You can set the value of the StopLoss and Profit Target using User Defined Parameters.
                              Creating User Defined Inputs

                              6)StopLoss orders are submitted as Stop Limit Orders, if set to false it will remain a Stop Limit.
                              Cal H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FishTrade, 05-13-2024, 11:11 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post FishTrade  
                              Started by Graci117, Yesterday, 09:02 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by ETFVoyageur, Yesterday, 07:55 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post ETFVoyageur  
                              Started by janio973, Yesterday, 07:24 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by aligator, 01-06-2022, 12:14 PM
                              4 responses
                              252 views
                              0 likes
                              Last Post john_44573  
                              Working...
                              X