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?

      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...

          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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            666 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            377 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X