Argument out of range exeption

Created at 06 Mar 2013, 22:55
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!
condor's avatar

condor

Joined 28.02.2013

Argument out of range exeption
06 Mar 2013, 22:55


Hi,

A got that strange error : Argument out of range exeption in OnTick()

I think it could come frome that code but i'm not sure :

if(Account.PendingOrders.Count > 0)
            {
	            for(int i =0 ; i<= Account.PendingOrders.Count;i++)
			    {
			   	    Trade.DeletePendingOrder(Account.PendingOrders[i]);
			    }
		    }
            
            if(_position == null)
            {
            	Trade.CreateBuyStopOrder(Symbol, Volume, buyPrice, SLBuy, TPBuy, null);
            	Trade.CreateSellStopOrder(Symbol, Volume, sellPrice, SLSell, TPSell, null);
            }

@condor
Replies

condor
06 Mar 2013, 23:42

SOLVED !!!

I just needed to change this :

for(int i =0 ; i<= Account.PendingOrders.Count;i++)

to this :

for(int i =0 ; i< Account.PendingOrders.Count;i++)

 


@condor