• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 seagraph, Today, 03:27 PM
            0 responses
            11 views
            0 likes
            Last Post seagraph  
            Started by dedouglas, Today, 02:54 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by elkhatabi, 08-01-2019, 06:36 PM
            5 responses
            53 views
            0 likes
            Last Post NinjaTrader_RyanL  
            Started by mr_trade, Today, 01:01 PM
            4 responses
            19 views
            0 likes
            Last Post mr_trade  
            Started by Renorail, Today, 12:31 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Working...
            X