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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      87 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      106 views
      0 likes
      Last Post CarlTrading  
      Working...
      X