给模型加入交易量控制

CurrentContracts
获得当前持仓的持仓合约数。

Params
	Numeric length(30);
	// 交易手数
	Numeric lots(6);
Vars
	// 最高价
	Numeric hp;
	// 最低价
	Numeric lp;
	// 平均成交量
	Numeric average_v; 
Begin
	hp = Highest(High, length);
	lp = Lowest(Low, length);
	// 近三根k线的平均成交量
	average_v = Average(V, 3);
	// 最高价突破,做多单, 建仓次数小于5,成交量放大近3根k线平均值3倍
	If (H == hp And CurrentEntries < 2 And V > 1.5 * average_v) 
	{
		Buy(lots, Close);
	}
	// 最低价突破,做反手单
	If (L == lp)
	{
		// 持空单返回负数,所以使用绝对值
		Sell(Abs(CurrentContracts()), Close);
	}
End

猜你喜欢

转载自blog.csdn.net/bus_lupe/article/details/85010369