Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Time Frames

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

    Multiple Time Frames

    I am using Renko bars -ideally i would like to enter on the close of the candle to avoid the whole backtesting issue with these bars. i was told to use multiple time frames so that i can enter on the next time bar or tick. when i do this it always enters based off the ticks and not Renko. Do i open a tick chart and Add Renko or vice versa?
    // Condition set 1
    if (xxxxxxxxxxxx[0] < xxxxxxxxxxx[0])

    if (BarsInProgress == 1)
    return;
    {


    {

    }

    EnterShort((int) (Close[0]), "SHORT ENTRY");

    #2
    Hello hifreq,

    Thank you for your post.

    To clarify here; are you backtesting in the Strategy Analyzer?

    Do you want your calculations made on the Renko bars or on the added "smaller" period type and interval (1 tick for example)?

    Or are you just trying to have your calculations and orders placed on the close of the Renko bar?

    I look forward to your response.

    Comment


      #3
      - I was running it on a normal chart and looking at the historical performance- I want to execute on the close of the renko bar and the conditions are all from renko
      - I was only using a quick time frame so that I can see a real or better historical performance result. In real time it will get in on the open of the next renko bar but in historical it won't necessarily do that if the next bar goes the opposite direction.


      Thx

      Comment


        #4
        Hello hifreq,

        Thank you for your response.

        In this case you would not need to use the smaller time frame in real-time trading, but use the smaller time-frame when backtesting in the Strategy Anlayzer.

        If you wish to have the executions and calculations on the close of a bar then set CalculateOnBarClose to True. For information on CalculateOnBarClose please visit the following link: http://www.ninjatrader.com/support/h...onbarclose.htm

        Please let me know if you have any questions.

        Comment


          #5
          So calculateonbarclose will enter and or exit me at the close price of the renko bar for back testing purposes? If so can you just explain where I place this true statement in the code as I did not understand from the HELP where it should or should not be placed within the code.

          Comment


            #6
            Hello hifreq,

            Thank you for your response.

            Backtesting will always be CalculateOnBarClose = true, this cannot be changed and does not need to be set for backtesting.

            However, in your code the CalcualteOnBarClose bool must be placed in the Intialize() method.

            Please let me know if I may be of further assistance.

            Comment


              #7
              This is my code and with this it keeps running the criteria off the small time frame bars and not renko.
              protected override void Initialize()
              {


              {

              }
              AddRenko("$EURUSD", 40, MarketDataType.Last
              );
              CalculateOnBarClose = true;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              // Condition set 1
              if (xxxx()xxxClose[0] <xxxxx()xxxxOpen[0])

              if (BarsInProgress == 1)
              return;
              {


              {

              }

              EnterShort((int) (Close[0]), "SHORT ENTRY");

              ????

              Comment


                #8
                Hello hifreq,

                Thank you for your response.
                Originally posted by hifreq View Post
                protected override void Initialize()
                {


                {

                }
                AddRenko("$EURUSD", 40, MarketDataType.Last
                );
                CalculateOnBarClose = true;
                }

                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                // Condition set 1
                if (xxxx()xxxClose[0] <xxxxx()xxxxOpen[0])

                if (BarsInProgress == 1)
                return;
                {


                {

                }

                EnterShort((int) (Close[0]), "SHORT ENTRY");

                ????
                In this case remove the if(BarsInProgress ==1 )return; line and instead place your code within if(BarsInProgress == 0) and also make sure CalculateOnBarClose is set in the Initialize() method:
                Code:
                protected override void Initialize()
                {
                
                CalculateOnBarClose = true;	
                AddRenko("$EURUSD", 40, MarketDataType.Last);
                            
                }
                
                protected override void OnBarUpdate()
                {
                if(BarsInProgress == 0)
                {
                // Condition set 1
                if (xxxx()xxxClose[0] <xxxxx()xxxxOpen[0])
                {
                EnterShort((int) (Close[0]), "SHORT ENTRY");
                }
                }

                Comment


                  #9
                  Here is the code I have and it looks just like yours but it is still creating entries and exits off the tick chart and not the Renko Bars - why???


                  {

                  }
                  CalculateOnBarClose = true;
                  AddRenko("$EURUSD", 15, MarketDataType.Last
                  );

                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  if (BarsInProgress == 0)
                  // Condition set 1
                  if (HeikenAshi().HAClose[0] < HeikenAshi().HAOpen[0])



                  {


                  {

                  }

                  EnterShort((int) (Close[0]), "SHORT ENTRY");

                  ------thx

                  Comment


                    #10
                    Hello hifreq,

                    Thank you for your response.

                    To be clear on this matter; BarsInProgress == 0 would be the instrument you apply the strategy to, BarsInProgress == 1 would be the period type you "add" with ADD().

                    Keep this in mind when developing your strategy.

                    If you want the orders on the instrument and period type you apply the strategy to then use BarsInProgress == 0.
                    if you want the orders on the added instrument and/or period type use BarsInProgress == 1.

                    I highly recommend reviewing the material covered at the following link for multiple instrument and period types in your NinjaScript code: http://www.ninjatrader.com/support/h...nstruments.htm

                    Comment


                      #11
                      Originally posted by hifreq View Post
                      AddRenko("$EURUSD", 40, MarketDataType.Last
                      &nbsp;
                      ...
                      if (BarsInProgress == 1)
                      return;
                      These 2 statements together say: "If the tick is from the Renko bars, do not do any processing; just exit the loop."

                      Comment


                        #12
                        obviously i know zero about writing code. I simply want to have the conditions run off Renko Bars but the execution off ticks b/c when backtesting as we all know the Renko bar can give misleading results. If there was a way to say enter on close of Renko Bar (so that there is not the chance to get the Renko bar close / open discrep.) that is what I am after. I was told to use a multiframe (one Renko one Tick). Either I get the entries and exits all off the Renko or It will be on the tick b/c it is using the tick as the condition set and not the renko - so what the heck am i doing wrong here is my code:

                        protected override void Initialize()
                        {
                        CalculateOnBarClose = true;



                        AddRenko("$EURUSD", 15, MarketDataType.Last);
                        {

                        }


                        }

                        /// <summary>
                        /// Called on each bar update event (incoming tick)
                        /// </summary>
                        protected override void OnBarUpdate()
                        {
                        if (BarsInProgress == 1)

                        // Condition set 1
                        if (xxxx().xxxxClose[0] < xxxxxxx().xxxxOpen[0])



                        {


                        {

                        }
                        }
                        else if (BarsInProgress == 0)
                        {
                        EnterShort((int) (Close[0]), "SHORT ENTRY");

                        Comment


                          #13
                          Hello hifreq,

                          Thank you for your response.

                          Can you provide a toy version of your script to test on my end? I would like to see exactly what you are doing here that is not working.

                          If you would prefer you can send the toy version or full version (your choice) to support[at]ninjatrader[dot]com with 'ATTN: Patrick - 824607' in the subject line.

                          Comment


                            #14
                            sent in an e-mail

                            Comment


                              #15
                              Originally posted by hifreq View Post
                              obviously i know zero about writing code. I simply want to have the conditions run off Renko Bars but the execution off ticks b/c when backtesting as we all know the Renko bar can give misleading results. If there was a way to say enter on close of Renko Bar (so that there is not the chance to get the Renko bar close / open discrep.) that is what I am after. I was told to use a multiframe (one Renko one Tick). Either I get the entries and exits all off the Renko or It will be on the tick b/c it is using the tick as the condition set and not the renko - so what the heck am i doing wrong here is my code:

                              private bool TakeTrade = false;

                              protected override void Initialize()
                              {
                              CalculateOnBarClose = true;



                              AddRenko("$EURUSD", 15, MarketDataType.Last);
                              {

                              }


                              }

                              /// <summary>
                              /// Called on each bar update event (incoming tick)
                              /// </summary>
                              protected override void OnBarUpdate()
                              {
                              if (BarsInProgress == 1)

                              // Condition set 1
                              if (xxxx().xxxxClose[0] < xxxxxxx().xxxxOpen[0]) TakeTrade = true;



                              {


                              {

                              }
                              }
                              else if (BarsInProgress == 0)
                              {
                              if (TakeTrade) EnterShort((int) (Close[0]), "SHORT ENTRY");
                              You need to pass information from one barSeries to the other. Determine trade condition on one series; let the other series execute trades based on the trade conditions. The easiest way to do so is to pass a flag, setting it in one series, using it in the other. One method is shown inside your code, above. You will need to reset the flag after the trade is entered. I would do it in the OnExecution() event-handler.
                              Last edited by koganam; 04-14-2013, 06:41 AM. Reason: Corrected code.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              668 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              377 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              110 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              580 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X