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 kevinenergy, 02-17-2023, 12:42 PM
            118 responses
            2,777 views
            1 like
            Last Post kevinenergy  
            Started by briansaul, Today, 05:31 AM
            0 responses
            6 views
            0 likes
            Last Post briansaul  
            Started by fwendolynlpxz, Today, 05:19 AM
            0 responses
            4 views
            0 likes
            Last Post fwendolynlpxz  
            Started by traderqz, Yesterday, 12:06 AM
            11 responses
            28 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by PaulMohn, Today, 03:49 AM
            0 responses
            8 views
            0 likes
            Last Post PaulMohn  
            Working...
            X