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 naanku, Today, 07:25 PM
          0 responses
          6 views
          0 likes
          Last Post naanku
          by naanku
           
          Started by milfocs, Today, 07:23 PM
          0 responses
          5 views
          0 likes
          Last Post milfocs
          by milfocs
           
          Started by PaulMohn, Today, 06:59 PM
          0 responses
          7 views
          0 likes
          Last Post PaulMohn  
          Started by bortz, 11-06-2023, 08:04 AM
          48 responses
          1,755 views
          0 likes
          Last Post carnitron  
          Started by Jonker, 04-27-2024, 01:19 PM
          3 responses
          24 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X