Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intrabar Granularity for Profit Targets

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

    Intrabar Granularity for Profit Targets

    Hi there,

    I am working on strategy development with a rather limited knowledge of #C. I have been successful in adding a secondary 1-tick data series as shown in the sample intrabar granularity example thats posted to the forums. However, this example does not make it clear how to get intrabar granularity for profit targets. My backtests show exact price level fills on entries (I use the EnterLong(1, 1, "entry signal") but my exits are always calculated 1 bar later. Backtest exits at the correct price but if the next bar does not hit target, when the previous bar (entry) did, then it will not register as hitting my profit target. My strategy often has entry and profit targets hit on the same bar so it is important that I get this working for generating accurate backtests.

    Profit Targets are set:
    Code:
    else if (State == State.Configure)
                {
                    //Hardcode secondary data series (tick) in order to backtest with intrabar granularity
                    AddDataSeries(BarsPeriodType.Tick, 1);
                    
                    //Set Profit Targets and Stop losses
                    SetProfitTarget("Long Entry", CalculationMode.Ticks, 36);
                    SetProfitTarget("Short Entry", CalculationMode.Ticks, 22);
                    SetStopLoss(CalculationMode.Ticks, 44);
                }​
    Entry Logic:
    Code:
    if (session_check)
                {
                    if (take_trade && IBThreshold)
                    {
                        if (CrossAbove(Close, IBHigh, 1))
                        EnterLong(1, 1, "Long Entry");
                    
                        if (CrossBelow(Close, IBLow, 1))
                        EnterShort(1, 1, "Short Entry");    
                    }
                }
                else
                {
                    ExitLong("Long Entry");
                    ExitShort("Short Entry");
                }​
    I believe this has to do with the profit target being set on the next bar update iteration. How can we get the set profit target to update within the secondary data series.

    Thanks!​

    #2
    Hello asposito,

    For profit targets using Set methods that would not be possible in manual coding, you would have to change to using ExitLongLimit or ExitLongStopMarket as an example. If you want to use the set methods you can also remove the secondary series and just use the standard fill resolution setting while backtesting, that places he orders on a secondary series in the same way that you are doing now without having to code it.
    JesseNinjaTrader Customer Service

    Comment


      #3
      If you want to use the set methods you can also remove the secondary series and just use the standard fill resolution setting while backtesting, that places he orders on a secondary series in the same way that you are doing now without having to code it.
      I am not sure I understand. If I remove the secondary series (tick) and use standard resolution and set profit target methods.. I will I get filled intrabar, or will I only getting filled at the OHLC of the next bar?

      Comment


        #4
        Hello asposito,

        If you remove the series and instead use high order fill resolution with a more granular series, that will let you apply it to the set methods as well. In manual coding, you need to specify the BarsInProgress to the order method in order to use a more granular series for filling, which the set methods do not have.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Got it. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Armin, Today, 02:26 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Nancy75, Today, 10:22 AM
          0 responses
          4 views
          0 likes
          Last Post Nancy75
          by Nancy75
           
          Started by xiinteractive, 08-08-2023, 11:55 AM
          44 responses
          887 views
          3 likes
          Last Post bltdavid  
          Started by Thomas75k, 11-29-2024, 02:11 AM
          7 responses
          76 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by nelslynn, Today, 09:34 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X