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 samish18, Today, 01:01 PM
            0 responses
            4 views
            0 likes
            Last Post samish18  
            Started by WHICKED, Today, 12:56 PM
            0 responses
            7 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Spiderbird, Today, 12:15 PM
            2 responses
            11 views
            0 likes
            Last Post Spiderbird  
            Started by WHICKED, Today, 12:45 PM
            0 responses
            7 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by FrazMann, Today, 11:21 AM
            2 responses
            8 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Working...
            X