Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

seeing the result of a math method

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

    seeing the result of a math method

    I'm making a filter for a strategy to keep it from taking trades don't meet a minum risk to reward threshold. Here is the method:

    if((htfbullretouchline - bullpbclose) / (bullpbclose - bullstop) <= 3)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    2 questions. Is this syntax correct for dividing the result of the first variable minus the second by the 3rd variable minus the 4th? All 4 of those variables are doubles containing closing prices. Also, how do I see this number from the ninjascript editor. I'm assuming there has to be a way to do this. Please assist.

    #2
    Hello gordongekko,

    Thanks for your post.

    The subtractions would occur first because they are contained with () and then would be divided by the results of () / (). To further isolate that side of the logic you can add another set of () to surround the math (((htfbullretouchline - bullpbclose) / (bullpbclose - bullstop)) <= 3). This ensures that the math is completed before the logic is evaluated.

    To see the number being used, I would advise creating another line that puts the result into another variable and then use Print statements to see the value:

    double myRatio = (htfbullretouchline - bullpbclose) / (bullpbclose - bullstop);
    Print ("R/R = "+myRatio);

    Comment


      #3
      One more question. Is this correct syntax:

      bullstop = MIN(Low, 5)[0] -2*TickSize;

      Comment


        #4
        Hello gordongekko,

        Thanks for your reply.

        MIN(Low, 5)[0] -2*TickSize;

        Will provide the minimum value of the last 5 bars (including current bar) and then subtract 2 ticks.

        Comment

        Latest Posts

        Collapse

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