Hướng dẫn cách dùng

Examples of working with Orders
NetTradeX PC
NetTradeX Android
NetTradeX iOS
NetTradeX Mobile
NetTradeX Advisors
Examples of working with Orders

Example*. Placing a pending order.

int Initialize()
{
	return(0);
}
int Run()
{
	double volume = 12000;
	double bid;
	int64 orderID;
	bid = Symbols.LastBid(Chart.Symbol);
	if(bid==0)
	{
		System.Print("Can't update the price!");
		return 0;
	}
	orderID=Orders.SetPending(Chart.Symbol,volume,bid+0.1,opBuy,1,false,bid-0.1,bid+0.2,100);
	if(orderID==0)
	{
		System.Print("Can't open a pending order. Error = "+System.LastError);
		return 0;
	}
	else
	{
		System.Print("The pending order has been successfully opened!");
	}
	return(0);
}
int DeInitialize()
{
	return(0);
}

Example*. Placing an OCO-order.

int Initialize()
{
   return(0);
}
int Run()
{
	int64 orderID;
	double ask = Symbols.LastAsk(Chart.Symbol);
	double bid = Symbols.LastBid(Chart.Symbol);
	if(ask==0 || bid==0)
	{
		System.Print("Can't update the price!");
		return 0;
	}
	double ord1_price = ask + 40*Chart.Point;
	double ord2_price = bid - 40*Chart.Point;
	double ord1_volume = 20000;
	double ord2_volume = 10000;
	orderID=Orders.SetOCO(Chart.Symbol,ord1_price,ord1_volume,opBuy,false,ord2_price,ord2_volume,opSell,true,2);
	if(orderID==0)
	{
		System.Print("Can\'t open an OCO order. Error = "+System.LastError);
		return 0;
	}
	else
	{
		System.Print("The OCO order has been successfully opened!");
	}
	return(0);
}
int DeInitialize()
{
	return(0);
}

* All these examples are recommended to be run in demo accounts only.