Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert type ‘double’ to ‘bool’

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

    Convert type ‘double’ to ‘bool’

    Please help me with my strategy error.


    The attached chart is a custom made chart the uniquely displays support and resistance. The VMA indicator is the purple dotted line. The JMA indicator is the white solid line. I want to filter out false signals by creating a long condition to exist when:
    1. JMA is rising
    2. Both VMA (purple line) is parallel to JMA (white line)

    Of course, a short signal is the opposite:
    1. JMA is falling
    2. Both VMA (purple line) is parallel to JMA (white line)

    What I’m trying to say is that if the distance between JMA – VMA (in ticks) of the current bar is the same as the distance between JMA – VMA in the previous bar.

    I "remarked out" the rising condition to focus on the problem in the statement.

     
    As an alternative entry condition how can is say if JMA – VMA = x (in ticks), then go long/short??? In other words if JMA minus VMA is X ticks away, then go long/short?


    Your assistance is appreciated.
    Thank you!
    Attached Files

    #2
    dewurster, a single equal sign is an assignment / check, a double equal sign is a comparison for equality, so this would be what you need here.

    In addition you should record your differences between the MA's in variables and then compare those for cleaner coding.

    Then you could also realize your other entry condition needed more easily. For converting to ticksize / rounding of the values you can use the http://www.ninjatrader.com/support/h...trument_ro.htm

    Comment


      #3
      Problem with creating variables

      I now understand what you mean about using the double equals for comparison of one side against the other side. And both sides below now compile OK with the code below:

      // Condition set 1
      if ((JMA(3, 0)[0]) - (VMA(9, 9)[0]) == (JMA(3, 0)[1]) - (VMA(9, 9)[1]))

      However, I'm having trouble creating variables (one for each side) that works. If the left side is variable "bar0" and the right side is variable "bar1" I get the attached error (error - 2).

      How do I say?:

      // Condition set 1
      if bar0 = bar1

      The code for both variables is below:

      // User defined variables (add any user defined variables below)
      private double bar0 = (JMA(3, 0)[0]) - (VMA(9, 9)[0]);
      private double bar1 = (JMA(3, 0)[1]) - (VMA(9, 9)[1]);

      Also, I was wondering if it should be "private double" or "private int". Currently I'm comparing ticks on Oil charts. But if I were to use in on an ES chart would it need to be as an intiger?

      Thank you for your help!

      Comment


        #4
        You would use the same == equals comparison for your assigned double values as well, just remember that if you wish to set a value (like your private double one) then use one equal sign, if you wish to compare for something being equal to another use the double ones.

        doubles should be fine as values, since integer would provide to less resolution for your MA differences likely.

        Comment


          #5
          Originally posted by dewurster View Post
          I now understand what you mean about using the double equals for comparison of one side against the other side. And both sides below now compile OK with the code below:

          // Condition set 1
          if ((JMA(3, 0)[0]) - (VMA(9, 9)[0]) == (JMA(3, 0)[1]) - (VMA(9, 9)[1]))

          However, I'm having trouble creating variables (one for each side) that works. If the left side is variable "bar0" and the right side is variable "bar1" I get the attached error (error - 2).

          How do I say?:

          // Condition set 1
          if bar0 = bar1

          The code for both variables is below:

          // User defined variables (add any user defined variables below)
          private double bar0 = (JMA(3, 0)[0]) - (VMA(9, 9)[0]);
          private double bar1 = (JMA(3, 0)[1]) - (VMA(9, 9)[1]);

          Also, I was wondering if it should be "private double" or "private int". Currently I'm comparing ticks on Oil charts. But if I were to use in on an ES chart would it need to be as an intiger?

          Thank you for your help!
          What is the error code in your log?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          673 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          577 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X