咨詢內(nèi)容:
策略倉(cāng)位管理
策略引用商品指數(shù)日線跨周期數(shù)據(jù)指標(biāo)DMI+AXD>(55)同時(shí) 下穿-AXD 平倉(cāng)(止盈多空全部平)/或其他指標(biāo)
1:止盈條件平倉(cāng) (比如止盈條件DMI)
2:止盈條件平倉(cāng)后特別標(biāo)記平倉(cāng)方向!多單平倉(cāng)后只能開空單,空單開出后取消限制條件。多空同樣原理。
這個(gè)代碼要怎么實(shí)現(xiàn)呢?
?
?來(lái)源: m.weiqiv.net.cn
金字塔資深技術(shù):
1.跨指標(biāo)引用參考:
http://www.weistock.com/bbs/dispbbs.asp?boardid=17&Id=162644
參考這個(gè)函數(shù)說(shuō)明
2.用全局變量處理。在每次止盈平倉(cāng)后,重置全局變量的值。后續(xù)開倉(cāng)都要先判斷下這個(gè)全局變量的值。
[PEL]
復(fù)制代碼ma3:ma(close,3);
ma5:ma(c,5);
ma10:ma(close,10);
kd:cross(ma3,ma5);
kk:cross(ma10,ma5);
VARIABLE:ct:=0;
if kd and ct>=0 and holding=0 then
begin
buy(1,1,market);
ct:=0;
end
if kk and ct<=0 and holding=0 then
begin
buyshort(1,1,market);
ct:=0;
end
if (c-AVGENTERPRICE)>=5*MINDIFF and holding>0 then
begin
多止盈:sell(1,0,market);
ct:=-1;
end
if (AVGENTERPRICE-c)>=5*MINDIFF and holding<0 then
begin
空止盈:sellshort(1,0,market);
ct:=1;
end
參考這里全局變量的使用
技術(shù)交流:
if kd and ct>=0 and holding=0 then
begin
buy(1,1,market);
ct:=0;
end
if kk and ct<=0 and holding=0 then
begin
buyshort(1,1,market);
ct:=0;
end
這個(gè)里面的 CT>=0和CT<=0 ,這個(gè)沒(méi)有看懂,后面的多止盈和空止盈的話,跟我的根據(jù)商品指數(shù)引用編寫代碼一模板一樣的嗎?,
?
技術(shù)交流:
ct>=0 意思是開倉(cāng)條件默認(rèn)需要滿足:1.首次開倉(cāng) 。ct自然是0? ???2.前面ct是1 說(shuō)明多止盈了,-1 是空止盈了。
“跟我的根據(jù)商品指數(shù)引用編寫代碼一模板一樣的嗎?” 我這個(gè)止盈條件隨便寫的。你只要改成你自己的止盈條件就行了。