设为首页收藏本站

 找回密码
 注册
查看: 2955|回复: 0
打印 上一主题 下一主题

关于用户函数parabolicSAR的解释 [复制链接]

Rank: 5Rank: 5

精华
0
UID
28852
积分
651
帖子
153
主题
42
阅读权限
60
注册时间
2011-3-15
最后登录
2022-1-5
跳转到指定楼层
1#
发表于 2011-3-28 14:16:51 |只看该作者 |倒序浏览
有劳管理员大哥帮忙解释下这个用户函数的代码,有的地方我看不懂。最好每句标上注释,,感激不尽//------------------------------------------------------------------------
// 简称: ParabolicSAR
// 名称: 求抛物线转向
// 类别: 用户函数
// 类型: 内建函数
// 输出: 数值型
//------------------------------------------------------------------------

Params
        Numeric AfStep(0.02);
        Numeric AfLimit(0.2);
        NumericRef oParClose;
        NumericRef oParOpen;
        NumericRef oPosition;
        NumericRef oTransition;
Vars
        NumericSeries Af(0);       
        NumericSeries ParOpen(0);
        NumericSeries Position(0);       
        NumericSeries HHValue(0);
        NumericSeries LLValue(0);
Begin
        If (CurrentBar == 0)
        {
                Position = 1 ;
                oTransition = 1 ;
                Af = AfStep ;
                HHValue = High ;
                LLValue = Low ;               
                oParClose = LLValue ;
                ParOpen = oParClose + Af * ( HHValue - oParClose) ;
                If (ParOpen > Low)
                {
                        ParOpen = Low ;
                }
        }Else
        {       
                oTransition = 0 ;       
                If (High > HHValue[1])
                {
                        HHValue = High;
                }Else
                {
                        HHValue = HHValue[1];
                }
               
                If (Low < LLValue[1])
                {
                        LLValue = Low;
                }Else
                {
                        LLValue = LLValue[1];
                }
               
                If ( Position[1] == 1)
                {
                        If ( Low <= ParOpen[1])
                        {
                                Position = -1 ;
                                oTransition = -1 ;                               
                                oParClose = HHValue ;
                                HHValue = High ;
                                LLValue  = Low ;
       
                                Af = AfStep ;
                                ParOpen = oParClose + Af * ( LLValue - oParClose ) ;
                                       
                                If (ParOpen < High)
                                {
                                        ParOpen = High ;
                                }
                               
                                If (ParOpen < High[1])
                                {
                                        ParOpen = High[1] ;
                                }
                        }Else
                        {
                                Position = Position[1];
                                oParClose = ParOpen[1] ;                                       
                                If (HHValue > HHValue[1] and Af[1] < AfLimit )
                                {
                                        If(Af[1]+AfStep > AfLimit)
                                        {
                                                Af = AfLimit ;
                                        }Else
                                        {
                                                Af = Af[1]+AfStep;
                                        }                               
                                       
                                }Else
                                {
                                        Af = Af[1];
                                }       
                                ParOpen = oParClose + Af * ( HHValue - oParClose ) ;                               
       
                                If (ParOpen > Low)
                                {
                                        ParOpen = Low ;
                                }
                               
                                If (ParOpen > Low[1])
                                {
                                        ParOpen = Low[1];
                                }
                        }
                }Else
                {
                        If (High >= ParOpen[1])
                        {
                                Position = 1 ;
                                oTransition = 1 ;
                               
                                oParClose = LLValue ;
                                HHValue = High ;
                                LLValue  = Low ;
                               
                                Af = AfStep ;
                                ParOpen = oParClose + Af * ( HHValue - oParClose) ;
                                If (ParOpen > Low)
                                {
                                        ParOpen = Low ;
                                }
                               
                                If (ParOpen > Low[1])
                                {
                                        ParOpen = Low[1];
                                }
                        }Else
                        {
                                Position = Position[1];
                                oParClose = ParOpen[1];
                                       
                                If (LLValue < LLValue[1] And Af[1] < AfLimit )
                                {
                                        If(Af[1]+AfStep > AfLimit)
                                        {
                                                Af = AfLimit ;
                                        }Else
                                        {
                                                Af = Af[1]+AfStep;
                                        }
                                }Else
                                {
                                        Af = Af[1];
                                }
                                ParOpen = oParClose + Af * ( LLValue - oParClose ) ;
       
                                If (ParOpen < High)
                                {
                                        ParOpen = High ;
                                }
                               
                                If (ParOpen < High[1])
                                {
                                        ParOpen = High[1] ;
                                }
                        }
                }       
        }       
       
        oParOpen = ParOpen;
        oPosition = Position;
        Return True;
End

//------------------------------------------------------------------------
代码里面我不明白HHValue和LLValue分别代表什么意思,还有paropen代表什么。。看不懂。劳驾 每句注释下  感激不尽感激不尽啊
您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-23 20:50

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部