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

Working with CASE condition

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

    Working with CASE condition

    Hi,

    I'm working with this code:

    switch (PRef)
    {
    case (PRef >= C1):
    Print("Ponemos a partir de la 1 orden");

    EnterLongLimit(0, true,100000, C1, "Compra1");
    EnterLongLimit(0, true,100000, C2, "Compra2");
    EnterLongLimit(0, true,100000, C3, "Compra3");
    EnterLongLimit(0, true,100000, C4, "Compra4");
    break;
    case (PRef < C1):
    Print("Ponemos a partir de la 2 orden");

    EnterLongLimit(0, true,100000, C2, "Compra2");
    EnterLongLimit(0, true,100000, C3, "Compra3");
    EnterLongLimit(0, true,100000, C4, "Compra4");
    break;
    break;
    case (PRef < C2):
    Print("Ponemos a partir de la 3 orden");

    EnterLongLimit(0, true,100000, C3, "Compra3");
    EnterLongLimit(0, true,100000, C4, "Compra4");
    break;
    }

    But the condition in case doesn't works.

    Could you help me?

    #2
    Hi Giger,

    Try if this works:

    switch (PRef >= C1)
    {
    case(true)
    //
    break;

    case(false)
    //
    break;

    }

    Comment


      #3
      Giger, can you try implementing the proposed change by StockFundoo and let us know if this would help?
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        Giger, can you try implementing the proposed change by StockFundoo and let us know if this would help?
        I would like condition in each case.

        Comment


          #5
          I would then just use an if statement - or assign int values for the bool compares you have and use that in your switch, but there's not much coding value in it...
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Originally posted by giger2000 View Post
            I would like condition in each case.
            Use an if construct then: the only comparison condition that is valid for a switch statement is equality. Even then the comparison value must be stated indirectly, as a constant value.

            ref: http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bmartz, 03-12-2024, 06:12 AM
            4 responses
            32 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            12 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X