欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]图表里运行挺好的全局变量到后台就乱了?

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有7824人关注过本帖平板打印复制链接

主题:[求助]图表里运行挺好的全局变量到后台就乱了?

帅哥哟,离线,有人找我吗?
yukizzc
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:21598 积分:0 威望:0 精华:1 注册:2010/7/31 16:35:30
  发帖心情 Post By:2020/4/24 9:49:46    Post IP:180.169.30.6[只看该作者]

TRR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//真实波幅
ATR:=ref(MA(TRR,20),1); //波幅的20日均线
unit:(tasset*0.01)/(MULTIPLIER*atr);

INPUT:X(20,1,100,5);
X周期高点:=REF(HHV(H,X),1);//X是参数,自行调整
X周期低点:=REF(LLV(L,X),1);

//记录建仓的atr

GLOBALVARIABLE:entry=0;
//记录交易次数a
GLOBALVARIABLE:num=0;
//入场条件:
开多条件:=High>=X周期高点 and barpos>20;
开空条件:=Low<=X周期低点 and barpos>20;

//建立头寸
if 开多条件 and tholding=0 then
begin
 tbuy(1,unit,mkt);
 entry:=atr;
 num:=1;
end

if 开空条件 and tholding=0 then
begin
 tbuyshort(1,unit,mkt);
 entry:=atr;
 num:=1;
end


//每盈利0.5个atr加仓,最多加4次
if tbuyholding(1)>0 and high>tenterprice+0.5*entry and num<4 and tsellholding(1)=0 then
begin
 tbuy(1,unit,mkt),ALLOWREPEAT;
 num:=num+1;
end

if tsellholding(1)>0 and low<tenterprice-0.5*entry and num<4 and tbuyholding(1)=0 then
begin
 tbuyshort(1,unit,mkt),ALLOWREPEAT;
 num:=num+1;
end

 

//止损2个atr
if tbuyholding(1)>0 and low<tenterprice-2*entry  then
begin
 tsell(1,tbuyholding(1),mkt);
end
if tsellholding(1)>0 and high>tenterprice+2*entry  then
begin
 tsellshort(1,tsellholding(1),mkt);
end

//破短期高低位,平仓出场
INPUT:Y(10,1,100,5);
Y周期高点:=REF(HHV(H,10),1);
Y周期低点:=REF(LLV(L,10),1);
if low<Y周期低点 and tbuyholding(1)>0 then
begin
 tsell(1,tbuyholding(1),mkt);
end
if high>Y周期高点 and tsellholding(1)>0 then
begin
 tsellshort(1,tsellholding(1),mkt);
end


 回到顶部
总数 47 1 2 3 4 5 下一页