• 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 aligator, Today, 03:23 PM
            4 responses
            9 views
            0 likes
            Last Post aligator  
            Started by RtelTrade, Today, 01:27 PM
            1 response
            24 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by RolloHarper, Today, 12:59 PM
            2 responses
            22 views
            0 likes
            Last Post NinjaTrader_Jermaine  
            Started by tvaughan4, Today, 01:02 PM
            2 responses
            32 views
            0 likes
            Last Post tvaughan4  
            Started by NinjaTrader_Brandon, Today, 01:19 PM
            0 responses
            59 views
            0 likes
            Last Post NinjaTrader_Brandon  
            Working...
            X