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

Entry Freak out

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

    Entry Freak out

    I've been using the playback feature to make sure my algorithm is working properly. Some Market Opens on a given day will absolutely panic and try and open as many positions as the algorithm allows for and then some. It seems to update on each tick.
    Click image for larger version

Name:	image.png
Views:	49
Size:	48.0 KB
ID:	1282127

    NS Output goes crazy and starts spamming:
    Click image for larger version

Name:	image.png
Views:	43
Size:	285.5 KB
ID:	1282128

    The Freak out will deduct the fees if your testing is set up for it.
    All in all it's extremely obnoxious. I never told it to continue to put in orders. For all I know I have 1 order per signal turned on, but I can't seem to find anything to stop this from happening. What is it and why does this happen? Then how do we make it not happen anymore?

    #2
    Hello alphatango,

    Thanks for your post.

    The conditions to place the orders are likely becoming true and if your strategy is running with Calculate.OnEachTick then the order would be placed for each incoming tick if the condition is true.

    Ensure that you are not using both Set methods (SetProfitTarget/SetStopLoss) and Exit methods (ExitLongLimit/ExitLongStopLimit) in your script.

    In your condition to place an entry order you could create a condition that checks if you are in a flat position (Position.MarketPosition == MarketPosition.Flat), that way orders are only submitted when you are in a flat position.

    Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm

    To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).​

    Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your quick reply BrandonH. It's exasperating and would love to get this resolved.

      You asked Conditions likely becoming true.
      I do indeed have a Flat check on there with exactly what you posted. Most of the time it works. If there is an Open (unfilled) order, will this continue to show Flat = true? That is how it has worked in the past.

      I also have a Start and End time to limit me to RTH. If I set Playback to 08:29:00 AM CST (1 min before Markets open) it will give me a "order submitted" response but error and not actually show and Output will give me an error.

      Print Script for my timeframe shows it cycling True, False, True True, error, True, False, True, True seemingly with every tick.

      Sometimes it works perfectly well. Sometimes it just freaks out like this. Would love to know why.



      It also started giving me this error:

      Click image for larger version

Name:	image.png
Views:	46
Size:	12.2 KB
ID:	1282138

      Playback appears to be playing back normally after I close this.

      Comment


        #4
        Hello alphatango,

        Thanks for your notes.

        Without debugging and thoroughly testing the code I cannot say for certain what is causing the behavior when running the script.

        To understand how it is behaving you would need to debug and test the strategy to understand how your logic is behaving. This is done by reducing code and adding prints to understand how your strategy logic is evaluating.

        If your strategy is printing too much information to the Output window, you could write the debugging prints to a file using a StreamWriter and view the prints in that file.

        StreamWriter: https://ninjatrader.com/support/help...o_write_to.htm

        Note that we do not provide debugging services in our support so it would be up to you to debug the script's logic to understand how it is behaving and placing orders.

        If you need assistance reviewing the debugging prints output then you should share the Output with us and we would be happy to assist. When the output from the Output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        The error message in the screenshot you shared indicates that you may not have data downloaded for the date you are testing over.

        You may want to check the data that has been downloaded. In the Historical Data window you could view the data downloaded for each instrument (Historical/Playback).

        I suggest that you refer to this tab to see which days have been downloaded already, then set your dates in the 'Playback' window to match what is available.

        Market Replay data can be downloaded from our servers, without connecting to another data provider, however you do have to specify the instrument for the download, and download each day you intend to use for playback.​​
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,788 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        835 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,291 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        11 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        62 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X