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 Additional Data AddRenko

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

    Renko Additional Data AddRenko

    I am trying to add additional data in the form of Renko to a strategy. My script compiles but does not seem to work as expected, ie. entries when there shouldn't be.
    The strategy will be ran on a 10 Renko and I would like to call a 30 Renko for support in a entire.

    I am new to this so I tried to build the strategy using the Strategy Builder and unlocking it to replace the AddDataSeries() with AddRenko() but it does not seem to work. Also would I be able to use this in a 'Playback Connection'?

    See snip below.


    private APZ APZ1;
    private APZ APZ2;

    }
    else if (State == State.Configure)
    {
    AddRenko("ES 06-22", 30, MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    APZ1 = APZ(Close, 2, 20);
    APZ2 = APZ(Closes[1], 2, 20);
    }

    if ((Position.MarketPosition == MarketPosition.Flat)
    && (Close[0] > APZ1.Upper[0])
    && (Close[0] > APZ2.Upper[0]))
    {
    EnterLong(Convert.ToInt32(Contracts), @"E1Long");
    }

    #2
    Hello pattersp,

    Thank you for the post.

    You had the right idea, you need to unlock it to be able to use renko bars. The problem is that the APZ does not allow for series input based on its code, to use the APZ value you would have to collect that from BarsInProgress 1. The way you have it now will work for any indicator that can take an input, for example the SMA.


    Code:
    private APZ APZ1;
    private double APZ2;
    
    }
    else if (State == State.Configure)
    {
        AddRenko("ES 06-22", 30, MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
        APZ1 = APZ(Close, 2, 20);
    }
    
    if(BarsInProgress == 0)
    {
         if(APZ2 <= 0) return;
         if ((Position.MarketPosition == MarketPosition.Flat) && Close[0] > APZ1.Upper[0] && Close[0] > APZ2)
        {
             EnterLong(Convert.ToInt32(Contracts), @"E1Long");
        }
    }
    
    if(BarsInProgress == 1)
    {
        APZ2 = APZ(2,20).Upper[0];
    }
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks for your replay!
      I still seem to be doing something incorrect at now there are no entries at all in the 'Playback Connection'.

      I have a few other Sets prior to the entry section that may be causing an issue?
      Should the first BarsInProgress be != 0 ?

      Sorry like I said I am very new to this.


      private APZ APZ1;
      private double APZ2;


      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      //Defaults
      }
      else if (State == State.Configure)
      {
      AddRenko("ES 06-22", 30, MarketDataType.Last);
      }
      else if (State == State.DataLoaded)
      {
      APZ1 = APZ(Close, 2, 20);
      }
      }

      protected override void OnBarUpdate()
      {
      if (BarsInProgress != 0)
      return;

      if (BarsInProgress == 0)
      {
      // Set 6
      if (APZ2 <= 0) return;
      if ((Position.MarketPosition == MarketPosition.Flat) && Close[0] > APZ1.Upper[0] && Close[0] > APZ2)
      {
      EnterLong(Convert.ToInt32(Contracts), @"E1Long");
      }
      if(BarsInProgress == 1)
      {
      APZ2 = APZ(2,20).Upper[0];
      }
      }



      Comment


        #4
        Hello pattersp,

        The problem is with how you have the BarsInProgress conditions, you also have an return statement that needs removed.

        Remove this:

        Code:
        if (BarsInProgress != 0)
        return;
        And then make these two separate conditions:

        Code:
        if (BarsInProgress == 0)
        {
            if (APZ2 <= 0) return;
            if ((Position.MarketPosition == MarketPosition.Flat) && Close[0] > APZ1.Upper[0] && Close[0] > APZ2)
           {
              EnterLong(Convert.ToInt32(Contracts), @"E1Long");
           }
        }
        
        if(BarsInProgress == 1)
        {
            APZ2 = APZ(2,20).Upper[0];
        }

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rhyminkevin, Today, 04:58 PM
        0 responses
        13 views
        0 likes
        Last Post rhyminkevin  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        6 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        14 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        48 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        15 views
        0 likes
        Last Post bltdavid  
        Working...
        X