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

Help with coding indicator

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

    Help with coding indicator

    I'm new to coding in c#. I am trying to run a simple indicator to accumulate volume over a 10 bar interval. The code below plots nothing. I would appreciate it if someone can explain why it doesn't plot.

    if
    (CurrentBar == 0)
    Value.Set(
    0);
    else
    {
    int x = 0;
    do
    {
    Value.Set(Value[
    1]+ Volume[0]);
    x = x +
    1;
    }
    while (x < 10);
    Value.Set(
    0);

    #2
    Originally posted by Ninjaman View Post
    I'm new to coding in c#. I am trying to run a simple indicator to accumulate volume over a 10 bar interval. The code below plots nothing. I would appreciate it if someone can explain why it doesn't plot.

    if
    (CurrentBar == 0)
    Value.Set(
    0);
    else
    {
    int x = 0;
    do
    {
    Value.Set(Value[
    1]+ Volume[0]);
    x = x +
    1;
    }
    while (x < 10);
    Value.Set(
    0);

    if (CurrentBar == 0)
    Value.Set(
    0);

    if (CurrentBar < 10) return; // Minumum bars needed for calculating 10 bar interval.

    else
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Originally posted by rt6176 View Post
      if (CurrentBar == 0)
      Value.Set(
      0);

      if (CurrentBar < 10) return; // Minumum bars needed for calculating 10 bar interval.

      else
      RT,

      Thanks. I tried that but it still comes up blank.

      Comment


        #4
        Define "int x = 0;" in the init section on the script.
        RJay
        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

        Comment


          #5
          Here is what i did and it still doesn't work. this one is called volaccum1
          {

          int x = 0;
          }
          protectedoverridevoid OnBarUpdate()
          {
          if (CurrentBar == 0)
          Value.Set(
          0);
          else
          if
          (CurrentBar < 10) return;
          else
          {
          int x = 0;
          do

          {
          Value.Set(Value[
          1]+ Volume[0]);
          x = x +
          1;
          }
          while (x < 10);
          Value.Set(
          0);
          }
          }
          ******
          This one does work and it's called vollaccum
          protectedoverridevoid OnBarUpdate()
          {
          if (CurrentBar == 0){
          Value.Set(
          0);}
          else
          {
          Value.Set(Value[
          1]+ Volume[0]);
          }
          if (Bars.SessionBreak) {
          Value.Set(
          0);}
          }

          They seem similar, but I still can't get the top one to work. I included a screenshot of both
          Attached Files

          Comment


            #6
            Originally posted by rt6176 View Post
            Define "int x = 0;" in the init section on the script.

            Sorry,

            I should have checked first, here is where I was thinking.

            #region Variables
            // Wizard generated variables
            // User defined variables (add any user defined variables below)

            int x = 0;

            #endregion
            RJay
            NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by lightsun47, Today, 03:51 PM
            0 responses
            4 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            8 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            44 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            13 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            9 views
            0 likes
            Last Post port119
            by port119
             
            Working...
            X