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

AddRenko() breaks code

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

    AddRenko() breaks code

    i currently try to use a multtimeframe for renkobars but when i include the nessesary AddRenko everything seems to break.
    Code:
            protected override void Initialize()
            {
                Overlay                = true;
                AddRenko(Instrument.MasterInstrument.Name,100,MarketDataType.Last);
                CalculateOnBarClose = true;
            }
    
    
            protected override void OnBarUpdate()
            {
                Print("1");
                if (BarsInProgress == 1){    
                    Print("2");
                }
                if (BarsInProgress == 0){
                    Print("3");
                }
            }
    to figure out whats goin on i got rid of nearly all code. running the above code, i didnt get any prints. however by just removing the AddRenko line, i was able to get 1 and 3 prints as expected.
    i also tried refering to the instrument by simply AddRenko("EURUSD",...) but same thing.

    help?!
    Last edited by BigRo; 12-17-2015, 12:25 PM.

    #2
    Hello BigRo,

    Thank you for your inquiry.

    Please utilize Instrument.FullName rather than Instrument.MasterInstrument.Name.

    Utilizing Instrument.MasterInstrument.Name does not return the full name of the instrument ($EURUSD). You can see this in your Log tab in the Control Center.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      I created an indicator using the Gomi Volume ladder on a 10 range chart. I would like to display this indicator on a renko chart but still do ther calculations based on the 10 range chart.

      In the OnStartUp() method I previously had:

      objGomVolumeLadder = GomVolumeLadder();

      The gomi ladder also has an additional constructor where we can pass a dataseries:

      objGomVolumeLadder = GomVolumeLadder(tenRangeSeries);

      Where tenRangeSeries is a dataseries created in the Initialize() method:

      Add(PeriodType.Range, 10);

      tenRangeSeries = new DataSeries(this);


      In OnBarUpdate() I have the following code to populate the dataseries but the indicator is not displaying indicating an error with the approach.

      if (BarsInProgress == 1)
      return;


      tenRangeSeries.Set(BarsArray[1][0]);

      //other processing here

      Comment


        #4
        Hello mballagan,

        Thank you for writing in.

        You'll want to ensure that you have at least 1 range bar before setting it to your tenRangeSeries.

        Example:
        Code:
        if (CurrentBars[1] < 0) return; // we're using 0 as CurrentBar starts at 0 for the first bar and increments by one for each new bar: http://ninjatrader.com/support/helpGuides/nt7/?currentbar.htm
        
        tenRangeSeries.Set(BarsArray[1][0]);
        More information about checking tosee that you have enough bars in the DataSeries you are accessing can be found here: http://ninjatrader.com/support/forum...ead.php?t=3170
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thanks Zachary.

          Also my code uses FirstTickOfBar in the OnBarUpdate() method. Is there a way to reference a second dataseries using this method such as FirstTickOfBar[1] or Bars[1].FirstTickOfBar?

          Comment


            #6
            Hello mballagan,

            You'll need to check for FirstTickOfBar for the secondary series with the BarsInProgress check.

            Code:
            protected override void OnBarUpdate()
            {
                 if (BarsInProgress == 1) // if the secondary series called OnBarUpdate()
                 {
                      if (FirstTickOfBar) // do something if it's the FirstTickOfBar for the secondary series
                      {
                           // do something
                      }
                 }
            }
            Zachary G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by zstheorist, Today, 07:52 PM
            0 responses
            3 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            149 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            5 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            33 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            5 views
            0 likes
            Last Post tkaboris  
            Working...
            X