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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 几个止盈的源代码

   

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


  共有8392人关注过本帖树形打印复制链接

主题:几个止盈的源代码

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


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
几个止盈的源代码  发帖心情 Post By:2011/3/7 15:14:48    Post IP:112.65.22.175[只看该作者]

1.

 

strata:=10;
If(
C=PREV,
PREV,
If(
((Ref(C,-1)<PREV)AND (C<PREV)),
Min(PREV,C*(1+strata/100)),
If(
(Ref(C,-1)>PREV) AND (C>PREV),
Max(PREV,C*(1-strata/100)),
If(
C>PREV,
C*(1-strata/100),
C*(1+strata/100)))))

 

 

2.

 

If(cum(1)=1,
{then} Close,
{else} If((C*1.1) <= PREV,
{then}(C*1.1),
{else} PREV));

 

3.

 

If(cum(1)=1,
{then} Close,
{else} If((C*1.1) <= PREV,
{then}(C*1.1),
{else} PREV));

 

4.

 

Volatility Stop (Long)

Pds1:= Input("ATR Lookback?",2,100,10);
Mult:= Input("ATR Multiplier?",1,20,3);
Pds2:= Input("HHV Lookback?",2,100,20);
PrelimStop:= HHV(H,Pds1) - ATR(Pds1)*Mult;
ActualStop:= HHV(PrelimStop,Pds2);
ActualStop


Volatility Stop (Short)

Pds1:= Input("ATR Lookback?",2,100,10);
Mult:= Input("ATR Multiplier?",1,20,3);
Pds2:= Input("LLV Lookback?",2,100,20);
PrelimStop:= LLV(L,Pds1) + ATR(Pds1)*Mult;
ActualStop:= LLV(PrelimStop,Pds2);
ActualStop

 


 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 15:15:53    Post IP:112.65.22.175[只看该作者]

可以改变成金字塔的PEL格式


 回到顶部
帅哥哟,离线,有人找我吗?
msy0985
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:115 积分:829 威望:0 精华:0 注册:2010/9/9 11:50:11
  发帖心情 Post By:2011/3/7 15:30:17    Post IP:113.228.17.253[只看该作者]

现在金字塔能用这些不?

 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 15:32:26    Post IP:112.65.22.175[只看该作者]

periodsshort:=Input("periods if short",1,50,10);
periodslong:=input("periods if long",1,50,10);

HHV(H,periodsshort)-atr(periodsshort);
{stop loss level for short positions}
LLV(L,periodslong)+ATR(periodslong);
{stoploss level for long positions}


 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 15:39:03    Post IP:112.65.22.175[只看该作者]

Uptrend Signal

Peak(1,If(H>Ref(HHV(H,4),-1),Ref(LLV(L,4),-1),0),1) <>
Ref(Peak(1,If(H>Ref(HHV(H,4),-1),Ref(LLV(L,4),-1),0),1),-1)
Downtrend Signal

Peak(1,If(L<Ref(LLV(L,4),-1),Ref(HHV(H,4),-1),0),1) <>
Ref(Peak(1,If(L<Ref(LLV(L,4),-1),Ref(HHV(H,4),-1),0),1),-1)
Uptrend / Downtrend Signals

If(BarsSince(Fml("Downtrend Signal")) <BarsSince(Fml("Uptrend Signal")),
{then} Ref(HHV(H,4),-1), {else} Ref(LLV(L,4),-1))

 回到顶部
帅哥哟,离线,有人找我吗?
fly
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:5082 积分:17642 威望:0 精华:6 注册:2010/7/15 9:05:58
  发帖心情 Post By:2011/3/7 16:00:08    Post IP:58.246.57.26[只看该作者]

楼主的CUM(1)和PREV是什么意思 



金字塔—专业程序化交易量化投资平台

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 16:03:58    Post IP:112.65.22.175[只看该作者]

MetaStock  的代码

 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 16:47:03    Post IP:112.65.22.175[只看该作者]

CUM是累计的意思

PREV是类似公式重复计算前一根的意思

[此贴子已经被作者于2011-3-7 16:53:45编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
KKSH
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:24 积分:112 威望:0 精华:0 注册:2011/2/15 21:08:00
  发帖心情 Post By:2011/3/7 16:50:41    Post IP:112.65.22.175[只看该作者]

Cumulate(累积)
SYNTAX        cum( DATA ARRAY )

FUNCTION        Calculates a cumulative sum of the DATA ARRAY from the first period in the chart.
EXAMPLE        The formula "cum( 1 )" calculates an indicator that rises one point for each day since the beginning of the chart; the formula "cum( C )" calculates the cumulative total of all closing prices from the beginning of the chart.

 

 


 

PREV
The PREV constant allows you to create self-referencing formulas.  A self referencing formula is one that is able to reference the "previous" period's value of itself.
For example, the following is an example of a self referencing formula:
((H+L+C)/3) + PREV
This simple formula divides the high, low, and closing prices by 3 and then adds this value to yesterday's value of the ((H+L+C)/3).
The calculation of the popular indicator On Balance Volume illustrates the use of the PREV function.

(if(c>ref(c,-1),1,-1)*volume)+PREV
Although On Balance Volume can be calculated without the use of the PREV function, an exponential moving average cannot (other than using the mov() function).  The following formula shows how a 18% exponential moving average (approximately 10-periods) is calculated using the PREV function.
(close*0.18)+(PREV*0.82)

[此贴子已经被作者于2011-3-7 16:50:54编辑过]

 回到顶部
美女呀,离线,留言给我吧!
xian_0_9
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 BOO
等级:论坛游民 帖子:378 积分:1856 威望:0 精华:0 注册:2010/1/25 18:04:12
  发帖心情 Post By:2011/3/7 23:57:31    Post IP:119.114.112.231[只看该作者]

能介绍一下4个都是什么意思么


 回到顶部
总数 11 1 2 下一页