Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization runs yield zero results

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

    Optimization runs yield zero results

    Greetings,

    I have a strategy using tick replay that runs fine in realtime, replay, and backtests however attempts at running single or multiple objective optimizations always result in zero results for each iteration. The parameters I'm testing are simple booleans such as whether to move stops to breakeven.

    Trade logic is in OnBarUpdate and uses the managed approach with entries looking like this:

    EnterLong(tradedInstrument,1, @orderTag);

    Where tradedInstrument is an int representing a second or third dataseries such as AddDataSeries(SecondarySeries, BarsPeriodType.Tick, 1);

    Wondering if I'm missing something obvious.

    Mark

    #2
    Hello Mark,

    Thanks for your post.

    The arguments supplied to the AddDataSeries() method in your strategy should be hardcoded into the method and not rely on variables. This information is noted on the AddDataSeries() help guide page linked below.

    From the AddDataSeries() help guide page: "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.​"

    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

    This means that you should hardcode the instrument into the AddDataSeries() method instead of passing in SecondarySeries for the AddDataSeries() instrumentName argument.

    Further, debugging prints should be added throughout the strategy to understand exactly how your logic is processing when running the optimization.

    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, you could enable TraceOrders which will let you 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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon. I realized actually that flipping the switch to "Optimization" was setting my "IsBacktest" and "AllowHistorical" properties to False which is why the strategy ran through all iterations without taking a single trade. It's also why there were absolutely no logs or prints either.

      I do appreciate the reminder about the proper usage of the AddDataSeries though which I will definitely keep i mind whenever things do not appear to be working. But for now, the last 4 months of development have thus far satisfactorily demonstrated to me that passing a series such as "CL 09-23" as a property to AddDataSeries works flawlessly.


      Best,
      Mark​

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X