Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bugs Report 1

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

    Bugs Report 1

    Hello,

    I'm testing my strategy via Ninjatrader and only using market replay for tests. Sory i can't share my strategy source code here but still I'll try to explain ploblems because i'm fan of this platform.

    My strategy source code draft below, i don't share entry/exit rules but you can think these are only true/false flags.

    protected override void OnBarUpdate()
    {
    if (Position.MarketPosition == MarketPosition.Long)
    {
    if (Long entry exit conditions are met or there is short entry signal)
    {
    //try exit via SetProfitTarget a few ticks later
    SetProfitTarget("Entry", CalculationMode.Price, Close[0] + OrderPlusTicks * TickSize);
    }
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    if (Long entry conditions are met)
    {
    //I'm setting large profit target via SetProfitTarget first(yes i know i can do this once in initialize)
    //try enter via EnterLongLimit a few ticks later
    EnterLongLimit(OrderQuantity, Close[0] - OrderPlusTicks * TickSize, "Entry");
    }
    }
    }

    Notes:
    *Above strategy name is MomentumBullStrategy and i write second strategy that name is MomentumBearStrategy for short. Why? because of for simplicity. Ahead i'll combine this two strategy and the result will be the same.
    *Strategy initialize contain CalculateOnBarClose = true and ExitOnClose = false;
    *I'm testing this strategy ES 2 min chart, i added two strategy same ES 2 min chart and examine results from account performance tab.

    Then i changed my code like below-------------------------------------------------------------

    protected override void OnBarUpdate()
    {
    int barOffset = Historical || CalculateOnBarClose ? 0 : 1;

    if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Long)
    {
    if (Long entry exit conditions are met or there is short entry signal)
    {
    //try exit via SetProfitTarget a few ticks later
    SetProfitTarget("Entry", CalculationMode.Price, Close[barOffset] + OrderPlusTicks * TickSize);
    }
    if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Flat)
    {
    if (Long entry conditions are met)
    {
    //I'm setting large profit target via SetProfitTarget first(yes i know i can do this once in initialize)
    //try enter via EnterLongLimit a few ticks later
    EnterLongLimit(OrderQuantity, Close[barOffset] - OrderPlusTicks * TickSize, "Entry");
    }
    }
    }

    Notes:
    *I do same changes for MomentumBearStrategy.
    *When query entry/exit conditions i'm using barOffset too.
    *Strategy initialize contain CalculateOnBarClose = false and ExitOnClose = false;
    *I'm testing this strategy ES 2 min chart, i added two strategy same ES 2 min chart and examine results from account performance tab. Absolutely other all testing conditions are same; strategy parameters, time frame, instrument etc.
    *Why change this code like this? because of i'll try to after X ticks profit later i set stop loss to breakeven and i want to do this check tick by tick.
    * I save performance report, trades and daily period results for both test.
    *I have from 2013-06-11 to 30-07-30 market replay data. this is 44 day market data.

    Final----------------------------------------------------------------------------------------------------

    Results (performans values, order times and types, position entry and exit times, profits, losts etc. are same for 42 days but 2 days a little different. For example one day there is additional one position. Think about it, 44 days 2 min market replay only 2 days diff for both test and only 2 position additionaly. I don't think so i do any error. There is no day specific code, there is no complex strategy, there is no diff parameters etc. I want to repeat again both test result until all the details are same but only 2 day, one each additional only one position.

    Final Final

    There is no problem for me and for my test because of only 2 addional two position at short time frame. This would not pervert my goal. But i like ninjatrader and i want to help for better product. Also i worry about there is a way send private post that only ninjatrader team see post in this forum?

    Sory for long post, have a nice day.
    Last edited by aytacasan; 08-02-2013, 06:41 AM.

    #2
    Hello aytacasan,

    Are you moving the slider or using the "Go To" option to go through the 44 days worth of data quickly?
    JCNinjaTrader Customer Service

    Comment


      #3
      Hello,

      No i don't do these actions. Simply before new test i always closing and opening market replay connection (maybe this is not necessary but i'm doing). Then open ES 2 min chart and add bull and bear strategies on it. Lastly i'm clicking run button market replay control panel and clicking speed button again and again until see 500X test speed. Then i'm waitng to finish test almost 3 hours.

      Comment


        #4
        Hello aytacasan,

        I would start narrowing down your test period to 1 day, and then use the Print() method to check all of the values to make sure they are what you expect them to be.



        It maybe that barOffset is not getting the results that want, but making sure that the values you are getting are correct for a single day will let you know if the strategy is processing the logic that you would like.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi,

          Thanks for your interest. I have 15+ years experiance about software development. Only 5 years about developing indicator/strategies and only 2-3 years about ninjatrader. Still if i don't read before then i read artical at that link. Also thanks for that link. I'm ready to do help, If there's anything to do.

          Strictly speaking, after realize the problem i don't try to debug my strategy because i don't need. I mean, my opinion is that if there is my fault so we see more days have problem not only 2 days in 44 days. Forget days, in 44 days period there is 924 trades and only 2 trades different. Other 922 trades exactly same entry/exit time(on the tick), profit/loss etc before change my strategy from "run on close" to "run tick by tick".What is more interesting, this errors not end of test, i mean;

          11.06.2013-16.06.2013 range is right
          17.06.2013 there is additional entry
          18.06.2013-30.06.2013 range is right
          01.07.2013 one order exit bar is different
          02.07.2013-30.07.2013 range is right

          I can't provide my strategy source code because of commercial purposes so I'll try to find what is wrong. If i find anything that usefull i'll inform you.

          Good luck.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          368 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          571 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X