Incorporate an array into fractals

MQL4 지표 컨설팅

작업 종료됨

실행 시간 31 분
고객의 피드백
Fantastic. Quick, efficient and even annotated the script so i could follow it more easily. 5 stars.
피고용인의 피드백
Great customer from the Great Britain.

명시

I've been working on other things but over the past month been back and forward with this. 

I need to store fractals in an array to compare them. 

Recent fractal lower than last fractal and last fractal higher than third last fractal. Plot a buffer on the middle fractal.

The same for low fractals.

(image included).

So the dots are fractals that plot fine if a fractal has a higher/lower pair of fractals either side plot another buffer on it.

The fractal indicator i have works fine i just want to add this extra feature to make it clearer when trend changes direction.

So store last three fractal values and compare them. I don't want to use Ifractals as that limits me to only 2 bars either side of the fractal.

Code is below:

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow

//---- input parameters

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
double TOP[];


double UP_ARRAY[3];
double DOWN_ARRAY[3];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer); 
    SetIndexBuffer(2,TOP);
 
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,119);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,119);
    SetIndexStyle(2, DRAW_ARROW,0,4);
    SetIndexArrow(2,119);

//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
    SetIndexEmptyValue(2,0.0);

//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
    SetIndexLabel(2, "TOP");

    

//---- initialization done   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,nCountedBars;
   bool   bFound;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   if(nCountedBars<=2)
      i=Bars-nCountedBars-3;
   if(nCountedBars>2)
     {
      nCountedBars--;
      i=Bars-nCountedBars-1;
     }      
          
//----Up and Down Fractals
   while(i>=2)
     {
      //----Fractals up
      bFound=false;
      dCurrent=Close[i];
      
        if(dCurrent>Close[i+1] && dCurrent>Close[i-1])
        {
         bFound=true;
         ExtUpFractalsBuffer[i]=dCurrent;
         
         
         int TotalUp =3;
     for(int j=TotalUp-1;j>=0;j--)
     {
      if(ExtUpFractalsBuffer[i]!=0)
        {
         UP_ARRAY[j]=dCurrent;
         UP_ARRAY[j]=UP_ARRAY[j-1]; 
        }
     }
        if(UP_ARRAY[0]<UP_ARRAY[1] && UP_ARRAY[1]>UP_ARRAY[2])
        {
         TOP[i]=dCurrent;
         }
        }
      
                                         

      //----Fractals down
      bFound=false;
      dCurrent=Close[i];
      if(dCurrent<Close[i+1] && dCurrent<Close[i-1] )
        {
        bFound=true;
        ExtDownFractalsBuffer[i]=dCurrent;
        
        }                                   
      i--;
     }
     //----------------
    
     //----------------
     return(0);
     }

The yellow is the array and plotting buffer part I've had a shot at but no luck.

If you could make it run and perhaps a brief summary of these sections and how you got it to work so i can learn from it.

Thank you in advance.

Torexvir

응답함

1
개발자 1
등급
(501)
프로젝트
752
63%
중재
33
27% / 45%
기한 초과
23
3%
무료
2
개발자 2
등급
(461)
프로젝트
688
56%
중재
43
30% / 33%
기한 초과
110
16%
작업중
3
개발자 3
등급
(51)
프로젝트
66
30%
중재
2
0% / 0%
기한 초과
0
무료

프로젝트 정보

예산
30+ USD
개발자에게
27 USD
기한
 4 일