• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Center Of Gravity Osc. help

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

    Center Of Gravity Osc. help

    Hi,

    I am trying to write the code for John Ehler's CG Osc. It's my first indicator in NinjaScript, I thought I did this right...but (I obviously didn't) it's just drawing a flat zero line.

    here's my code:
    Code:
                double num = 0;
                double den = 0;
                double cog = 0;
    
    for (int barsAgo = 0; barsAgo = Period; barsAgo++)
                    {
                        num = (num + Input[barsAgo]) * (barsAgo + 1);
                        
                        den = num + Input[barsAgo];
                        
                    }
                
                    cog = -1 * (num/dem) ;
    
    
                CGL.Set(cog);
                SL.Set(cog[-1]);
               // HL.Set(Close[0]);

    #2
    Hi negima,

    I suggest you debug your code. Here is a tip about some general practices we advise you take when debugging: http://www.ninjatrader-support.com/v...ead.php?t=3418
    JoshNinjaTrader Customer Service

    Comment


      #3
      Thanks, got it working

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by GussJ, Today, 01:30 PM
      1 response
      2 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by GARZONJ, Today, 12:25 PM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by RandanAL, Today, 11:53 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by yeshujbp, 07-21-2019, 02:40 PM
      2 responses
      35 views
      0 likes
      Last Post omololu
      by omololu
       
      Started by seagraph, Yesterday, 03:27 PM
      1 response
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X