以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请把这个指标改为金字塔的  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=52635)

--  作者:站通
--  发布时间:2013/5/30 21:31:10
--  请把这个指标改为金字塔的

variable:tr=0,up=0,dn=0;
N:=10;
M:=1.5;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR1,N);
median:= (high + low) / 2;
up:= median+atr * M;
dn:= median-atr * M;
tr:=if(c>ref(up,1),1,if(c<ref(dn,1),-1,tr));
flag:=tr<0 and ref(tr,1)>0;
flagh:=tr>0 and ref(tr,1)<0;
dn:=if(tr>0 and dn<ref(dn,1),ref(dn,1),dn);
up:=if(tr<0 and up>ref(up,1),ref(up,1),up);
up:=if(flag,median + atr * M,up);
dn:=if(flagh,median - atr * M,dn);
outtr:=tr;
outup:=up;
outdn:=dn;
supertren:if(outtr=1,outdn,outup),colorwhite;
PARTLINE(supertren,tr=1,rgb(200,0,0),tr=-1,rgb(0,200,0)),linethick2;

 

下面的链接里有指标效果

http://www.55188.com/thread-4930383-1-1.html

[此贴子已经被作者于2013-5-30 21:32:41编辑过]

--  作者:jinzhe
--  发布时间:2013/5/31 9:08:42
--  

variable:trn=0,up=0,dn=0;
N:=10;
M:=1.5;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR1,N);
median1:= (high + low) / 2;
up:= median1+atr * M;
dn:= median1-atr * M;
trn:=if(c>ref(up,1),1,if(c<ref(dn,1),-1,tr));
flag:=trn<0 and ref(tr,1)>0;
flagh:=trn>0 and ref(tr,1)<0;
dn:=if(trn>0 and dn<ref(dn,1),ref(dn,1),dn);
up:=if(trn<0 and up>ref(up,1),ref(up,1),up);
up:=if(flag,median1 + atr * M,up);
dn:=if(flagh,median1 - atr * M,dn);
outtr:=trn;
outup:=up;
outdn:=dn;
supertren:if(outtr=1,outdn,outup),colorwhite;
PARTLINE(supertren,trn=1,rgb(200,0,0),trn=-1,rgb(0,200,0)),linethick2;

 


改了一些和金字塔已有函数名相同的变量名


--  作者:站通
--  发布时间:2013/5/31 9:40:00
--  

谢谢 能通过 但显示效果不对


图片点击可在新窗口打开查看此主题相关图片如下:ddd.gif
图片点击可在新窗口打开查看

--  作者:站通
--  发布时间:2013/5/31 9:45:56
--  peak函数信号飘移是否可以通过另外设置变量来解决
这是大智慧的效果
图片点击可在新窗口打开查看此主题相关图片如下:ddd.gif
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2013/5/31 9:54:31
--  

划线函数定义不一样,说一下划线的思路


--  作者:站通
--  发布时间:2013/5/31 10:02:49
--  

这是mt4源码

//+------------------------------------------------------------------+
//|                                        IND_20130219_hbhshany.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright  "xszjg <xszjg@verscm.com> for xxx <xxx@xxx.com> on 20110815"
#property link       "http://www.verscm.com, http://verscm.taobao.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color3 Aqua
#property indicator_color4 Yellow
#property indicator_width3 3
#property indicator_width4 3
extern int N=10;
extern double M=2;
extern int N2=10;
extern double M2=1.5;
double buffer1[];
double dn[];
double up[];
double tr[];
double dn1[];
double up1[];
double zhu1[];
double zhu2[];
int init()
  {

   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,up1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,dn1);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,zhu1);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,zhu2);
   SetIndexBuffer(4,up);
   SetIndexBuffer(5,dn);
   SetIndexBuffer(6,tr);
   SetIndexBuffer(7,buffer1);
   return(0);
  }
int deinit()
  {
   for(int i=0;i<Bars;i++)
   ObjectDelete("juxing"+Time[i]);
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int tr0,tr1;
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   int i=0;
   for (i=MathMin(Bars-5,limit);i>=0; i--)
   {
      buffer1[i]=MathMax(MathMax(High[i]-Low[i],MathAbs(Close[i+1]-High[i])),MathAbs(Close[i+1]-Low[i]));
   }
   for (i=MathMin(Bars-5,limit);i>=0; i--)
   {
      double atr2=iMAOnArray(buffer1,0,N2,0,0,i);
      if((Close[i+1]-Low[i]>atr2*M2 && Close[i]<Open[i]) || (High[i]-Close[i+1]>atr2*M2 && Close[i]>Open[i]))
      {
         zhu1[i]=Open[i];
         zhu2[i]=Close[i];
      }
      if(Close[i]>Close[i+1] && Low[i]>High[i+1])
      drawline("juxing"+Time[i],Time[i+1],High[i+1],Time[i-1],Low[i],Yellow);
      if(Close[i]<Close[i+1] && High[i]<Low[i+1])
      drawline("juxing"+Time[i],Time[i+1],Low[i+1],Time[i-1],High[i],Aqua);
   }
   for (i=MathMin(Bars-5,limit);i>=0; i--)
   {
      double atr=iMAOnArray(buffer1,0,N,0,0,i);
      up1[i]=EMPTY_VALUE;dn1[i]=EMPTY_VALUE;
      double median=(High[i]+Low[i])/2.0;
      up[i]=median+atr*M;
      dn[i]=median-atr*M;
     
      if(i==Bars-5)
      {
         up1[i]=up[i];
         dn1[i]=dn[i];
      }
      else
      {
         if(Close[i]>up1[i+1])
         tr[i]=1;
         else
         {
            if(Close[i]<dn1[i+1])
            tr[i]=-1;
            else
            tr[i]=tr[i+1];
         }
         if(tr[i]==EMPTY_VALUE)
         {
            if(up[i]>up1[i+1])
            up1[i]=up1[i+1];
            else
            up1[i]=up[i];
            if(dn[i]<dn1[i+1])
            dn1[i]=dn1[i+1];
            else
            dn1[i]=dn[i];
         }
         else
         {
            if(tr[i]>0)
            {
               if(dn[i]<dn1[i+1])
               dn1[i]=dn1[i+1];
               else
               dn1[i]=dn[i];
            }
            if(tr[i]<0)
            {
               if(up[i]>up1[i+1])
               up1[i]=up1[i+1];
               else
               up1[i]=up[i];
            }
         }
         if(tr[i]>0 && tr[i+1]<0)
         {
         dn1[i]=dn[i];
         dn1[i+1]=up1[i+1];
         }
         if(tr[i]<0 && tr[i+1]>0)
         {
         up1[i]=up[i];
         up1[i+1]=dn1[i+1];
         }
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+
void drawline(string linename,int t1,double price1,int t2,double price2,int lincolor)
{
if (ObjectFind(linename)<0)
   {
      ObjectCreate(linename, OBJ_RECTANGLE, 0, t1, price1,t2,price2);
      ObjectSet(linename, OBJPROP_COLOR, lincolor);
      ObjectSet(linename,OBJPROP_RAY,false);
   }
else
   {
      ObjectSet(linename, OBJPROP_TIME1,t1);
      ObjectSet(linename, OBJPROP_PRICE1,price1);
      ObjectSet(linename, OBJPROP_TIME2,t2);
      ObjectSet(linename, OBJPROP_PRICE2,price2);
   }
   return;
}


--  作者:jinzhe
--  发布时间:2013/5/31 10:14:02
--  
说思路吧,这个看不懂
--  作者:站通
--  发布时间:2013/5/31 10:28:47
--  

我不会说思路 这是理想论坛的指标 只是用着好用

在本论坛搜了下 有人要求该过此指标http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=52417 但没改成

[此贴子已经被作者于2013-5-31 10:29:07编辑过]

--  作者:站通
--  发布时间:2013/5/31 10:33:17
--  
能不能写两个指标 一个指标画红线 一个指标画绿线 而后叠加两个指标
--  作者:客人
--  发布时间:2015/9/19 2:23:10
--  nikefree
& womens
exactly what had taken way too long? VisaSo the reason Work permit hence fortunate to have recently been crowned one of the most up-to-date Dow customers? nike roshe run hyperfuse rot Consider an appearance. Working permit is often a San francisco bay area structured company providing you with world wide payment methods supporting the money and debit settlement programs of economic associations. This can be a $115 thousand massive limit business that I make a conventional probability shape in order to. As a result, it\'s really a share i individual around my old-fashioned growth reports in contrast to our competitive increase company accounts as this is certainly not the type of investment that has the opportunity to help increase in certain weeks. It is usually not really a high-risk share possibly.锘hy performed Josh Wariboko pick UCLA Ou peut-rrtre un football a break down aggravating improvement Wednesday as soon as Casady offensive lineman Josh Wariboko Alali authorized with UCLA. Not really Ou bien, his homestate university. http://www.nikerundames.nl/ Never Pitt, the shielding country wide champion. Nonetheless UCLA, which usually, we will always be frank, is really a traditional underachiever attending college hockey. We all usually wonder precisely why younger decides to help bypass Ou peut-rrtre un as well as OSU plus head anywhere else. It is just all-natural. In the same way chaussures running free 5.0 femme nike it really is all-natural don\'t ask yourself why a youngster through Tx or maybe Atlanta or even Ca would come to be able to OU or even OSU. The key reason why might not everyone desire to survive where by we survive? I haven\'t got almost any plan the reason Wariboko decided on UCLA. Your dog most likely stood a number of reasons. And also beneficial to them. He had loads of superior solutions, and that he decided a person. One thing to keep in mind is the fact many people are feeling stimulated in a different way. A lot of people usually are motivated by means of is important and even remain all around house. Or perhaps get miles away. Other people never inspired through geography. Many are generally inspired simply by instructors. A few usually are not. A few are motivated through instructors along with persona in addition to interactions. Some are not. A number of are usually encouraged by outfits, females, the weather, facilities. Many elements go into these conclusions. Yet allow me to supply you with my perspective of what could happen to a superior school university student from Oklahoma as well as in other regions which has a trip to UCLA. Larger New york is definitely an fascinating location. It\'s actually not for just anybody. Father christmas Monica Road at times creates a region gal glowing blue,