刚接触金字塔,软件好像没直接提供止盈止损函数,
请示例几个 固定止盈止损和移动止盈止损的范例,谢谢!
此代码中包含了持有空仓的止盈止损。
if holding<0 and enterbar>0 then ... //这段就是计算空头的最大盈利的
此代码中包含了持有空仓的止盈止损。
if holding<0 and enterbar>0 then ... //这段就是计算空头的最大盈利的
但是代码最后的止盈止损只有SELL指令,
止损:SELL(win < -2,0);
止赢:SELL(win2 >= 60 and openprofit > 0, 0);
怎么没有空头的止盈止损SELLSHORT指令?
或是说我理解错了?
后面那段改为:
多头止损:SELL(win < -2 and holding>0,0,market);
空头止损:SELLshort(win < -2 and holding<0,0,market);
多头止赢:SELL(win2 >= 60 and openprofit > 0 and holding>0, 0,market);
空头止赢:SELLshort(win2 >= 60 and openprofit > 0 and holding<0, 0,market);
还有我把这两段代码简化成下面的代码:测试结果却不一样,简化的逻辑有问题吗?
原代码:
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
if holding < 0 and enterbars > 0 then
begin
win:=(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
--------------------------------------------------------------------------
简化后:
if holding <> 0 and enterbars > 0 then begin
win:=abs(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then begin
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
end
DTYDZS:=(HHV(H,ENTERBARS)-CLOSE)/AVGENTERPRICE>=0.1;
KTYDZS:=(CLOSE-LLV(L,ENTERBARS))/AVGENTERPRICE>=0.1;
SELL(DTYDZS,0,MARKET);
SELLSHORT(KTYDZS,0,MARKET);
直接用这个,别去自己记录变量了
交易系统-功能模块范例
这里有固定和移动的范例,而且都是很简单的处理方法
if holding <> 0 and enterbars > 0 then begin
win:=abs(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
多了一个组begin。。end
if holding <> 0 and enterbars > 0 then begin
win:=abs(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
多了一个组begin。。end
我原来也是这么简化,但是一测试结果和原范例不一样,就加了一组begin。。end,结果还是不一样!
版主麻烦你也测试对比一下结果!谢谢!