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

Renko Reversal

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

    Renko Reversal

    Hi!

    I need a simple strategy.

    At the first renko bar that the price close more high of the previous bar ENTER LONG and at the first renko bar that the price close less of the previous bar ENTER SHORT.

    Can you help me?

    Thanks a lot

    #2
    Hello SamaS, and thank you for your question. While full strategy development is beyond the scope of our support, we are always happy to educate our user base on how NinjaTrader is designed to work.

    To detect whether this bar's high is higher than last bar's high, and enter long, we can use this code :

    Code:
    [FONT=Courier New]if (High[0] > High[1])
    {
      EnterLong();
    }
    [/FONT]
    Detecting whether this bar's close is lower than last bar's close is very similar

    Code:
    [FONT=Courier New]/* else */ if (Close[0] > Close[1])
    {
      EnterShort();
    }
    [/FONT]
    If you are using these together, you will want to uncomment the else by removing the /* and the */ .

    If your bar type for the chart is Renko, the above code will behave as expected.

    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Reversal

      Ok. thanks

      And how can indicate to enter only when the differences of the last bar between the previous bar is the size of renko?

      I need a reversal strategy but I'm not very able to program ninjascript.

      Thnks

      Comment


        #4
        For this we will need to return to the definition of a Renko bar. I am providing a publicly available link to the Investopedia definition.

        Originally posted by http://www.investopedia.com/terms/r/renkochart.asp
        A renko chart is constructed by placing a brick in the next column once the price surpasses the top or bottom of the previous brick by a predefined amount. White bricks are used when the direction of the trend is up, while black bricks are used when the trend is down.
        Beyond here, then, I am going to need to ask for some more information, since every Renko is going to be the exact same size in terms of price. Can I ask what you mean when you say

        And how can indicate to enter only when the differences of the last bar between the previous bar is the size of renko
        By the definition I posted earlier, this will always be true as far as I can tell, since the difference in price between two bars is the size of a Renko bar.

        If you would like to see the size of a Renko bar programmatically, we can use this from the Help Guide,

        Originally posted by https://ninjatrader.com/support/helpGuides/nt7/?barsperiod.htm
        BarsPeriod.Value

        Returns an integer value representing the period parameter.
        ...
        - When using Renko Bars objects this represents the "brickSize" parameter
        So this is the size, in price value, of a Renko bar,
        Code:
        [FONT=Courier New]protected double renkoPriceSize()
        {
          return BarsPeriod.Value * TickSize;
        }
        [FONT=Arial][/FONT][/FONT]


        I look forward to being able to answer any further questions you have.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Hi!

          I've an other question but i don't know how I can change thread... sorry.

          I need to insert in my strategy a MACD crossover but i want that the strategy go LONG when MACD crossabove only when this Cross is over a specific value like 6..... and the same for SHORT under a specific value like 6....

          How can I do this?
          What's the code... ??

          Thanks

          Is this cod correct for a crossover only... how can add upper o under a specific number?


          {
          // Condition set 1
          if (CrossAbove(EMA(MACD(Fast, Slow, Smooth).Avg, MAPeriod), MACD(Fast, Slow, Smooth).Avg, 1))
          {
          EnterShort(DefaultQuantity, "");
          }

          // Condition set 2
          if (CrossAbove(MACD(Fast, Slow, Smooth).Avg, EMA(MACD(Fast, Slow, Smooth).Avg, MAPeriod), 1))
          {
          EnterLong(DefaultQuantity, "");

          Comment


            #6
            We are happy to answer any questions that come up.

            The easiest way to set up a crossover condition with an offset, especially with a short lookback period such as your condition with a 1 bar lookback, is to compare to a single selected value from the 2nd series, and then modify that value. In our case that would be,

            Code:
            [FONT=Courier New]if (CrossAbove(EMA(MACD(Fast, Slow, Smooth).Avg, MAPeriod), MACD(Fast, Slow, Smooth).Avg[SIZE=3][B][0] + TickSize * 6[/B][/SIZE], 1))[/FONT]
            I have bolded my changes to make it clear what I am doing.

            • [0] means "the most recent value from this series"
            • I then take that value and add 6 to it

            So in plain language, this means "If the EMA average has crossed above 6 ticks above the MACD average"


            Please let us know if there are any other ways we can help.
            Jessica P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rtwave, 04-12-2024, 09:30 AM
            4 responses
            29 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Started by yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            6 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X