Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2nd bar same color

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

    2nd bar same color

    Hey all had a quick question. I am playing around with some new strategies and was wondering. Is there a way to take a buy or sell if the 2nd bar after a color change is same color?

    Ie. turns from green to red, and then 2nd bar is red, so sell at the open of 3rd bar?

    Thanks in advance.

    #2
    Hello sprks7979,

    Thanks for your post.

    To detect if the current bar is an up bar (green), a condition could be created that checks if the current Close price (Close[0]) is greater than the current Open price (Open[0]).

    To detect if the previous bar is an up bar, the condition would check if the previous Close price (Close[1]) is greater than the previous Open price (Open[1]).

    Note that we pass a BarsAgo value of 0 in for the price to get the current price. We pass a BarsAgo value of 1 in for the price to get the previous bar's price.

    Detecting if the current bar is a down bar (red), the condition could check if the current Close price is less than the current Open price.

    The previous bar will be a down bar is the previous Close price is less than the previous Open price.

    A condition to check if two bars are in the same direction might look something like this:

    Code:
    //detect if two bars are both up bars (green)
    if (Close[0] > Open[0] && Close[1] > Open[1])
    {
        //do something here
    }
    See this help guide page for more information about accessing PriceSeries values: https://ninjatrader.com/support/help...riceseries.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      NinjaTrader_BrandonH Thanks for your reply, I should have mentioned that I am doing this in the strategy builder. Is it possible to do the same thing in the builder by adding multiple conditions?

      Comment


        #4
        Hello sprks7979,

        Thanks for your note.

        Yes, it would be possible to have 2 or more price comparison conditions in the same Set when creating a Strategy Builder strategy.

        See this help guide page for information about how to make Price comparisons in the Strategy Builder: https://ninjatrader.com/support/help..._builder.htm#H owToMakePriceDataComparisons

        Here is a link to our publicly available training video, 'Strategy Builder 301', which you might find helpful.

        Strategy Builder 301 — https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s

        I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
        https://ninjatrader.com/support/help..._resources.htm

        Please let me know if I may assist further.​​
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        51 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        127 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X