Coding at: Metatrader with C++ Language


Inside Bar Indicator

Screen Capture:





Coding dalam mql4 (C++) language dapat di download di

InsideBar.mq4


        Code:
        #property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       NumPrevBars=4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY, 4);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY, 4);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   for (int i=0; i<limit; i++)
   {
      ExtMapBuffer1[i] = 0; ExtMapBuffer2[i] = 0;
      if ( (Low[i] > Low[i+1]) && (High[i] < High[i+1]))
      {
         ExtMapBuffer1[i] = Close[i];
         ExtMapBuffer2[i] = Open[i];
      }
      double r0 = MathAbs(Open[i] - Close[i]);
      double r1 = MathAbs(Open[i+1] - Close[i+1]);
      double r2 = MathAbs(Open[i+2] - Close[i+2]);
      double r3 = MathAbs(Open[i+3] - Close[i+3]);
      double r4 = MathAbs(Open[i+4] - Close[i+4]);
      
      if (r0 < r1 && r0 < r2 && r0 < r3 && r0 < r4)
      {
         ExtMapBuffer1[i] = Close[i];
         ExtMapBuffer2[i] = Open[i];
      }       
   }
   if (ExtMapBuffer1[1]  != 0 && NewBar())
   {
      Comment(TimeToStr(Time[0])," Inside bar"); Print(Symbol(), " Inside bar");
      PlaySound("expert.wav");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

bool NewBar()
{
   static datetime dt  = 0;
   if (dt != Time[0])
   {
      dt = Time[0];
      return(true);
   }
   return(false);
}


HIKKAKE PATTERN Indicator

Screen capture





Coding dalam mql4 (C++) language dapat di download di

hikkake2.mq4




        Code:
        #property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_color2 RoyalBlue
#property indicator_width2 2
extern int Bars_Count= 1000;

double UpBuffer[];
double DnBuffer[];
int bA = 0, sA = 0;

int init() {
    IndicatorBuffers(2);
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexBuffer(0,UpBuffer);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexBuffer(1,DnBuffer);
    SetIndexArrow(0,159);
    SetIndexArrow(1,159);
    return(0);
}
int start() {
    int i = Bars_Count;
    int m;
    m = Time[0] + Period()*60 - CurTime();
    m = (m - m % 60) / 60;
    while(i>=0) {
        if(Low[i+2] > Low[i+3] && High[i+2] < High[i+3] && Low[i+1] > Low[i+2] 
&& High[i+1] > High[i+2] && Close[i] < Open[i]) {
            UpBuffer[i] = High[i] * 1.001;
        } else if(Low[i+2] > Low[i+3] && High[i+2] < High[i+3]  && Low[i+1] < 
Low[i+2] && High[i+1] < High[i+2] && Close[i] > Open[i]) {
            DnBuffer[i] = Low[i] * 0.999;
        }
        i--;
    }

return(0);
}
ada yang bisa bantu coding untuk metastock atau amibroker?



Kind Regards,



Aditya
This post originally posted at:
www.trendtrader.co.cc



      

Kirim email ke