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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        30 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        17 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        9 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        16 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        19 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X