PDA

View Full Version : 简单的编码问题...



阿丽娅伊劳拉
02-09-2009 14:37, 02:37 PM
嗨,对于这个愚蠢的问题感到抱歉,但请在这里帮助我:

如果您在图表窗口中有任何由1条线组成的指标,并且您希望将标准偏差带添加到该线,例如布林带。你怎么做到这一点:
让我们说你的缓冲区绘制你的原始指标被命名为abc
所以首先你声明这些:
extern int BandsPeriod = 20;
extern int BandsShift = 0;
extern double BandsDeviations = 2.0;
1)你改变了
#property indior_buffers 1(1变为3)
2)
SetIndexBuffer(0,ABC);
SetIndexStyle(0,DRAW_LINE);
并添加
SetIndexBuffer(1,UpperBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2,LowerBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0, BandsPeriod BandsShift);
SetIndexDrawBegin(1,BandsPeriod BandsShift);
3)将其余的bollinger band代码添加到初始化循环中
int start()
{
int i,k,counts_bars = IndiorCounted();
双偏差,总和,oldval,newres;

//----
如果(Barslt; = BandsPeriod)返回(0);
//----初始零
如果(counted_barslt; 1)
等等....
4),但是你怎么用你的新缓冲区替换名为MovingBuffer的buffer在原始bands.mq4代码中,称为abc?

什么是最好的方式去做这件事?
我应该试着让我的指示码进入bands.mq4代码或其他方式吗?

我附加了一个众所周知的称为bands.mq4的代码片段,以便您可以看到我正在处理的内容。

再次,抱歉我的编码 - 无知

也许有人知道“添加stdev乐队教程”?那将是我现在需要的。谢谢

nedveltt
08-09-2023 14:50, 02:50 PM
嗨,对于愚蠢的问题抱歉,但请在这里帮助我:如果您有任何指标由图表窗口中的1条线组成,并且您希望将标准偏差带添加到该线,例如布林带。你如何做到这一点:假设你的原始指标的缓冲区被命名为abc,所以你首先声明这些:extern int BandsPeriod = 20; extern int BandsShift = 0; extern double BandsDeviations = 2.0; 1)你改变#property indior_buffers 1(1变为3)2)SetIndexBuffer(0,abc); SetIndexStyle(0,DRAW_LINE);并添加SetIndexBuffer(1,UpperBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,LowerBuffer); SetIndexStyle(2,DRAW_LINE); SetIndexDrawBegin(0, BandsPeriod BandsShift); SetIndexDrawBegin(1,BandsPeriod BandsShift); 3)...
使用iBandsOnArray的东西:iBandsOnArray(array [],total,period,deviation,bands_shift,mode,shift)数组显然是你的原始指标,只是把bars放在总的部分中,周期和偏差很明显,移位可能为零,模式是您根据乐队选择MODE_UPPER或MODE_LOWER的位置,并且移位将是i或0,您的选择。只要做两个,一个用于上乐队,一个用于低乐队。更新:这是一个代码示例:#property indior_separate_window #property indior_buffers 3 #property indior_color1红色#property indior_color2白色#property indior_color3白色//----输入extern int Stoch_Period = 5; extern int Bands_Period = 20; extern int偏差= 2;/----双缓冲区StochBuffer []; double UpperBuffer []; double LowerBuffer []; int init(){//---------- SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,StochBuffer);/---------- SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,UpperBuffer);/---------- SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,LowerBuffer); IndiorShortName(Stoch-Bands示例( Stoch_Period , Bands_Period , Deviations ));/---------- return(0); } int start(){int limit; int counted_bars = IndiorCounted();/---- if(counting_barsgt; 0)counted_bars--;极限=棒材 - counted_bars;/---- for(int i = 0; ilt; limit; i )StochBuffer [i] = iStochastic(NULL,0,Stoch_Period,3,3,MODE_SMA,PRICE_CLOSE,0,i); UpperBuffer [i] = iBandsOnArray(StochBuffer,Bars,Bands_Period,Deviations,0,MODE_UPPER,i);/---- for(i = 0; ilt; limit; i ) LowerBuffer [i] = iBandsOnArray(StochBuffer,Bars,Bands_Period,Deviations,0,MODE_LOWER,i);/---- for(i = 0; ilt; limit; i )/---- return(0); }/ ---------------------------------------------- --------------------

弗雷德里克大卫
08-09-2023 16:11, 04:11 PM
使用iBandsOnArray的东西:iBandsOnArray(array [],total,period,deviation,bands_shift,mode,shift)数组显然是你的原始指标,只是把bars放在总的部分中,周期和偏差很明显,移位可能为零,模式是您根据乐队选择MODE_UPPER或MODE_LOWER的位置,并且移位将是i或0,您的选择。只要做两个,一个用于上乐队,一个用于低乐队。
这是唯一的方法 - 但bandsonarray - int iBandsOnArray(double数组[],整数,整数周期,整数偏差,所以如果你需要双 - 或stDev或iCustom - 乐队 - 像HA它标准和它是双倍的

阿丽娅伊劳拉
08-09-2023 17:32, 05:32 PM
谢谢你们,我会继续努力。