I will write the indicator for free - page 44

 

Help with the indicator


I want to keep it as is, but redo it to two buffers


#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

#property indicator_maximum 1.4

#property indicator_level1 0

#property indicator_minimum -1.2


//------- External indicator parameters -------------------------------

extern int CCI_Period_0 = 14; // CCI period for the current timeframe

extern int Level_0 = 100; // CCI Level for the current TF

extern int TF_1 = 60; // Number of minutes in the first timeframe

extern int CCI_Period_1 = 14; // CCI Period for the first TF

extern int Level_1 = 100; // CCI Level for the first TF

extern int TF_2 = 240; // Number of minutes of the second TF

extern int CCI_Period_2 = 14; // CCI Period for the second TF

extern int Level_2 = 100; // CCI level for the second TF

extern int NumberOfBars = 10000; //Number of bars(0-all)


//------- Indicator buffers ------------------------------------------

double buf0[];

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

//| Custom indicator initialisation function |

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

void init()

{

IndicatorDigits(1);


SetIndexBuffer(0,buf0);

SetIndexLabel(0, "i-3CCI-h");

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);

SetIndexEmptyValue(0,0);

}

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

//| Custom indicator deinitialization function |

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

void deinit()

{

Comment(");

}

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

//| Custom indicator iteration function |

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

void start()

{

double cci0,cci1,cci2;

int nb1,nb2;

int LoopBegin,sh;


if(NumberOfBars==0) LoopBegin=Bars-1;

else LoopBegin=NumberOfBars-1;

LoopBegin=MathMin(Bars-1,LoopBegin);


for(sh=LoopBegin; sh>=0; sh--)

{

nb1=iBarShift(NULL, TF_1, Time[sh], False);

nb2=iBarShift(NULL, TF_2, Time[sh], False);


cci0=iCCI(NULL, 0 , CCI_Period_0, PRICE_CLOSE, sh);

cci1=iCCI(NULL, TF_1, CCI_Period_1, PRICE_CLOSE, nb1);

cci2=iCCI(NULL, TF_2, CCI_Period_2, PRICE_CLOSE, nb2);


if(cci0>Level_0 && cci1>Level_1 && cci2>Level_2) buf0[sh]=1;

if(cci0<-Level_0 && cci1<-Level_1 && cci2<-Level_2) buf0[sh]=-1;

}

}

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


trying it myself, no luck yet.

tried it this way


#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Green

#property indicator_color2 Red

#property indicator_maximum 1.4

#property indicator_level1 0

#property indicator_minimum -1.2


//------- External indicator parameters -------------------------------

extern int CCI_Period_0 = 14; // CCI period for the current timeframe

extern int Level_0 = 100; // CCI Level for the current TF

extern int TF_1 = 60; // Number of minutes in the first timeframe

extern int CCI_Period_1 = 14; // CCI Period for the first TF

extern int Level_1 = 100; // CCI Level for the first TF

extern int TF_2 = 240; // Number of minutes of the second TF

extern int CCI_Period_2 = 14; // CCI Period for the second TF

extern int Level_2 = 100; // CCI level for the second TF

extern int NumberOfBars = 10000; //Number of bars(0-all)


//------- Indicator buffers ------------------------------------------

double ExtBuffer1[];

double ExtBuffer2[];

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

//| Custom indicator initialization function |

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

void init()

{

SetIndexBuffer(0,ExtBuffer1);

SetIndexStyle(0,DRAW_HISTOGRAM,0,2);

//----

SetIndexBuffer(1, ExtBuffer2);

SetIndexStyle(1,DRAW_HISTOGRAM,0,2);

}

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

//| Custom indicator deinitialization function |

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

void deinit()

{

Comment(");

}

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

//| Custom indicator iteration function |

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

void start()

{

double cci0,cci1,cci2;

int nb1,nb2;

int LoopBegin,sh;


if(NumberOfBars==0) LoopBegin=Bars-1;

else LoopBegin=NumberOfBars-1;

LoopBegin=MathMin(Bars-1,LoopBegin);


for(sh=LoopBegin; sh>=0; sh--)

for(st=LoopBegin; st<0; st--)

{

nb1=iBarShift(NULL, TF_1, Time[sh], False);

nb2=iBarShift(NULL, TF_2, Time[st], False);


cci0=iCCI(NULL, 0 , CCI_Period_0, PRICE_CLOSE, sh);

cci1=iCCI(NULL, TF_1, CCI_Period_1, PRICE_CLOSE, nb1);

cci2=iCCI(NULL, TF_2, CCI_Period_2, PRICE_CLOSE, nb2);


if(cci0>Level_0 && cci1>Level_1 && cci2>Level_2) buf1[sh]=1;

if(cci0<-Level_0 && cci1<-Level_1 && cci2<-Level_2) buf2[st]=-1;



the error is


in the end we need two buffers, one above zero and one below.


Files:
12121.jpg  42 kb
ere.mq4  6 kb
 

Dear koziabrrr !!! You have created your own topic. There are more topics. What if someone starts looking for a topic? And there are a lot of topics, it's hard to find. To make it easier to topic by topic. The topmost topic is for helping newbies. That's where your question should go. Created topic delete, and there write taking into account my comments!!! Then you also wrote in this thread - well, this is megalomania, exaggerated opinion of the value of his person

To get attention - you need to explain the task. 1. What does the indicator look like = screenshot. 2. what does the indicator do, what is its use (entry points will show, trend, flat, ...). 3) Why do we need two buffers? What is more useful for it (it shows better the trend, the flat, entry points)? That's when everyone will rush to refine it!!!! .... It will be good for them and for you! We should be friends, share

 

Here's a redo. It seems to show a trend. But it's cheating.

In half an hour we'll know we should have sold...

And that it's time to buy - it's silent...

 
Something like that would be better:

or MAinColor of some kind

 
STARIJ:

Here's a redo. It seems to show a trend. But it's cheating.

We'll know in half an hour that we should have sold...

And that it's time to buy - it's silent...


Yes, it looks better, thanks for the redesign. But I still don't understand how)))

 
koziabrrr: Yes it looks better, thanks for the redesign. But I still don't understand how))
#property indicator_buffers 2
#property indicator_color2 Tomato
double buf0[], buf1[];  //------- Буферы индикатора ------   добавил второй буфер
void init() 
  {
..................
   SetIndexBuffer(1,buf1);
   SetIndexLabel(1,"Вниз");
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexEmptyValue(1,0);
  }

void start() 
  {
....................
..................

      buf0[sh]=0;buf1[sh]=0;
      if(cci0>Level_0 && cci1>Level_1 && cci2>Level_2) buf0[sh]=1;
      if(cci0<-Level_0 && cci1<-Level_1 && cci2<-Level_2) buf1[sh]=-1;
    }
}
 
STARIJ:

STARIJ:

I'm trying, but I can't get the whole thing together. It's good when you know the issue, but when you don't, every little thing is a day.

 
koziabrrr:


I'm trying, but I can't get the whole thing together. It's good when you know the issue, but when you don't, every little thing is a day.

... And every day is an invaluable experience that comes only through your own work - not through a forum solution.
 
Artyom Trishkin:
... And every day is an invaluable experience that only comes from one's own work - not a decision on a forum.

This is Yes!


STARIJ: Thanks for your help!!!!


Solved the issue)))

 

Hi Yuri.

Indicator description: when starting from 3 candles kept on the same level or almost on the same level.It sent an alert to email and transmitted a sound. Also showed the instrument and time frame on the screen until I cancelled it. Look at the attached files please, there are examples

Files:
11.png  25 kb
12.png  24 kb
13.png  24 kb
14.png  27 kb