Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinzaRenko

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

    NinzaRenko

    Hi,
    Using NinzaRenko bar, can someone please help me with this.

    I want to write a trading algorithm based on the step-by-step conditions provided below.

    1- Sets Green and Red Bar Condition.
    1.1- A Green Bar occurs when the close is greater than the open.
    1.2- A Red Bar occurs when the close is less than the open.

    2- Sets Bullish and Bearish Reversal Bar condition.
    2.1- A Bullish Reversal Bar condition occurs when the previous bar is a Red Bar and the current bar is a Green Bar.
    2.2- A Bearish Reversal Bar condition occurs when the previous bar is a Green Bar, and the current bar is a Red Bar.

    3- Sets Swing Low and Swing High Condition.
    3.1- A Swing Low is the low of a Bullish Reversal Bar condition.
    3.2- A Swing High is the high of a Bearish Reversal Bar condition.

    4- Sets Lower Swing and Higher Swing condition for entry signals.
    4.1- A Higher Swing occurs when the current Swing Low is greater or equal to another Swing Low that happened 1 bar ago or multiple bars ago. enter long.
    4.2- A Lower Swing occurs when the current Swing High is less or equal to another Swing High that happened 1 bar ago or multiples bar ago. enter short.

    5- Sets Stop Loss and Profit Target. A stop loss of 24 ticks and a profit target of 20 ticks is applied to both long and short entries.

    I have zero knowledge in coding.

    Thanks!

    #2
    Hello Sharkclub,

    Welcome to the NinjaTrader forums!

    It is necessary to have a fundamental understanding of programming in C# to make NinjaScripts. I would highly encourage you to take a formal class or bootcamp if you have interest in this.

    Below I am providing a link to a forum post with helpful resources on getting started with C# and NinjaScript.


    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.


    That said, this would be a fairly advanced script.

    The green bar and red bar can be found fairly easy with the Close and Open series.

    if (Close[0] > Open[0]) // the close is greater than the open, this is a green bar

    if (Close[0] < Open[0]) // the close is less than the open, this is a red bar

    Below are links to the help guide.




    With 'Sets Bullish and Bearish Reversal Bar condition'

    You will need some logic that check the brick size of the renko bar and calculate where the next reversal will be.

    The BarsPeriod contains information about the bar type. The BarsPeriod.Value would be the brick size for regular renko bars. You will want to confirm with the developer of the NinZa Renko bars what property values are used in this custom bar type.



    'Sets Swing Low and Swing High Condition'

    The swing indicator is a tricky indicator to use. This indicator changes its historical values. Meaning that bar 100 may update and there may be no swing on that bar, then a few bars later on bar 105 a swing was detected on that previous bar 100. The indicator goes back and sets the swing value on bar 100.

    Because of this, you don't want to just check the plot value. Instead, you want to check what the most recent swing bar number was with SwingHighBar() and SwingLowBar(), then use the high or low from that bar.

    The help guide provides sample code.



    'Sets Lower Swing and Higher Swing condition for entry signals'

    The SwingHighBar() method lets you select an instance ago. Supply a value of 2 for the instance to compare the second most recent swing high / low to supplying a value of 1 for the most recent swing high / low.

    Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)


    'Sets Stop Loss and Profit Target. A stop loss of 24 ticks and a profit target of 20 ticks is applied to both long and short entries'

    A simple stop loss with a number of ticks can be added with SetStopLoss() and SetProfitTarget() in State.Configure.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      A picture of what I'm trying to do with some details.
      Attached Files

      Comment


        #4
        Below I've attached an indicator that might prove suitable
        for entering trades on NinzaRenko and UniRenko charts.

        I borrowed the button code from here,


        and converted it to a chart-trader-order-entry-helper indicator.

        The idea is that you 'arm' either the Long or Short buttons,
        (when a button is armed it will show '-ARMED-') by clicking
        on the button, click again to disarm.

        When the Long button is armed, the indicator looks for a green
        up bar that follows a red down bar. When it finds this entry
        condition, the indicator will use StartAtmStrategy and
        enter a Buy Market order using the account, atm strategy,
        and quantity specified in the chart trader.

        Similar for the Short button being armed, a red down bar
        after a green up bar and a Sell Market order is entered.

        After an order is entered, that button is automatically disarmed,
        the idea is: an armed button stays armed until it finds the entry
        condition, but it's only good one time.

        This indicator is a chart trader helper and so chart trader
        should be enabled. Test it using Sim101.

        More elaborate rules could be designed for the 'armed'
        state -- but these simple checks allow an immediate
        entry on bar close -- you'll just have to arm the button
        when you notice your setup is forming.
        Attached Files

        Comment


          #5
          Originally posted by bltdavid View Post
          Below I've attached an indicator that might prove suitable
          for entering trades on NinzaRenko and UniRenko charts.

          I borrowed the button code from here,


          and converted it to a chart-trader-order-entry-helper indicator.

          The idea is that you 'arm' either the Long or Short buttons,
          (when a button is armed it will show '-ARMED-') by clicking
          on the button, click again to disarm.

          When the Long button is armed, the indicator looks for a green
          up bar that follows a red down bar. When it finds this entry
          condition, the indicator will use StartAtmStrategy and
          enter a Buy Market order using the account, atm strategy,
          and quantity specified in the chart trader.

          Similar for the Short button being armed, a red down bar
          after a green up bar and a Sell Market order is entered.

          After an order is entered, that button is automatically disarmed,
          the idea is: an armed button stays armed until it finds the entry
          condition, but it's only good one time.

          This indicator is a chart trader helper and so chart trader
          should be enabled. Test it using Sim101.

          More elaborate rules could be designed for the 'armed'
          state -- but these simple checks allow an immediate
          entry on bar close -- you'll just have to arm the button
          when you notice your setup is forming.
          Thanks for this indicator.

          Please, instead of OrderType.Market, I want to implement OrderType.MIT and OrderType.Limit with some tweaks on this indicator. Is it feasible ... if YES, could you please direct me on how to implement this.

          lolu

          Comment


            #6
            Originally posted by omololu View Post

            Thanks for this indicator.

            Please, instead of OrderType.Market, I want to implement OrderType.MIT and OrderType.Limit with some tweaks on this indicator. Is it feasible ... if YES, could you please direct me on how to implement this.

            lolu
            It seems that bltdavid​ is not responding to my request. In any case, what I'm requesting is as follows;

            The below code from the BltRenkoTrader.cs​ indicator posted above by bltdavid​ is for OrderType.Market ... I want it for OrderType.MIT and OrderType.Limit orders.

            Order o = a.CreateOrder(instr, Direction == LONG ? OrderAction.Buy : OrderAction.Sell, OrderType.Market,
            OrderEntry.Automated, TimeInForce.Day, quantity, 0, 0, "", "Entry", Core.Globals.MaxDate, null);


            I shall appreciate a help.

            omololu​

            Comment


              #7
              Originally posted by omololu View Post

              It seems that bltdavid​ is not responding to my request. In any case, what I'm requesting is as follows;

              The below code from the BltRenkoTrader.cs​ indicator posted above by bltdavid​ is for OrderType.Market ... I want it for OrderType.MIT and OrderType.Limit orders.

              Order o = a.CreateOrder(instr, Direction == LONG ? OrderAction.Buy : OrderAction.Sell, OrderType.Market,
              OrderEntry.Automated, TimeInForce.Day, quantity, 0, 0, "", "Entry", Core.Globals.MaxDate, null);


              I shall appreciate a help.

              omololu​
              Stand by ... will post an update soon

              Comment


                #8
                Originally posted by bltdavid View Post

                Stand by ... will post an update soon
                Great !!!

                Thanks.

                Comment


                  #9
                  Originally posted by omololu View Post

                  Thanks for this indicator.

                  Please, instead of OrderType.Market, I want to implement OrderType.MIT and OrderType.Limit with some tweaks on this indicator. Is it feasible ... if YES, could you please direct me on how to implement this.

                  lolu
                  Where you able to have this indicator works? If so can you please tell me how. Cause I can't have it working. Thanks!

                  Comment


                    #10
                    Thank you for your patience.

                    Give this new version a try.

                    I've added 3 parameters to the property grid,

                    EntryOrderType
                    LimitOffset <-- number of ticks to adjust LimitPrice
                    StopOffset <-- number of ticks to adjust StopPrice


                    Market orders are self-explanatory, for all the other
                    order types the offset values are relative to the price
                    at bar close, and will adjust it accordingly.

                    Offset values of zero, therefore, mean bar close.
                    Offset values cannot be negative.

                    -- Example 1 --

                    If you select,

                    EntryOrderType=Limit
                    LimitOffset=1
                    StopOffset=n <-- not used w/Limit orders


                    then when the LONG entry signal is detected at bar close,
                    the indicator will submit a Limit entry order with a Limit
                    price of Close minus 1 tick.

                    For the SHORT entry signal, the Limit price for the LImit
                    entry order will be Close plus 1 tick.

                    -- Example 2 --

                    If you select,

                    EntryOrderType=MIT
                    LimitOffset=n <-- not used w/MIT orders
                    StopOffset=1

                    then when the LONG entry signal is detected at bar close,
                    the indicator will submit a MIT entry order with a Stop
                    price of Close minus 1 tick.

                    For the SHORT entry signal, the Stop price for the MIT
                    entry order will be Close plus 1 tick.

                    -=o=-

                    ​Look at the source code to see how the other order types
                    use the offsets to adjust the LimitPrice and/or StopPrice.

                    I think the calculations using the offsets is reasonable and
                    correct -- ie, Limit and MIT mirror each other, except one
                    uses LimitPrice and the other uses StopPrice.

                    Attached Files

                    Comment


                      #11
                      Originally posted by bltdavid View Post
                      Thank you for your patience.

                      Give this new version a try.

                      I've added 3 parameters to the property grid,

                      EntryOrderType
                      LimitOffset <-- number of ticks to adjust LimitPrice
                      StopOffset <-- number of ticks to adjust StopPrice


                      Market orders are self-explanatory, for all the other
                      order types the offset values are relative to the price
                      at bar close, and will adjust it accordingly.

                      Offset values of zero, therefore, mean bar close.
                      Offset values cannot be negative.

                      -- Example 1 --

                      If you select,

                      EntryOrderType=Limit
                      LimitOffset=1
                      StopOffset=n <-- not used w/Limit orders


                      then when the LONG entry signal is detected at bar close,
                      the indicator will submit a Limit entry order with a Limit
                      price of Close minus 1 tick.

                      For the SHORT entry signal, the Limit price for the LImit
                      entry order will be Close plus 1 tick.

                      -- Example 2 --

                      If you select,

                      EntryOrderType=MIT
                      LimitOffset=n <-- not used w/MIT orders
                      StopOffset=1

                      then when the LONG entry signal is detected at bar close,
                      the indicator will submit a MIT entry order with a Stop
                      price of Close minus 1 tick.

                      For the SHORT entry signal, the Stop price for the MIT
                      entry order will be Close plus 1 tick.

                      -=o=-

                      ​Look at the source code to see how the other order types
                      use the offsets to adjust the LimitPrice and/or StopPrice.

                      I think the calculations using the offsets is reasonable and
                      correct -- ie, Limit and MIT mirror each other, except one
                      uses LimitPrice and the other uses StopPrice.

                      GREAT !!!

                      Thanks.

                      omololu

                      Comment


                        #12
                        Originally posted by bltdavid View Post
                        Thank you for your patience.

                        Give this new version a try.

                        I've added 3 parameters to the property grid,

                        EntryOrderType
                        LimitOffset <-- number of ticks to adjust LimitPrice
                        StopOffset <-- number of ticks to adjust StopPrice


                        Market orders are self-explanatory, for all the other
                        order types the offset values are relative to the price
                        at bar close, and will adjust it accordingly.

                        Offset values of zero, therefore, mean bar close.
                        Offset values cannot be negative.

                        -- Example 1 --

                        If you select,

                        EntryOrderType=Limit
                        LimitOffset=1
                        StopOffset=n <-- not used w/Limit orders


                        then when the LONG entry signal is detected at bar close,
                        the indicator will submit a Limit entry order with a Limit
                        price of Close minus 1 tick.

                        For the SHORT entry signal, the Limit price for the LImit
                        entry order will be Close plus 1 tick.

                        -- Example 2 --

                        If you select,

                        EntryOrderType=MIT
                        LimitOffset=n <-- not used w/MIT orders
                        StopOffset=1

                        then when the LONG entry signal is detected at bar close,
                        the indicator will submit a MIT entry order with a Stop
                        price of Close minus 1 tick.

                        For the SHORT entry signal, the Stop price for the MIT
                        entry order will be Close plus 1 tick.

                        -=o=-

                        ​Look at the source code to see how the other order types
                        use the offsets to adjust the LimitPrice and/or StopPrice.

                        I think the calculations using the offsets is reasonable and
                        correct -- ie, Limit and MIT mirror each other, except one
                        uses LimitPrice and the other uses StopPrice.

                        Please, I have a new request. I want to be able to select the EntryOderTypes --- MIT, Limit, Market, StopLimit, and StopMarket on the chart and "on-the-fly" instead of via the Indicator Settings. Could you please include this request in your next update ? Alternatively, you may please wish to direct and guide me with some code snippets to achieve this.

                        Thans.

                        omololu​

                        Comment


                          #13
                          Yes, that would be a nice addition.

                          Feel free to use this indicator source code as
                          the basis for your future projects.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Jonafare, 12-06-2012, 03:48 PM
                          5 responses
                          3,986 views
                          0 likes
                          Last Post rene69851  
                          Started by Fitspressorest, Today, 01:38 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post Fitspressorest  
                          Started by Jonker, Today, 01:19 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post Jonker
                          by Jonker
                           
                          Started by futtrader, Today, 01:16 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post futtrader  
                          Started by Segwin, 05-07-2018, 02:15 PM
                          14 responses
                          1,792 views
                          0 likes
                          Last Post aligator  
                          Working...
                          X