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

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 mjairg, 07-20-2023, 11:57 PM
      3 responses
      213 views
      1 like
      Last Post PaulMohn  
      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      544 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      3 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      12 views
      0 likes
      Last Post XXtrader  
      Started by Waxavi, Today, 02:10 AM
      0 responses
      7 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Working...
      X