Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF strategy analyzer tick by tick

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

    MTF strategy analyzer tick by tick

    Hi,

    Im trying to write a simple strategy that will look at a range chart for a signal and then enter on a 1 tick bar series and continue to monitor on the one tick bar series for the exit.
    for whatever reason this strategy doesn't take any trades. If tried various combinations of changing the secondary and primary bar series. If i run on a one tick and monitor the range it enters orders but the entries and exits occur at the exact same time which is useless. If i keep the range as primary and execute on the secondary 1 tick it wont take any trades.

    does anyone have an example of a working strategy that uses a range chart for a signal and the 1 tick as a secondary bar series to monitor the possible intrabar entry and exit?

    thanks

    #2
    floyd084, would not be aware of a specific example shared already that would cover your setup. What order methods are you using? Did you receive any errors in the log tab? Was the TraceOrders output suggesting any ignored / expired orders?

    If you like and would be willing to share we could also run your script here and let you know our thoughts.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I wanted to run it on a range chart so i can see the orders afterwards, there is some code in there that i have commented out, on one occasion if i reveresed the primary and secondary charts it would take orders but would take thousands of orders a day, when it should be taking less than 50.


      Code:
                  Add(PeriodType.Tick, 1);
                  
                  SetProfitTarget("", CalculationMode.Ticks, Target);
                  SetStopLoss("", CalculationMode.Ticks, Stop, false);
                  TraceOrders = true;
                  CalculateOnBarClose = true;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  // EnterLongLimit(0, false, DefaultQuantity, Close[0] + 0 * TickSize, "Long");
                  //EnterShortLimit(0, false, DefaultQuantity, Close[0] + 0 * TickSize, "Short");
              
                  // OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
                  // We only want to process events on our primary Bars object (index = 0) which is set when adding
                  // the strategy to a chart  BarsSinceExit(0, "", 1) > 1 || BarsSinceExit(0, "", 1) == -1
                  //if (BarsInProgress == 1)
                  //return;
                      
              
                  
                  // Condition set 1
                  if ( ToTime(Time[0]) > ToTime(9, 30, 0)
                      && ToTime(Time[0]) < ToTime(15, 48, 0)
                      && Close[0] < Open[0])
                  {
                     EnterLongLimit(1, false, DefaultQuantity, Closes[0][0] + -5 * TickSize, "Long");
                      
                  }
      
                  // Condition set 2
                  if ( ToTime(Time[0]) > ToTime(9, 30, 0)
                      && ToTime(Time[0]) < ToTime(15, 48, 0)
                      && Close[0] > Open[0])
                  {
                    EnterShortLimit(1, false, DefaultQuantity, Closes[0][0] + 5 * TickSize, "Short");

      Comment


        #4
        So i noticed that when i change the entry order duration to from false to true, it begins to place orders, yet the exits for those orders all occur at the close time of the range bar and not on the secondary chart series. It seems i need to set a canle order command that will trigger when the primary series closes the current bar the order was placed in.

        Comment


          #5
          Hi Floyd,

          What do you expect the strategy to do and what is occurring?

          Can you take a screenshot and attach it to show?

          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 to your post, Click Reply, Go advanced and click the paperclip on the top toolbar to add an attachment.

          For detailed instructions please visit the following link

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

          Comment


            #6
            So its my understanding that strategy analyzer doesn't analyze tick by tick. To bypass this i want to force it to by using tick granularity. the strategy monitors the primary bar series for an entry (in this case the close of a 10 range chart) then it will place an order on the secondary bar series ( 1 tick). so now I should have an order resting on a 1 tick chart waiting to get filled. If it gets filled the 1 tick chart will determine if my stop or target is hit and at the correct time, not the strategy analyzers OHLC for the 10 range. This way I can see the actual outcome of trades. Additionally if the order on the 1 tick is not filled within the 10 range bar that triggered the entry then it should cancel the order.

            looking at the screen shots here:
            the last two trades that occurred show their exit times being equal to the close of the bar but clearly the close of the bar is not the same price as the exit price, this is the downside of strategy analyzer that i am trying to overcome.
            Attached Files

            Comment


              #7
              Floyd,

              From the picture you provided your trades are hitting their profit targets which seems to be occurring on the same bar.

              I'm not sure what you expect here but this is to be expected with profit targets and stoploss's.

              When you get filled from an order the Profit Target and Stop Loss are then placed. In which case can be filled on the same bar.

              What are the profit target and stop loss being set to? According to the Chart picture, it looks to be 5 ticks.

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

              Comment


                #8
                these results are from the strategy analyzer, not a replay. I'm not worried about the targets being hit or not. What I'm worried about is the time at which they are hit. Lets look at the last trade:
                profit target 5 ticks, stop of 9.
                entry 1616.25 on 5/7/2013 at 10:39:23 AM <- the time is correct because that's the actual time it would have filled if i were trading live and nothing else changed

                now the exit:

                exit 1615.00 on 5/7/2013 at 11:10:16 AM <- I can guarantee it did not fill at this time at a price of 1615.00. how do I know this? Because 11:10:16 is the time associated with the close of the bar and at the close of that particular bar the market was trading about 2 points higher. using the same example its 11:10:16 AM and the market is trading at 1617.25 and i get filled at 1615.00 at that same time. now there could be a fluke that the market was really thin at that time and managed to trade down to 1615.00 and then back to 1617.25 within one second. but after reviewing all the trades that is not the case. We both know why its doing this, the strategy analyzer doesn't analyze tick by tick. It uses the OHLC of any particular bar to determine fills. If my stop and target are within the price range of the entry bar the strategy analyzer assumes I got fills on price alone, because the strategy analyzer completely ignores order of events. Which is why im trying to code this work around. I really hope this makes sense.

                Comment


                  #9
                  Hi Floyd,

                  You have stated that -
                  Code:
                  if ( ToTime(Time[0]) > ToTime(9, 30, 0)
                                  && ToTime(Time[0]) < ToTime(15, 48, 0)
                                  && Close[0] < Open[0])
                  Be aware of that, Close[0] and Open[0] will reference which bar is in progress against both data series that you have, Range and Tick, on a multi-timeframe strategy.

                  I may want to try using Closes[0][0] and Open[0][0], that way you are always referencing your primary(Range) data series.
                  Last edited by NinjaTrader_CalH; 07-03-2013, 01:32 PM.
                  Cal H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Aviram Y, Today, 05:29 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post Aviram Y  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by ScottWalsh, 04-16-2024, 04:29 PM
                  7 responses
                  34 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cls71, Today, 04:45 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post cls71
                  by cls71
                   
                  Started by mjairg, 07-20-2023, 11:57 PM
                  3 responses
                  218 views
                  1 like
                  Last Post PaulMohn  
                  Working...
                  X