编码帮助 - 页 201

 
Slow Moe:
你好,我想问一下,是否有可能改写这个指标,使其只显示箭头,而在蜡烛图上显示出来?谁能帮我一下,或者帮我编码一下?

问候

fxmtn-test.mq4

慢速

试着这样做

附加的文件:
 

非常感谢,Mladen工作得很好!!!我想让 "extern int arrowDistance = XXX; "也被激活。

我想让 "extern int arrowDistance = XXX; "也以某种方式激活。

它现在显示在选择菜单中,但没有改变距离。要把*箭头距离放在哪里?

还是我完全错了?

我把它放在了几个地方,但它只给我更多的点,而不是更多的距离....。

试图理解代码的新手,希望得到一些启示

 

现在是这样做的:

如果(AboveBuff > 24.0) ShortBuff = High+ (Point*arrowDistance /2);

如果(BelowBuff < -24.0) LongBuffe = Low- (Point*arrowDistance /2);

这是个正确的方法吗?仅仅因为它有效,它可能是错误的

 
Slow Moe:
现在是这样做的:

如果(AboveBuff > 24.0) ShortBuff = High+ (Point*arrowDistance /2);

如果(BelowBuff < -24.0)LongBuffe = Low- (Point*arrowDistance /2)。

这是个正确的方法吗?仅仅因为它有效,它可能是错误的

这应该是可行的,还有一种方法可以这样做

LongBuffe = Low-arrowDistance*iATR(NULL,0,20,i) and ShortBuff = High+arrowDistance*iATR(NULL,0,20,i)

 

很慢。

最好使用iATR()模式。改变时间框架,你会明白我的意思。从视觉上看,当箭头与高点或低点的距离固定时,你在较高的时间框架上会有一个问题(它们在某些时间框架上看起来会很乱)。使用iATR()而不是使用固定距离可以解决这个问题。

 

谢谢mrtools,mladen的工作方式真的很好。

最后一个指标我无法控制....

试图在这里改变它:SignalGap = MathCeil(iATR(NULL,0,50,0)/Point)。

我想这是正确的位置,因为改变50会改变距离。但是,我测试的任何东西都不能与箭头距离一起工作。

 
Slow Moe:
谢谢mrtools,mladen的工作方式真的很好。

最后一个指标我无法控制....

试图在这里改变它:SignalGap = MathCeil(iATR(NULL,0,50,0)/Point)。

我想这是正确的地方,因为改变50会改变距离。但是我测试的任何东西都不能与箭头距离一起工作。

缓慢

当你使用ATR的箭头距离时,可能最好的方法是用一种乘法来修改这个距离。比如说:

arrowPrice = High+iATR(NULL,0,50,0)*arrowDistance。

其中arrowDistance被定义为双数,可以是小数(所以你可以使用0.5这样的值,也可以使用10.5这样的值)。改变ATR周期不会明显改变距离(它只是考虑到更长的平均范围)。

 

尝试从另一个指标获取数值

你好,我正在写我自己的第一个指标。

我想写我自己的第一个指标,我也想使用我从这个网站上得到的一个现有指标的值。我只是从这里复制了代码。

我必须在我的新指标中编写什么代码才能知道条形图是蓝色/红色还是1/0,我不介意,但我已经尝试了很多,但所有的时间都是零。

我甚至试图在我的指标中获得整个代码,但这并不奏效。

如果有任何帮助,我将不胜感激

谢谢 鲍勃

#property copyright "fxfariz"

#property link "fxfariz@gmail.com"

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Blue //Red //Aqua

#property indicator_color2 Red

extern int SSP=7;

extern double Kmax=50.6; //24 21.6 21.6

extern int CountBars=300;

extern int myPeriod = 0 ;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtHBuffer1[];

double ExtHBuffer2[];

int xPeriod ;

//+------------------------------------------------------------------+

string TimeFrameToString(int tf)

{

string tfs;

switch(tf) {

case PERIOD_M1: tfs="M1" ; break;

case PERIOD_M5: tfs="M5" ; break;

case PERIOD_M15: tfs="M15" ; break;

case PERIOD_M30: tfs="M30" ; break;

case PERIOD_H1: tfs="H1" ; break;

case PERIOD_H4: tfs="H4" ; break;

case PERIOD_D1: tfs="D1" ; break;

case PERIOD_W1: tfs="W1" ; break;

case PERIOD_MN1: tfs="MN1";

}

return(tfs);

}

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

IndicatorBuffers(4);

SetIndexStyle(0,DRAW_HISTOGRAM,0,4); //Red

SetIndexBuffer(0,ExtHBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM,0,4); //Lime

SetIndexBuffer(1,ExtHBuffer2);

SetIndexBuffer(2,ExtMapBuffer1);

SetIndexBuffer(3,ExtMapBuffer2);

if(myPeriod==0){xPeriod=Period();} {xPeriod=myPeriod;}

string tPeriod = TimeFrameToString(xPeriod) ;

IndicatorShortName(tPeriod + " Trade What You see ("+SSP+")");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

if (CountBars>=Bars) CountBars=Bars;

SetIndexDrawBegin(0,Bars-CountBars+SSP);

SetIndexDrawBegin(1,Bars-CountBars+SSP);

int i, counted_bars=IndicatorCounted();

double SsMax, SsMin, smin, smax;

if(Bars<=SSP+1) return(0);

if(counted_bars<SSP+1)

{

for(i=1;i<=SSP;i++) ExtMapBuffer1[CountBars-i]=0.0;

for(i=1;i<=SSP;i++) ExtMapBuffer2[CountBars-i]=0.0;

}

for(i=CountBars-SSP;i>=0;i--) {

SsMax = High;

SsMin = Low[Lowest(NULL,xPeriod,MODE_LOW,SSP,i-SSP+1)];

smax = SsMax-(SsMax-SsMin)*Kmax/100;

ExtMapBuffer1=smax;

ExtMapBuffer2=smax;

}

for(int b=CountBars-SSP;b>=0;b--)

{

if(ExtMapBuffer1>ExtMapBuffer2)

{

ExtHBuffer1=1;

ExtHBuffer2=0;

}

else

{

ExtHBuffer1=0;

ExtHBuffer2=1;

}

}

return(0);

}
 
BobMorane1000:
你好,com。

我想写我自己的第一个指标,我想使用我从这个网站上得到的一个现有指标的值。我只是从这里复制了代码。

我必须在我的新指标中编写什么代码才能知道条形图是蓝色/红色还是1/0,我不介意,但我已经尝试了很多,但所有的时间都是零。

我甚至试图在我的指标中获得整个代码,但这并不奏效。

如果有任何帮助,我将不胜感激

谢谢 鲍勃

#property copyright "fxfariz"

#property link "fxfariz@gmail.com"

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Blue //Red //Aqua

#property indicator_color2 Red

extern int SSP=7;

extern double Kmax=50.6; //24 21.6 21.6

extern int CountBars=300;

extern int myPeriod = 0 ;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtHBuffer1[];

double ExtHBuffer2[];

int xPeriod ;

//+------------------------------------------------------------------+

string TimeFrameToString(int tf)

{

string tfs;

switch(tf) {

case PERIOD_M1: tfs="M1" ; break;

case PERIOD_M5: tfs="M5" ; break;

case PERIOD_M15: tfs="M15" ; break;

case PERIOD_M30: tfs="M30" ; break;

case PERIOD_H1: tfs="H1" ; break;

case PERIOD_H4: tfs="H4" ; break;

case PERIOD_D1: tfs="D1" ; break;

case PERIOD_W1: tfs="W1" ; break;

case PERIOD_MN1: tfs="MN1";

}

return(tfs);

}

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

IndicatorBuffers(4);

SetIndexStyle(0,DRAW_HISTOGRAM,0,4); //Red

SetIndexBuffer(0,ExtHBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM,0,4); //Lime

SetIndexBuffer(1,ExtHBuffer2);

SetIndexBuffer(2,ExtMapBuffer1);

SetIndexBuffer(3,ExtMapBuffer2);

if(myPeriod==0){xPeriod=Period();} {xPeriod=myPeriod;}

string tPeriod = TimeFrameToString(xPeriod) ;

IndicatorShortName(tPeriod + " Trade What You see ("+SSP+")");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

if (CountBars>=Bars) CountBars=Bars;

SetIndexDrawBegin(0,Bars-CountBars+SSP);

SetIndexDrawBegin(1,Bars-CountBars+SSP);

int i, counted_bars=IndicatorCounted();

double SsMax, SsMin, smin, smax;

if(Bars<=SSP+1) return(0);

if(counted_bars<SSP+1)

{

for(i=1;i<=SSP;i++) ExtMapBuffer1[CountBars-i]=0.0;

for(i=1;i<=SSP;i++) ExtMapBuffer2[CountBars-i]=0.0;

}

for(i=CountBars-SSP;i>=0;i--) {

SsMax = High;

SsMin = Low[Lowest(NULL,xPeriod,MODE_LOW,SSP,i-SSP+1)];

smax = SsMax-(SsMax-SsMin)*Kmax/100;

ExtMapBuffer1=smax;

ExtMapBuffer2=smax;

}

for(int b=CountBars-SSP;b>=0;b--)

{

if(ExtMapBuffer1>ExtMapBuffer2)

{

ExtHBuffer1=1;

ExtHBuffer2=0;

}

else

{

ExtHBuffer1=0;

ExtHBuffer2=1;

}

}

return(0);

}

BobMorane1000

你可以做这样的事情。

bool blueValue = (iCustom(NULL,0,"indicatorNameHere",SSP,Kmax,0,0)!=0);

bool redValue = (iCustom(NULL,0,"indicatorNameHere",SSP,Kmax,1,0)!=0);

但要小心。该指标是超级信号指标的一个变体,而超级信号指标会重新计算(重绘)。

 

非常感谢你和你的警告^^,我现在就去试试......。