#property indicator_separate_window// Indicator is drawn in the main window#property indicator_buffers1// Number of buffers#property indicator_color1 Red // Color of the 1st linedouble Buf_0[]; // Declaring indicator arrays//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].//--------------------------------------------------------------------int init() // Special function init()
{
//--------------------------------------------------------------------SetIndexBuffer(0,Buf_0); // Assigning an array to a bufferSetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style//--------------------------------------------------------------------// SetIndexBuffer(1,Buf_1); // Assigning an array to a buffer//SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Line style//--------------------------------------------------------------------return(0); // Exit the special funct.init()
}
//--------------------------------------------------------------------int start() // Special function start()
{
int i=0, iCht, Counted_bars;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted barsfor(iCht = Bars - 1 - Counted_bars; iCht >= 0; iCht--){ // Chart barsint iD1 = iBarShift(NULL, PERIOD_D1, Time[iCht]);
double openD1 = iOpen(NULL, PERIOD_D1, iD1);
int iM1Beg = iBarShift(NULL, PERIOD_M1, Time[iCht]),
iM1End = -1;
if(iCht > 0) iM1End = iBarShift(NULL, PERIOD_M1, Time[iCht-1]);
for(Buf_0[i] = 0; iM1Beg > iM1End; iM1Beg--){
double hM1 = iHigh(NULL, PERIOD_M1, iM1Beg),
lM1 = iLow(NULL, PERIOD_M1, iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period if( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++;
}
}
//--------------------------------------------------------------------return(0); // Exit the special funct. start()
}
//--------------------------------------------------------------------
#property indicator_separate_window// Indicator is drawn in the main window#property indicator_buffers1// Number of buffers#property indicator_color1 Red // Color of the 1st linedouble Buf_0[]; // Declaring indicator arrays//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].//--------------------------------------------------------------------int init() // Special function init()
{
//--------------------------------------------------------------------SetIndexBuffer(0,Buf_0); // Assigning an array to a bufferSetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style//--------------------------------------------------------------------// SetIndexBuffer(1,Buf_1); // Assigning an array to a buffer//SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Line style//--------------------------------------------------------------------return(0); // Exit the special funct.init()
}
//--------------------------------------------------------------------int start() // Special function start()
{
int i=0, iCht, Counted_bars;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted barsfor(iCht = Bars - 1 - Counted_bars; iCht >= 0; iCht--){ // Chart barsint iD1 = iBarShift(NULL, PERIOD_D1, Time[iCht]);
double openD1 = iOpen(NULL, PERIOD_D1, iD1);
int iM1Beg = iBarShift(NULL, PERIOD_M1, Time[iCht]),
iM1End = -1;
if(iCht > 0) iM1End = iBarShift(NULL, PERIOD_M1, Time[iCht-1]);
for(Buf_0[i] = 0; iM1Beg > iM1End; iM1Beg--){
double hM1 = iHigh(NULL, PERIOD_M1, iM1Beg),
lM1 = iLow(NULL, PERIOD_M1, iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period if( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++;
}
}
//--------------------------------------------------------------------return(0); // Exit the special funct. start()
}
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted barsfor(iCht = Bars - 1 - Counted_bars; iCht >= 0; iCht--){ // Chart barsint iD1 = iBarShift(Symbol(), PERIOD_D1, Time[iCht]);
//----find the datetime of iD1. ie the Time[]datetime daystarttime = iTime(Symbol(),PERIOD_D1,iD1);
double openD1 = iOpen(Symbol(), PERIOD_D1, iD1);
//----find BarShift of daystarttime on current chart and take the nearest following bar if it doesn't existint iM1Beg = iBarShift(Symbol(),PERIOD_M1,daystarttime,true);
if(iM1Beg<0)
iM1Beg = iBarShift(Symbol(),PERIOD_M1,daystarttime,false)+1;
//----find BarShift for end of day on current chart and take the nearest following bar if it doesn't existif(iD1>0)
{
datetime nextday = iTime(Symbol(),PERIOD_D1,iD1-1);
int iM1End = iBarShift(Symbol(),PERIOD_M1,nextday-1,true);
if(iM1End<0)
iM1End = iBarShift(Symbol(),PERIOD_M1,nextday,false);
for(Buf_0[i] = 0; iM1Beg > iM1End; iM1Beg--){
double hM1 = iHigh(Symbol(), PERIOD_M1, iM1Beg),
lM1 = iLow(Symbol(), PERIOD_M1, iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period if( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++;
}
}
#property indicator_separate_window// Indicator is drawn in the main window#property indicator_buffers1// Number of buffers#property indicator_color1 Red // Color of the 1st line//#property indicator_color2 Yellow // Color of the 2nd lineexternint Multiplier=2;
double Buf_0[];// Buf_1[]; // Declaring indicator arrays//THIS INDICATOR IS TO COUNT NUMBER OF M1 BARS WHICH HIGH[I] IS HIGHER AND LOW[I] IS LOWER THAN OPEN[1440].//--------------------------------------------------------------------int init() // Special function init()
{
//--------------------------------------------------------------------SetIndexBuffer(0,Buf_0); // Assigning an array to a bufferSetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style//--------------------------------------------------------------------// SetIndexBuffer(1,Buf_1); // Assigning an array to a buffer// SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,2);// Line style//--------------------------------------------------------------------return(0); // Exit the special funct.init()
}
//--------------------------------------------------------------------int start() // Special function start()
{
int i=0, iCht, Counted_bars;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted barsfor(iCht = Bars - 1 - Counted_bars; iCht >= 0; iCht--){ // Chart barsint iD1 = iBarShift(NULL, PERIOD_D1, Time[iCht]);
double openD1 = iOpen(NULL, PERIOD_D1, iD1);
int iM1Beg = iBarShift(NULL, PERIOD_M1, Time[iCht]),
iM1End = -1;
if(iCht > 0) iM1End = iBarShift(NULL, PERIOD_M1, Time[iCht-1]);
Buf_0[iCht] = EMPTY; // <<<<<<<<<<<< This is the magic code that gjol inserted and it worked. for(Buf_0[i] = 0; iM1Beg > iM1End; iM1Beg--){
double hM1 = iHigh(NULL, PERIOD_M1, iM1Beg),
lM1 = iLow(NULL, PERIOD_M1, iM1Beg);
// count Bars of M1 Period that crisscross Open price of D1 Period if( hM1 >= openD1 && openD1 >= lM1) Buf_0[iCht]++;
// Buf_1[iCht]= Multiplier*Buf_0[iCht];
}
}
//--------------------------------------------------------------------return(0);//
}
//--------------------------------------------------------------------
你有M1的历史吗?
是的,我有。
突出显示的这行代码只有在Indi与日线图相连时才会给出正确的转变。
正如我在之前的帖子中所说
"所以你需要 D1蜡烛开盘的日期时间值 。你能做到这一点吗?"
突出显示的这行代码只有在Indi与日线图相连时才会给出正确的转变。
正如我在之前的帖子中所说
"所以你需要 D1蜡烛开盘的日期时间值 。你能做到这一点吗?"
嗨,GumRai,我试了很多次,但我甚至不能编译它,这超出了我的理解范围。最好是有人能告诉我怎么做,然后我就能从中学到东西,我注意到如果有例子的话,我学得很快。现在,该指标正在计算与Open[1]价格交错的Bar1内的M1条。但是,计数从那里开始就停止了,没有进展到完成图形。我试图将该指标连接到一个EA,但即使是EA在回测时也不能发送信号。 请显示一些代码,以完成这个指标为好。谢谢你。
Buf_0[iCht] = EMPTY;
嗨,GumRai,我试了很多次,但我甚至不能编译它,这超出了我的理解范围。最好是有人能告诉我怎么做,然后我就能从中学到东西,我注意到如果有例子的话,我学得很快。现在,该指标正在计算与Open[1]价格交错的Bar1内的M1条。但是,计数从那里开始就停止了,没有进展到完成图形。我试图将该指标连接到一个EA,但即使是EA在回测时也不能发送信号。 请显示一些代码,以完成这个指标为好。谢谢你。
未编译或测试,但可能对你有所帮助
我设法将Buf_0[iCht] = EMPTY;插入WHRoeder代码中,不知何故,该指标成功。请查看图片和最新的编译代码。然而,当我把它链接到我的EA时,它一直在加载和卸载它,就像一个醉汉在喷牛奶一样。而链接到同一EA的其他指标则工作正常。这是我收到的信息。
2014.02.25 17:17:08.806 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:删除
2014.02.25 17:17:08.799 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:加载成功
2014.02.25 17:17:08.794 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:已删除
2014.02.25 17:17:08.787 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:加载成功
2014.02.25 17:17:08.783 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:已删除
2014.02.25 17:17:08.774 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:加载成功
2014.02.25 17:17:08.768 2014.01.02 07:48 自定义指标MamaMaryII EURPLN,Daily:已删除