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 Touch-Ups, Today, 10:36 AM
      0 responses
      1 view
      0 likes
      Last Post Touch-Ups  
      Started by geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,289 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Working...
      X