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

Bar to Bar Building

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

    Bar to Bar Building

    I just had a question, how should I go about building a bar to bar strategy/indicator...

    The first bar should look for a High[0] > High[1]...BarColor = Red

    Now the second bar, makes sure the first bar rules are met, High[0] > High[1]...BarColor = Yellow

    I took a look at the TDSequential indicator, because I see that it counts 1,2,3,... bar to bar. But its way over my head

    Any help would be appreciated, thx

    #2
    Hi chatchgo,

    Thank you for your post.

    I'm not 100% sure I understand what you are attemtping, please clarify.
    Last edited by NinjaTrader_Tim; 03-12-2010, 08:09 AM.
    TimNinjaTrader Customer Service

    Comment


      #3
      Thx Tim, I've gotten that far, but let me clarify. I want the indicator/strategy to check if the FIRST condition is met, and if and only if that bar is true, check for the SECOND condition, if this is true, check for the THIRD, and so on.

      In the building process, I would like to have the BarColor's change with each condition met.

      For example, if the first condition is met, BarColor = Red, but the next bar doesn't comply with the condition, so the bar remains its default color.
      So when I look at previous history, I would see a Red bar, but ONLY the red...

      Hope I'm being clear

      Comment


        #4
        Hi chatchgo,

        You could try nesting if statements. Here, the bars will only continue to be colored if each condition is met.

        Code:
        if (High[0] > High[1]) //First bar condition
        {
        	BarColor = Color.Red;
        
        		if (High[1] > High[2]) //Second bar condition
        		{
        			BarColor = Color.Yellow;
        	
        				if (High[2] > High[3]) //Third bar condition
        					BarColor = Color.Green;
        		}
        }
        TimNinjaTrader Customer Service

        Comment


          #5
          Thx for the quick reply Tim. The nesting is working, but there seems to be a small problem. I attached a screenshot, its showing a yellow bar, not proceeded by a red bar

          Not sure why it skipped the first condition here

          Any help again is appreciated

          Edit: Maybe its checking for the second condition in the code, but im hoping that it would check for Red bar first, then make yellow bar, not really a big issue, i could just easily disregard it. But for backtesting, it would be great to have it do these things first
          Attached Files
          Last edited by chatchgo; 03-12-2010, 09:49 AM.

          Comment


            #6
            Hi chatchgo,

            I don't see the mentioned attachment.
            TimNinjaTrader Customer Service

            Comment


              #7
              Thx for the quick reply Tim. The nesting is working, but there seems to be a small problem. I attached a screenshot, its showing a yellow bar, not proceeded by a red bar

              Not sure why it skipped the first condition here

              Any help again is appreciated

              Edit: Maybe its checking for the second condition in the code, but im hoping that it would check for Red bar first, then make yellow bar, not really a big issue, i could just easily disregard it. But for backtesting, it would be great to have it do these things first
              Attached Files

              Comment


                #8
                Hi chatchgo,

                Not sure what is happening there, as well as the following several yellow bars.

                Can you post your if statement nestings.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  As Im going thru putting it together, here is the snippet:

                  if
                  (High[0] >= High[1] + 2 * TickSize
                  && Low[
                  0] >= Low[1]) //First bar condition
                  {
                  BarColor = Color.Red;
                  if (High[1] > High[2]) //Second bar condition
                  {
                  BarColor = Color.Yellow;

                  if (High[2] > High[3]) //Third bar condition
                  {
                  BarColor = Color.Green;
                  }

                  In the attachment, the red bars that are circled are not meeting the Low[0] >= Low[1] condition??

                  Attached Files

                  Comment


                    #10
                    Hi chatchgo,

                    Thus far I've been unable to reproduce this. Please see the attached image.

                    Ensure CalculateOnBarClose = true;
                    From there, I suggest using Print() to compare the values to ensure they are truly achieved in the condition.
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      Still, I am stuck at trying to get the values to start over at 1 if the series is over...

                      So if red bar, then yellow, then the next bar fails the condition, the indicator/strategy should start over...it would need to meet a 1,2,3 buy/sell criteria, this would make it easier to backtest the strategy

                      Edit: If there are any indicators that you could point me too for reference, that would be great

                      Comment


                        #12
                        Hi chatchgo,

                        Unfortunately, there is no way to paint/unpaint historical bars by default.

                        You can check if all the conditions are met for each historical bar, then paint the current bar if the conditions are met.

                        As an alternative, you can use a drawing object, such as an arrow, which can be painted on historical bars, and removed.

                        More info at - http://www.ninjatrader-support.com/H...ml?DrawArrowUp

                        and - http://www.ninjatrader-support.com/H...moveDrawObject
                        TimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jclose, Today, 09:37 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post jclose
                        by jclose
                         
                        Started by WeyldFalcon, 08-07-2020, 06:13 AM
                        10 responses
                        1,413 views
                        0 likes
                        Last Post Traderontheroad  
                        Started by firefoxforum12, Today, 08:53 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post firefoxforum12  
                        Started by stafe, Today, 08:34 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Started by sastrades, 01-31-2024, 10:19 PM
                        11 responses
                        169 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X