Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

mtf strategy + no primary serie condition = all plots should sync

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

    #16
    Hi Roland,

    yes EoD.
    if the calculation is once every bar and the 2nd serie not processed, then an OnBarUpdate would take the trade. 900 took it OnBarUpdate. Price was already too low for 300.
    a BarSinceExit +Something would do the trick on the 900. It probably would need to be added on the 300 too because each is processed separately.

    this is only for visual effect..
    All this would work just fine under Live Data condition and trigger on the primary OnBarClose. Wether primary is 900 or 150 ? right ?

    Comment


      #17
      Hello Amedeus,

      NT-Roland is completely correct and has inquired if you are placing orders during specific BarsInProgress.


      To address some questions first:

      To confirm NT-Roland, unfortunately, 1-tick granularity cannot be implemented in the Strategy Builder. The Strategy Builder is limited with order placement and orders cannot be placed to a secondary series and can only be placed to the primary series. This would require unlocking the script.

      If Calculate is set to OnBarClose, then TickReplay is not necessary and Order fill resolution set to High can be used with scripts using the Strategy Builder (Default properties page as well) to implement the intra-bar granularity. (See the link in post# 11 about intra-bar granularity for more on Order fill resolution and a link to the help guide)

      However, if this script is being created with the Strategy Builder, this would mean that the orders would be placed at different times on charts with different primary data series if the Calculate setting is OnBarClose. The orders can only be submitted when the primary bars are closing and the primary bars are closing at different times.

      To use different primary data series and evaluate logic and trigger actions on a secondary added series, it is required to unlocked the script and code by hand. The Strategy Builder cannot trigger logic when secondary series are updating. It can only use data from them and only when the primary is updating.


      BarsRequiredToTrade is not available in the Strategy Builder. Using this would require unlocking the script. But you can add to the condition to require CurrentBar to be greater than a manually set number like 20.


      In an unlocked script, you are submitting orders during BarsInProgress 1, to BarsInProgress 1, is this correct? Or are you adding a 1 tick series just to use for accurate bar fills, and placing the orders during a different bars update?
      For example:
      The chart bars are 300 tick and 900 tick on different charts. The first AddDataSeries() adds a 1 tick series for fills and is BarsInProgress 1. The second AddDataSeries() adds a 5 minute series and this is used for the logic and is BarsInProgress 2. The conditions are checked when BarsInProgress is 2 every 5 minutes, and when true, places an order to BarsInProgress 1 for fills. BarsInProgress 2 is the same for both charts so the orders get submitted at the same time every 5 minutes even though the charts have different primary series. The orders fill at the same time because they are submitted to the 1 tick series for high accurcacy fill prices.


      We are wanting to confirm that BarsInProgress 1 (the first secondary series added), is the same for both charts running with the same start and end bar, and same values in the condition (such as the same indicator values if an indicator is being called), and that the order is being submitted at the exact same time.


      May I confirm, is this real-time or historical data?

      What is the condition that submits the order?

      Print just above that condition.

      The Time[0], BarsInProgress, and all values used in the condition (meaning all variables or hardcoded values in the condition).

      It looks like you've got a start:
      TimeCurrentBarDefault> 17/05/2021 15:41:48 TimeCurrentBarDefault-1> 17/05/2021 15:41:38 TimeCurrentBar300> 17/05/2021 15:41:48 TimeCurrentBar300-1> 17/05/2021 15:41:38

      A bit of encouragement:
      Code:
      Print(string.Format("{0} | BarsInProgress: {1}, {2} {3} {4}", Time[0], BarsInProgress, Instrument.FullName, BarsPeriod.Value, BarsPeriod.BarsPeriodType));
      This would tell us the time of the bar updating, and which series is updating, and the name and bar size of that series and would confirm each script is processing the same amount of data.

      From there add to the print the condition values (like indicators if the conditions calls indicators).
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hey Chelsea and Roland, thanks,

        Yes the order is submitted on the first secondary series.

        In an unlocked script, you are submitting orders during BarsInProgress 1, to BarsInProgress 1, is this correct?
        I do not think so after all. The exits are simple stops, which I gess now means : the exits are on the primary anways. But the Entries are all on the BarsInProgress1.

        The script was entirely made in the builder. The only manual intervention was for this formula
        Code:
         if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
        return;
        if (BarsInProgress == 0)
        if (BarsInProgress == 1)
        I may try the one tick secondary series just later but not yet.
        CurrentBars<1 is just a way to make sure the calculation goes through every bar of every series, is this correct ?

        May I confirm, is this real-time or historical data?
        It is real Time according to the Output message about the enabling :
        Code:
        Enabling NinjaScript strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341' : [U]On starting a real-time strategy[/U] - StartBehavior=WaitUntilFlat EntryHandling=Unique entries EntriesPerDirection=1 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 300 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
        I just saw from the Historical vs Real time page, that yesterday's data could already be historical if we have any other chart that is open with the same instrument since a while, Wich i do, with a good amount of data in it.
        I guess that it matters when searching through the output : attached is what the output looks like when searching chronologically for "13/05/21 21:13:26" with 2 same strategies applied.

        What is the condition that submits the order?
        Print just above that condition.
        From there add to the print the condition values (like indicators if the conditions calls indicators)
        The condition set is after 2 bools... and the HLC detail of the entry is on the 1rst layer of bools. It is all on 2ndary and 3ry series (300 and 900)

        The Prints :
        First our example is actually not with only 1 secondary like mentionned earlier but with 3. But all conditions are on the 1st and 2nd secondary series only (no primary, no 3rd)
        Also our previous example is not the same but i found another similar example, provided in the attachments.
        because of the unreadable output with 2 strategies, we will apply them one after the other and pick everything that is printed under the timestamp, with 1 or 2 bars before and after.
        I underlign what looks to be what we are looking for, please correct if wrong.
        *** in the next post due to the limitation of characters***

        Comment


          #19
          Code:
          1rst trade Under primary 900 calculation :
          [U]13/05/2021 21:06:15 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Entered internal[/U] SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:15 | BarsInProgress: 3, MES 06-21 4200 Tick
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=3 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=3 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:31 | BarsInProgress: 0, MES 06-21 900 Tick
          13/05/2021 21:06:31 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:31 | BarsInProgress: 2, MES 06-21 900 Tick
          13/05/2021 21:06:42 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:07:00 | BarsInProgress: 1, MES 06-21 300 Tick
          
          2nd trade under primary 900 calculation
          [U]13/05/2021 21:12:56 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:12:56 [/U]Strat[U]egy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Entered internal [/U]SubmitOrderManaged() method at 13/05/2021 21:12:56: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4118,25 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:13:11 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:26 | BarsInProgress: 0, MES 06-21 900 Tick
          13/05/2021 21:13:26 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:26 | BarsInProgress: 2, MES 06-21 900 Tick
          13/05/2021 21:13:26 | BarsInProgress: 3, MES 06-21 4200 Tick
          13/05/2021 21:13:26 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342: Cancelled pending exit order, since associated position is closed, orderId='NT-00144-808' account='Sim101' name='Profit target' orderState=Working instrument='MES 06-21' orderAction=Sell orderType='Limit' limitPrice=4122 stopPrice=0 quantity=1 tif=Day oco='NT-00030-808' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2021-05-13 21:12:38' gtd='2099-12-01' statementDate='2021-05-26'
          13/05/2021 21:13:26 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108342': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00144-808' account='Sim101' name='Profit target' orderState=Cancelled instrument='MES 06-21' orderAction=Sell orderType='Limit' limitPrice=4122 stopPrice=0 quantity=1 tif=Day oco='NT-00030-808' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2021-05-13 21:12:38' gtd='2099-12-01' statementDate='2021-05-26'
          13/05/2021 21:13:36 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:43 | BarsInProgress: 1, MES 06-21 300 Tick
          
          
          1rst trade Under primary 300 calculation :
          [U]13/05/2021 21:06:15 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Entered internal [/U]SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:15 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:15 | BarsInProgress: 3, MES 06-21 4200 Tick
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=3 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:15 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:15: BarsInProgress=3 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:31 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:06:31 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:31 | BarsInProgress: 2, MES 06-21 900 Tick
          13/05/2021 21:06:42 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:06:42 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Entered internal SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='' FromEntrySignal=''
          13/05/2021 21:06:42 Strategy 'aaaaaaaaNTForumMTFStrategyExampleUnlocked2/232108341': Ignored SubmitOrderManaged() method at 13/05/2021 21:06:42: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=4117,75 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          13/05/2021 21:07:00 | BarsInProgress: 0, MES 06-21 300 Tick
          
          2nd trade under primary 300 calculation : nowhere to see
          13/05/2021 21:13:11 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:13:11 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:26 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:13:26 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:26 | BarsInProgress: 2, MES 06-21 900 Tick
          13/05/2021 21:13:26 | BarsInProgress: 3, MES 06-21 4200 Tick
          13/05/2021 21:13:36 | BarsInProgress: 0, MES 06-21 300 Tick
          13/05/2021 21:13:36 | BarsInProgress: 1, MES 06-21 300 Tick
          13/05/2021 21:13:43 | BarsInProgress: 0, MES 06-21 300 Tick
          Attached Files

          Comment


            #20
            Hello Amedeus,

            If the script was made in the builder, it not triggering logic on the secondary series and placing orders to the 1 tick series.

            I would recommend you change the logic to operate on the added series whichever BarsInProgress that may be and the orders be placed to the 1 tick series.

            See post# 11 for a link on how to implement intra-bar granularity.


            Every time you enable a script, it processes historical data before real-time data.


            The State property tells if you historical or real-time data is being processed.


            Historical data is processed differently than real-time data and involves intra-bar granularity and TickReplay. See post# 11 for a link to a forum post on historical data and intra-bar granularity.

            Below I am providing a link to a forum post with helpful information on getting started with NinjaScript and C#.
            Last edited by NinjaTrader_ChelseaB; 05-26-2021, 07:58 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Hi Chelsea, thanks

              If the script was made in the builder, it not triggering logic on the secondary series and placing orders *to the 1 tick series*(or to the 1st secondary 300...?)
              In the 1rst picture we can see 2 live sim order from the strategies. Since orders are only showing on the 300, I conclude the strategy submits the orders on the 1st secondary (300).
              Is that a wrong conclusion ?
              In the builder it is possible to set the LongLimit order on the secondary. Here is the syntax of the order itself produced by the builder (I do not recall having added the -1 after aaaKCOB which should correspond to the 1st secondary, if i followed correctly)
              EnterLongLimit(Convert.ToInt32(DefaultQuantity), aaaKCOB1.Midline[0], "");

              I would recommend you change the logic to operate on the added series whichever BarsInProgress that may be and the orders be placed to the 1 tick series.
              It was made in the builder but the recent examples are from the unlocked script with the BarsInProgress syntax from last post.
              Is this not precisely changing the logic to secondaries ?

              what am I missing ?

              Should we precise in the script wether we want it to calculate if State == State.Historical, or State.Realtime ? Is that it ?
              and like... switch to one another manually every time we either backtest it or apply it on live data ?
              Attached Files
              Last edited by Amedeus; 05-26-2021, 10:07 AM.

              Comment


                #22
                Hello Amedeus,

                The orders need to be submitted to the barsInProgressIndex of the 1 tick series. Which BarsInProgress is the tick series?
                EnterLong(int barsInProgressIndex, int quantity, string signalName)

                Do you have output from both charts showing that BarsInProgress 2, the series you are using to trigger logic, is the same in both scripts?

                Is the logic to submit the order within a condition where BarsInProgress is 2?

                For the orders to be submitted at the exact same time, the data has to be the same (or on a 1 tick series the orders would be placed at the time of a specific tick). So we want to see that BarsInProgress 2 matches between each script.

                Below is a link on using prints to understand behavior and includes videos for you to watch.
                https://ninjatrader.com/support/foru...121#post791121

                The output is saved to text file by right-clicking the output window and selecting Save As.


                The SampleIntrabarBacktest reference sample demonstrates the logic processed when BarsInProgress is 0, and placing orders to BarsInProgress 1 (the 1 tick series).
                https://ninjatrader.com/support/help...ipt_strate.htm
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  hey All,

                  This time we applied the 1 tick series.
                  a few adaptations have been made. We will enumerate Very quickly the small changes that this thread led to, see the Result Picture, and see if something is missing :

                  1st things 1st :
                  Code:
                   protected override void OnStateChange()
                  {
                  if (State == State.SetDefaults)
                  {
                  TraceOrders = true;
                  }
                  There are 4 secondary series now, we did add the 1 tick after the others with the intend of letting every series to be checked 1st :
                  Code:
                  else if (State == State.Configure)
                  {
                  AddDataSeries(Data.BarsPeriodType.Tick, 300);
                  AddDataSeries(Data.BarsPeriodType.Tick, 900);
                  AddDataSeries(Data.BarsPeriodType.Tick, 4200);
                  AddDataSeries(Data.BarsPeriodType.Tick, 1);
                  }
                  We adapted the CurrentBars check count to as many series there are. The same for the BarsInProgress :
                  Code:
                   protected override void OnBarUpdate()
                  {
                  if (CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1 || CurrentBars[3] < 1 || CurrentBars[4] < 1)
                  return;
                  if (BarsInProgress == 0)
                  if (BarsInProgress == 1)
                  if (BarsInProgress == 2)
                  if (BarsInProgress == 3)
                  if (BarsInProgress == 4)
                  Since the Order should be on the 1st Secondary, we are letting it there,
                  But we order the calculation to do it Only when the 1st tick serie placed in the End is close enough to where the the 1st secondary will act :
                  && (Closes[4][0] < (aaaKCOB1.Midline[0] + 0.5) )
                  && (Closes[4][0] > (aaaKCOB1.Midline[0] - 0.5) )
                  )
                  {
                  EnterLongLimit(Convert.ToInt32(DefaultQuantity), aaaKCOB1.Midline[0], "");
                  }
                  }
                  We can see in the attachments that something has changed but nothing is solved.
                  I'll just try the entry on the 1 tick somehow,see what we get, see you next post.
                  Attached Files

                  Comment


                    #24
                    hey All,

                    just this part has changed, not the rest, entry on the 1 tick :
                    Code:
                     && (Closes[1][0] < (aaaKCOB1.Midline[0] + 0.5) )
                    && (Closes[1][0] > (aaaKCOB1.Midline[0] - 0.5) )
                    )
                    {
                    // EnterLong(int barsInProgressIndex, int quantity, string signalName)
                    EnterLong(4, Convert.ToInt32(DefaultQuantity), "");
                    }
                    We can still see discrepancies.
                    I tried with the Closes a little closer but it did not change very much.
                    Attached Files

                    Comment


                      #25
                      Hello Amedeus,

                      The logic would only be submitted when BarsInProgress is 2. Not when the other bars in progresses are occurring.
                      You can remove:


                      if (BarsInProgress == 0)
                      if (BarsInProgress == 1)
                      if (BarsInProgress == 3)
                      if (BarsInProgress == 4)

                      and just leave

                      if (BarsInProgress == 2)
                      {
                      // print of time and all values in conditions that place order here, along with any relevant information.

                      Print(string.Format("{0} | BarsInProgress: {1}, {2} {3} {4}", Time[0], BarsInProgress, Instrument.FullName, BarsPeriod.Value, BarsPeriod.BarsPeriodType));

                      Print(string.Format("{0} | Closes[1][0]: {1} < (aaaKCOB1.Midline[0] + 0.5): {2} && Closes[1][0]: {1} > (aaaKCOB1.Midline[0] - 0.5): {3}", Time[0], Closes[1][0], (aaaKCOB1.Midline[0] + 0.5), (aaaKCOB1.Midline[0] - 0.5)));

                      // my conditions to place order here//
                      if ((Closes[1][0] < (aaaKCOB1.Midline[0] + 0.5) ) && (Closes[1][0] > (aaaKCOB1.Midline[0] - 0.5))
                      {
                      EnterLong(4, Convert.ToInt32(DefaultQuantity), "");
                      }
                      }

                      With TraceOrders set to true we can track when the order is submitted, ignored, automatically cancelled, rejected.
                      In OnOrderUpdate() we can track when the order becomes working and fills.
                      Print(order.ToString());

                      This would then be run on both charts so we can compare the output from the two charts to see exactly when the condition is true, when the order method is called to submit the order, and when the order is filled, ignored, or rejected.

                      Attach the output txt files with your reply.

                      If they match, the orders will be shown on the bar that closes encompassing the time of the order on both charts.

                      If they don't match, the orders may be on different bars.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #26
                        Hey Chelsea, thanks

                        I just saw your last post after sending mines.
                        It seems i pretty much spontaneously did what you said but for the prints, yet.

                        the output threshold if already full of the 1Tick of today now, after historical calculation. what ca be done about this ?

                        Comment


                          #27
                          Hello Amedeus,

                          As we are only concerned with BarsInProgress 2, the print would be within that condition set and only printing when BarsInProgress is 2, when the condition for the entry is evaluated.

                          Is it BarsInProgress 2 when you are placing orders? The 900 Tick series?
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            Hi Chelsea.

                            we had a synch prob. now it's ok.

                            I am not sure anymore if we are talking of the same.

                            I thought it was clear by now that the entry should be on the 1rst secondary series : 300 : Midline1, if we can.

                            But the porpuse of this is to be able to have a chart overview of the strategy from a 900 or more chart, or less too ...

                            I can reload and print the output right now : which BarsInProgress do I keep ?


                            Last edited by Amedeus; 05-26-2021, 12:47 PM.

                            Comment


                              #29
                              Hello Amedeus,

                              Apologies, the logic should be within the condition set for BarsInProgress 1 for the 300 tick series.

                              What is the issue you are having?

                              I understood this as, the order is appearing on a different bar (range) open to close time on another chart using a different primary series.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                hi Chelsea, thanks

                                The text file of the output is too big.
                                I could search only for the trades from our examples so far but they are not taken by the strategy this time (since and with only BarsInProgress1). they will not be found in the output.
                                I could not say why.
                                --

                                I have a strategy that i'd like to watch or maybe apply on different frames.
                                I don't absolutely need to apply it on different time frames, it could be applied and/or backtested just fine on a primary 300 only.
                                This is all just to have an overview of the strategy from a larger standpoint.

                                The initial idea was to just set every condition NOT on the primary series.
                                When applying such strategy on another frame, is when this thread started, because the markers did not match.

                                From what I can understand now we cannot have a perfect backtest with a OnBarClose calculation, . There will always be discrepancies, except maybe with TickReplay.
                                Dicrepancies on the chart like our examples, and discrepancies in the stats of the analyzer (but i dont need to backtest a primary 900 in the analyzer at all, I would love a chart view though, if discrepancies are minor ).

                                Apparently this issue is an issue only for State.Historical : if we would apply such strategy (a simple "nothing on the primary" logic) on a real time account, it would calculate on each OnBarClose of the 1st secondary series ( if like in our case we want the 1st secondary to lead, with orders on this series1 only) wether the strategy is applied on a 300 or a 900. << this is correct right ?

                                this is the "issue".
                                ---

                                now,
                                why 3/4 of the trades have disapeared since there is only BarsInProgress1 in the script ? Does it not recognize the primary anymore ?
                                Should I put back BarsInProgress0 ?
                                Is this combination with the 1Tick series the best we can do for a backtest calculated OnbarClose ?
                                Does this 1 tick Series addition have any relavancy when State == State.RealTime ?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by rhyminkevin, Yesterday, 04:58 PM
                                5 responses
                                62 views
                                0 likes
                                Last Post dp8282
                                by dp8282
                                 
                                Started by realblubb, Today, 09:28 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post realblubb  
                                Started by AaronKoRn, Yesterday, 09:49 PM
                                1 response
                                18 views
                                0 likes
                                Last Post Rikazkhan007  
                                Started by ageeholdings, Today, 07:43 AM
                                0 responses
                                12 views
                                0 likes
                                Last Post ageeholdings  
                                Started by pibrew, Today, 06:37 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post pibrew
                                by pibrew
                                 
                                Working...
                                X