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

Adding a point system

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

    Adding a point system

    I have a bunch of rules that I want to assign a point system to if the its true and get a total point at the end.

    For example,

    If 3 of my rules are

    Code:
    Close[0] > Open[0]
    VOL1[0] > VOLMA[0]
    ADX1 > 25
    And only 2 of them are true, then total point will be 2 points
    If all 3 are true, then total point will be 3 points, etc.

    Is this possible? If so, how to achieve this?

    Thanks!

    #2
    Hello Ousher,

    Thank you for your reply.

    I would create a counter variable to hold the current number of points in and reset it to zero, then check each rule and if true, add 1 to your counter variable. Then, when you've checked each set of rules, you can get the total points from your counter variable.

    For example:

    Code:
    int myCount = 0;
    
    if (Close[0] > Open[0])
    {
    myCount++;
    }
    
    if (Vol1[0] > VOLMA[0])
    {
    myCount++;
    }
    
    if (ADX1 > 25)
    {
    myCount++;
    }
    
    Print("Total points: " + myCount);
    If two of the three rules are true, you would see "Total Points: 2" printed in the NinjaScript Output window using the above code.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello Ousher,

      Thank you for your reply.

      I would create a counter variable to hold the current number of points in and reset it to zero, then check each rule and if true, add 1 to your counter variable. Then, when you've checked each set of rules, you can get the total points from your counter variable.

      For example:

      Code:
      int myCount = 0;
      
      if (Close[0] > Open[0])
      {
      myCount++;
      }
      
      if (Vol1[0] > VOLMA[0])
      {
      myCount++;
      }
      
      if (ADX1 > 25)
      {
      myCount++;
      }
      
      Print("Total points: " + myCount);
      If two of the three rules are true, you would see "Total Points: 2" printed in the NinjaScript Output window using the above code.

      Please let us know if we may be of further assistance to you.
      THanks! That works.

      Question, is it possible to assign a custom value to each rule/statement instead of everything being 1?

      Comment


        #4
        "myCount++" simply increments by 1. "myCount--" would decrement by 1. And "myCount = myCount + increment" would increment by the value of "increment", and similarly to decrement (using minus, of course). Finally, there's "myCount = amount" where the amount is simply a specific value you choose.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment


          #5
          Originally posted by jeronymite View Post
          "myCount++" simply increments by 1. "myCount--" would decrement by 1. And "myCount = myCount + increment" would increment by the value of "increment", and similarly to decrement (using minus, of course). Finally, there's "myCount = amount" where the amount is simply a specific value you choose.
          Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rodriguesdanny, 05-15-2024, 12:06 PM
          8 responses
          34 views
          0 likes
          Last Post rodriguesdanny  
          Started by warpinator, 05-16-2024, 10:44 AM
          10 responses
          54 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Austiner87, Today, 11:19 AM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by ETFVoyageur, Today, 10:34 AM
          5 responses
          17 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by StefanA, Today, 11:24 AM
          6 responses
          15 views
          0 likes
          Last Post StefanA
          by StefanA
           
          Working...
          X