Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

code für "between" and "and"

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

    code für "between" and "and"

    Hallo,

    I would like to execute the following code:

    if (Math.Abs(SMA(13)[0] / SMA(34)[0]) = "between" 0.99 "and" 1.01;

    {
    Value.Set(1);
    }

    It´s for the MA to filter corresponding stocks.

    How can I do this?
    Thanks for your help!

    Blackburn

    #2
    Originally posted by Blackburn View Post
    Hallo,

    I would like to execute the following code:

    if (Math.Abs(SMA(13)[0] / SMA(34)[0]) = "between" 0.99 "and" 1.01;

    {
    Value.Set(1);
    }

    It´s for the MA to filter corresponding stocks.

    How can I do this?
    Thanks for your help!

    Blackburn
    "Between" means "greater than the smaller value and smaller than the larger value", so just code it that way.
    Code:
    if (entity > 0.99 && entity < 1.01) ...
    where entity is the expression that you are testing: in your case, that SMA ratio.

    Comment


      #3
      Hello Blackburn,

      If I am understanding you correctly, you want your condition to be true when "Math.Abs(SMA(13)[0] / SMA(34)[0]" is between 0.99 and 1.01.

      You may want to try:

      Code:
      if( Math.Abs(SMA(13)[0] / SMA(34)[0]) > 0.99 && Math.Abs(SMA(13)[0] / SMA(34)[0]) < 1.01 )
      {
      		Value.Set(1);
      }
      JCNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X