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

logic problem

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

    logic problem

    I have the following if statement:-

    if(High[0] >= hPiv - Math.Max(2*TickSize,(hPiv-lPiv)*0.1) && Close[0] > lPiv + 1/2 * hPiv-lPiv && pStop.StopPrice < (lPiv + 1/2 * hPiv-lPiv))

    And i couldn't understand why it was equating to false when it should be true so I debugged with VS and can see that this part of the if statement is equating to false :-

    pStop.StopPrice < (lPiv + 1/2 * hPiv-lPiv)

    where

    pStop.StopPrice = 140.46
    lPiv = 140.49
    hPiv = 140.96



    This makes no sense can anyone tell em why this is?

    I have attached a screenshot of VS.
    Attached Files

    #2
    Would be the result of a precision and bracing issue, please try for example instead with -

    pStop.StopPrice < (lPiv + (0.5 * (hPiv-lPiv))))

    1/2 is dividing int's > so just 0...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand, good to know. So if I need to do 1/3 can i use 1.0/3.0 to get over the int problem?

      Comment


        #4
        Right, that would work as well > as you divide doubles then.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WHICKED, Today, 12:45 PM
        2 responses
        16 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by GussJ, 03-04-2020, 03:11 PM
        15 responses
        3,272 views
        0 likes
        Last Post xiinteractive  
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        2 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X