Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possible Bug - Point and Figure with added range chart back test goes insane?

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

    Possible Bug - Point and Figure with added range chart back test goes insane?

    I have a strategy that works fine in normal forward market operations. But when you back test it, the orders go insane. It seems as if the stop and entry values are set to the same price, which is actualy the close of the last P&F bar seen.No where near where the
    price that you set in the strategy

    So you get a gazillion order fills at each tick (because of the 1 tick range secondary chart series) and stop outs. Nothing like what you would expect. I went insane trying to see where the bug was in my code, so i finally just tried it for real
    and it worked fine. Here is the set up:

    Run the strategy as a Point and Figure with: ticks, 1 base period, 1 box , and 10 reversal

    Initialisation routine:
    SetStopLoss("Short", CalculationMode.Ticks, stop_ticks, false);
    SetProfitTarget("Short", CalculationMode.Ticks, profit_ticks);
    SetStopLoss("Long", CalculationMode.Ticks, stop_ticks, false);
    SetProfitTarget("Long", CalculationMode.Ticks, profit_ticks);
    Add(PeriodType.Range, 1); // secondary time frame
    Note: the values of ticks set set correctly.

    OnBarUpdate() routine:
    if(BarsInProgress == 0) do a strategy and set a flag to trigger something
    in the BarsInProgress == 1 time frame.

    if(BarsInProgress == 1):

    If flag from BarsInProgress == 0 was set:
    Short = EnterShortLimit(0, true, DefaultQuantity, Variable, "Short");
    or depending on the flag direction.
    Long = EnterLongLimit(0, true, DefaultQuantity, Variable, "Long");
    Note: Variable has the correct value

    Like I said, in forward test, it runs fine. Back testing the orders make no sense. Even back testing
    the variables for Variable, stop_ticks and profit_ticks - all printed out correct in the output window.
    The orders simulated by the back test are just wild. I think Ninja gets confused with P&F charts and an
    added tick secondary time frame series. I turned trace orders on and it is no help. It just confirms what I already said,
    nothing other was unusual.
    Last edited by Bluepoint; 12-20-2010, 04:38 AM.

    #2
    Hello,

    Thanks for your note.

    The SetStopLoss is it in fact getting hit? What value do you enter at and what value does the stop loss get send as this would be shown in the TraceOrders.

    Also, what is the ticksize for the stop loss, you have it set as a variable. Is this set dynamically or only once in the parameters?

    Also, please insure that you have if( CurrentBars[0] > 20 || CurrentBars[1] >20 ) check in your strategy to make sure you have enough data for both DataSeries so you dont get and strange values left over from an unstable period.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      See responses to your questions below:

      Let me know if I can be of further assistance? I am sorry but, I get the sense that bugs are the customer's problem to prove. It is your product, not mine. I am trying to help you. I have seen similar posts, scanning through the forum on this issue - multi time frame tick based charts. Is it logical that in forward test the strategy runs fine but in back test it takes an entry on every tick and stops out on the same tick? If it was bad code, would I not see the same thing the forward test too? Take a little time and investigate....run a test programme.... unless you want to hire me to be part of the Ninja Customer Support team......ok, enough steam.....

      Your answers ....

      The SetStopLoss is it in fact getting hit? What value do you enter at and what value does the stop loss get send as this would be shown in the TraceOrders.

      Yes the stop is getting hit in the back test, it was set to the same price as the price as the limit order. So yes a limit order of say EUR 131.21 and a stop of 131.21 gets hit directly. But the limit order and stops set in the strategy were no where to any where to what the trace order says. I put print statements around the executions and the prices of the stops and limit orders in the strategy and they are correct. For example Eur limit of 131.30 and a 15 tick stop are no where near EUR 131.21 and a stop of 131.21. The executions in the back test do not match between the strategy and what the trace orders of back test says. It appears to be using the closing price of the previous P&F bar and using this for the prices for both the stop and entry price of the limit order. So for each tick in painting the new P&F bar gets an this bizzare order/stop on the same tick every tick- until the P&F bar finishes. This is due to the multi-time frame addition of the 1 tick range chart as described in the original post. So where does it gets this - I think its a bug in the back test software. Remember this only happens in the back test. In regular market operations it works fine.

      Also, what is the ticksize for the stop loss, you have it set as a variable. Is this set dynamically or only once in the parameters?

      Not not set dynamically set as a fix variable (15) in the initialization.

      Also, please insure that you have if( CurrentBars[0] > 20 || CurrentBars[1] >20 ) check in your strategy to make sure you have enough data for both DataSeries so you dont get and strange values left over from an unstable period.

      Plenty of data.....

      Let me know if I can be of further assistance.

      Comment


        #4
        Blue,

        I'm hear to assist you. When there is an issue we must break it down to its core issue and run from there. I need basic information first before we can get into if there is a bug here, for example car engine wont start, we must first check gas, air, starter, battery etc before we just call the engine broke. The point here is that I cannot assume an issue is a bug until I have all facts and information that prove otherwise. As NinjaScript is a very complex vehicle and even one wrong typo could cause code to not react as you would expect it too. In either back test, or running live.

        Please insure you are using SetStopLoss() right before your entry inside of your BarInProgress check. Therefor it Set the correct stop loss based on the secondary time frame.

        If the above does not resolve the issue, If you want me to continue to further assist you I will need you to send in a copy of your code to support at ninjatrader dot com. You can take out sections that do not pertain to your strategy and intelectual property. I will then give your code a quick run on my side in the backtester to look into.

        Also, I have run tests on Backtester with PnF charts I have not run into this issue with sample code.
        BrettNinjaTrader Product Management

        Comment


          #5
          Tried what you said still does it. Anyway it works in the forward operations so it does not matter. I leave this to you to fix if you wish to investigate further......

          Comment


            #6
            Hello,

            Thanks, Attempted to reproduce on my end no luck works as expected. If you wish me to look into further please send me the strategy to causes this to occur to support at ninjatrader dot com and reference this forum post for me to look into further.

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X