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

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.
    Brandon H.NinjaTrader Customer Service

    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.​​
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Working...
        X