Phương pháp giao dịch chống lại xu hướng

Tác giả:đồng xu989, Ngày: 2019-07-16 14:57:23
Tags:Thương mại rùa

Phong cách đánh cá, đơn giản là đánh cá, là một chiến lược giao dịch ngược lại với luật giao dịch cá, nó lợi dụng các khuyết điểm của giao dịch theo xu hướng (đặc biệt là cách đánh cá) trong nhiều bước đột phá giả để kiếm lợi nhuận (làm cá trở thành một con cá).

Vào đầu những năm 1980, một nhóm các nhà giao dịch rất nổi tiếng có tên là Bồ-tát Bồ-tát. Richard Dennis, một bậc thầy thị trường nổi tiếng đã tạo ra cái tên thú vị này khi đào tạo một nhóm các nhà giao dịch mới. Richard tin rằng việc đào tạo các nhà giao dịch thực sự giống như nuôi bồ-tát ở Singapore.

Hơn hai mươi năm sau, phương pháp này không còn là một bí mật nữa, và nhiều người đã biết nó. Tuy nhiên, tại sao vẫn có ít người thành công trong giao dịch bằng nó? Đó là bởi vì các chiến lược theo xu hướng thường phải chịu đựng sự đảo ngược lớn và lâu dài. Nhiều nhà đầu tư hoặc nhà giao dịch không có đủ vốn hoặc sẵn sàng chịu đựng những lỗ lâu dài này.

Lý do mà hầu hết các chiến lược không thể giữ lợi nhuận là vì một khi nhiều người tham gia thị trường sử dụng chúng, khả năng lợi nhuận của các chiến lược này sẽ bị suy giảm. Đây là cách thị trường sử dụng để cân bằng những hiện tượng không cân bằng. Warsky tìm thấy nhiều kết quả thành công và lợi nhuận hơn bằng cách giao dịch ngược lại với phương pháp hải tặc.

Các quy tắc giao dịch cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu cổ phiếu

Các đặc điểm chiến lược: Hỗ trợ theo dõi xu hướng ở bất kỳ cấp độ nào (tháng K, giờ K, ngày K, tuần K, v.v.) Hỗ trợ các cặp giao dịch tùy chọn (ETH/BTC, BSV/BTC, v.v.) Hỗ trợ các sàn giao dịch tùy chọn Báo cáo chiến lược chi tiết (bao gồm tình trạng chiến lược, lịch sử giao dịch, v.v.) Hỗ trợ gần 10 tham số cá nhân hóa tùy chỉnh

Tải về botvs_tools:https://www.pcclean.io/9o7u


var strategy_version="1.0.0.0(new release 仅供学习研究使用,实盘后果自负。实盘策略访问http://pcclean.io/quant  )";

var price_n={Futures_OKCoin_BSV_USD:2};
var num_n={Futures_OKCoin_BSV_USD:0};
var minestbuy={Futures_OKCoin_BSV_USD:1};
var price_step={Futures_OKCoin_BSV_USD:0.05};
var contract_min={Futures_OKCoin_BSV_USD:10};
var wait_ms=3000;
var max_wait_order=15000;
var max_positions=4;

//gloabl variables
var positions_duo=[];
var positions_kong=[];
var total_loop=0;
var bet_duo=0;
var bet_kong=0;

function main(){
	Log("strategy_version="+strategy_version);
	$.set_params(price_n,num_n,minestbuy,price_step,wait_ms,max_wait_order);
	while(true){
		var exname=exchange.GetName();
		var currency=exchange.GetCurrency();
		var account=_C(exchange.GetAccount);
		var ticker=_C(exchange.GetTicker);
		var depth=_C(exchange.GetDepth);		
		var sell1=depth.Asks[0].Price;
		var buy1=depth.Bids[0].Price;
		var records=_C(exchange.GetRecords);
		if (records.length<=50){
			Log("records.length无效,跳过此次执行...");
			Sleep(wait_ms);
			continue;
		}
		var atr = TA.ATR(records, 20);
		if (atr.length<=1){
			Log("atr.length无效,跳过此次执行...");
			Sleep(wait_ms);
			continue;
		}
		var N=atr[atr.length-1];
		var position_unit=account.Stocks/(max_positions*2);
		var highest20=TA.Highest(records, 20, 'High');
		var lowest20=TA.Lowest(records, 20, 'Low');
		var highest10=TA.Highest(records, 10, 'High');		
		var lowest10=TA.Lowest(records, 10, 'Low');
		
		//建仓
		if (positions_duo.length===0){
			if (sell1<=lowest20){
				var heyuefenshu=_N(position_unit*sell1/contract_min[$.get_exchange_id(exchange)],0);
				exchange.SetDirection("buy");
				var dealamount=$.perform_limited_order("buy",exchange,sell1,heyuefenshu,false,"futures","buy");
				if (dealamount>0){
					var postion = {
						amount:dealamount, 
						price:sell1,
						stoploss_price:sell1-2.5*N,
						stopwin_price:sell1+2.5*N,
						};
					positions_duo.push(postion);
					bet_duo=1;
				}
			}
		}
		if (positions_kong.length===0){
			if (buy1>=highest20){
				var heyuefenshu=_N(position_unit*buy1/contract_min[$.get_exchange_id(exchange)],0);
				exchange.SetDirection("sell");
				var dealamount=$.perform_limited_order("buy",exchange,buy1,heyuefenshu,false,"futures","sell");
				if (dealamount>0){
					var postion = {
						amount:dealamount, 
						price:buy1,
						stoploss_price:buy1+2.5*N,
						stopwin_price:buy1-2.5*N,
						};
					positions_kong.push(postion);
					bet_kong=1;
				}
			}
		}
		//加仓
		if (positions_duo.length>0){
			var last_price=positions_duo[positions_duo.length-1].price;
			if (bet_duo<max_positions){
				if (last_price-sell1>=0.5*N){
					var heyuefenshu=_N(position_unit*sell1/contract_min[$.get_exchange_id(exchange)],0);
					exchange.SetDirection("buy");
					var dealamount=$.perform_limited_order("buy",exchange,sell1,heyuefenshu,false,"futures","buy");
					if (dealamount>0){
						var postion = {
							amount:dealamount, 
							price:sell1,
							stoploss_price:sell1-2.5*N,
							stopwin_price:sell1+2.5*N,
							};
						positions_duo.push(postion);
						bet_duo+=1;
					}
				}
			}
		}
		if (positions_kong.length>0){
			var last_price=positions_kong[positions_kong.length-1].price;
			if (bet_kong<max_positions){
				if (buy1-last_price>=0.5*N){
					var heyuefenshu=_N(position_unit*buy1/contract_min[$.get_exchange_id(exchange)],0);
					exchange.SetDirection("sell");
					var dealamount=$.perform_limited_order("buy",exchange,buy1,heyuefenshu,false,"futures","sell");
					if (dealamount>0){
						var postion = {
							amount:dealamount, 
							price:buy1,
							stoploss_price:buy1+2.5*N,
							stopwin_price:buy1-2.5*N,
							};
						positions_kong.push(postion);
						bet_kong+=1;
					}
				}
			}
		}
		//止损
		if (positions_duo.length>0){
			var positions_duo_new=[];
			for (var i=0; i < positions_duo.length; i++){
				if (buy1<=positions_duo[i].stoploss_price){
					exchange.SetDirection("closebuy");
					$.perform_limited_order("sell",exchange,buy1,positions_duo[i].amount,true,"futures","closebuy");
				}else{
					positions_duo_new.push(positions_duo[i]);
				}
			}
			positions_duo=positions_duo_new;
		}
		if (positions_kong.length>0){
			var positions_kong_new=[];
			for (var i=0; i < positions_kong.length; i++){
				if (sell1>=positions_kong[i].stoploss_price){
					exchange.SetDirection("closesell");
					$.perform_limited_order("sell",exchange,sell1,positions_kong[i].amount,true,"futures","closesell");
				}else{
					positions_kong_new.push(positions_kong[i]);
				}
			}
			positions_kong=positions_kong_new;
		}
		//止盈
		if (positions_duo.length>0){
			var positions_duo_new=[];
			for (var i=0; i < positions_duo.length; i++){
				if (buy1>=positions_duo[i].stopwin_price){
					exchange.SetDirection("closebuy");
					$.perform_limited_order("sell",exchange,buy1,positions_duo[i].amount,true,"futures","closebuy");
				}else{
					positions_duo_new.push(positions_duo[i]);
				}
			}
			positions_duo=positions_duo_new;
		}
		if (positions_kong.length>0){
			var positions_kong_new=[];
			for (var i=0; i < positions_kong.length; i++){
				if (sell1<=positions_kong[i].stopwin_price){
					exchange.SetDirection("closesell");
					$.perform_limited_order("sell",exchange,sell1,positions_kong[i].amount,true,"futures","closesell");
				}else{
					positions_kong_new.push(positions_kong[i]);
				}
			}
			positions_kong=positions_kong_new;
		}
		//清仓
		if (positions_duo.length>0){
			if (buy1>=highest10){
				for (var i=0; i < positions_duo.length; i++){
					exchange.SetDirection("closebuy");
					$.perform_limited_order("sell",exchange,buy1,positions_duo[i].amount,true,"futures","closebuy");
				}
				positions_duo=[];
			}
		}
		if (positions_kong.length>0){
			if (sell1<=lowest10){
				for (var i=0; i < positions_kong.length; i++){
					exchange.SetDirection("closesell");
					$.perform_limited_order("sell",exchange,sell1,positions_kong[i].amount,true,"futures","closesell");
				}
				positions_kong=[];
			}
		}
		//交易所强平
		var current_ok_position=_C(exchange.GetPosition);//must update here
		if (current_ok_position.length===0){
			positions_duo=[];
			positions_kong=[];
		}
		
		//chart
		var table1={type: 'table', title: '期货仓位', cols: ['交易所','持仓量','冻结量','持仓均价','实现盈余','类型','合约代码'], rows: []};
		var table2={type: 'table', title: '跟踪仓位', cols: ['交易所','类型','数量','价格','止损价','止盈价'], rows: []};
		for (var i=0; i < current_ok_position.length; i++){
				table1.rows.push([exname,
				current_ok_position[i].Amount,
				current_ok_position[i].FrozenAmount,
				current_ok_position[i].Price,
				current_ok_position[i].Profit,
				current_ok_position[i].Type,
				current_ok_position[i].ContractType]);
			}
		for (i=0; i<positions_duo.length; ++i){
			table2.rows.push([exname,'做多',positions_duo[i].amount,positions_duo[i].price,
			positions_duo[i].stoploss_price,positions_duo[i].stopwin_price]);
		}
		for (i=0; i<positions_kong.length; ++i){
			table2.rows.push([exname,'做空',positions_kong[i].amount,positions_kong[i].price,
			positions_kong[i].stoploss_price,positions_kong[i].stopwin_price]);
		}
		LogStatus(
					'`' + JSON.stringify([table1,table2])+'`'+'\n'+
					'买多仓位:'+positions_duo.length+'\n'+
					'买空仓位:'+positions_kong.length+'\n'+
					'交易单位: '+position_unit+'\n'+
					'highest20: '+highest20+'\n'+
					'highest10: '+highest10+'\n'+
					'lowest20: '+lowest20+'\n'+
					'lowest10: '+lowest10+'\n'+
					'♜轮询次数: '+total_loop+'\n'+
					'♜更新时间: '+$.get_ChinaTimeString()+'\n'+
					'♜定制策略联系微信: alinwo(验证消息:botvs)。实盘策略访问: http://pcclean.io/quant'+'\n'
				  );
		if (total_loop%300===0){
			LogProfit(account.Stocks);
		}
		
		Sleep(wait_ms);
		total_loop++;
	}
}

Có liên quan

Thêm nữa

mwh264Thật thú vị.