I need some information

Created at 31 Mar 2020, 17:47
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Capilta's avatar

Capilta

Joined 01.10.2013

I need some information
31 Mar 2020, 17:47


Dear,

I am new coder in cAlgo, I am getting a problem. I can't pass var veriable type into function parameter. 

I below code you will see i can't send 'pendingOrder' to another function as parameter.  current code give this error "Error CS0825: The contextual keyword 'var' may only appear within a local variable declaration"

In below code how can i fix this problem, Please help anyone help me ....

 

      foreach (var pendingOrder in PendingOrders)
       {
             if(pendingOrder.Id>0)
             {
                if (doMagic(pendingOrder) && pendingOrder.SymbolName == Symbol.Name)
                {
                    
                }
             }
       }

        bool doMagic(var order2)
        {
           if(UseNoMagicNumber) return(true);
           if(order2.Label == Magic) return(true);
           return(false);
        }
        

 


@Capilta
Replies

Capilta
01 Apr 2020, 08:29

RE:

Capilta said:

Dear,

I am new coder in cAlgo, I am getting a problem. I can't pass var veriable type into function parameter. 

I below code you will see i can't send 'pendingOrder' to another function as parameter.  current code give this error "Error CS0825: The contextual keyword 'var' may only appear within a local variable declaration"

In below code how can i fix this problem, Please help anyone help me ....

 

      foreach (var pendingOrder in PendingOrders)
       {
             if(pendingOrder.Id>0)
             {
                if (doMagic(pendingOrder) && pendingOrder.SymbolName == Symbol.Name)
                {
                    
                }
             }
       }

        bool doMagic(var order2)
        {
           if(UseNoMagicNumber) return(true);
           if(order2.Label == Magic) return(true);
           return(false);
        }
        

 

 

 

Is anyone help me 

 

 


@Capilta

PanagiotisCharalampous
02 Apr 2020, 08:32

Hi Capilta,

You cannot use var as a parameter type in a method variable declaration. The correct type is PendingOrder.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous