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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        49 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        69 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        36 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        96 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        59 views
        0 likes
        Last Post PaulMohn  
        Working...
        X