Navigation´╝ÜHome > Content >

KG_Daily_Range_level.mq4

Time: 2010-02-27 | Download file:KG_Daily_Range_level.mq4

//MAAP OM KG INDINYA SAYA OPREK, CODINGNYA MASIH KELIATAN BANGET :(
// MOHON KEIKHLASANNYA :)
#property  copyright "KG"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
//-----------------------------------
int bars_back = 120;

int i = 0;

int sName = 1102;


//-----------------------
double fx[], sqh[], sql[], stdh[], stdl[], stdkgh[], stdkgl[];

int    ip, p, n, f;

//*******************************************
int init()
{
  
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, fx);
   SetIndexLabel(0," DAILY OPEN");
   SetIndexStyle(1, DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(1, sqh);
   SetIndexLabel(1," SD 1");
   SetIndexStyle(2, DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(2, sql);
   SetIndexLabel(2," SD -1");
   SetIndexStyle(3, DRAW_LINE,STYLE_DASHDOTDOT);
   SetIndexBuffer(3, stdh);
   SetIndexLabel(3," SD 2");
   SetIndexStyle(4, DRAW_LINE,STYLE_DASHDOTDOT);
   SetIndexBuffer(4, stdl);
   SetIndexLabel(4," SD -2");
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, stdkgh);
   SetIndexLabel(5," SD 3");
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, stdkgl);
   SetIndexLabel(6," SD -3");
   p = MathRound(bars_back);
   
  
   return(0);
}
//----------------------------------------------------------
int deinit()
{
   ObjectDelete("pr" + sName);
}
//**********************************************************************************************
int start()
{
  
   datetime kjh=iTime(NULL,PERIOD_D1,0);
   ip = iBarShift(Symbol(),Period(),kjh,false);
   
   
   SetIndexDrawBegin(0, Bars-ip-1);
   SetIndexDrawBegin(1, Bars-ip-1);
   SetIndexDrawBegin(2, Bars-ip-1);
   SetIndexDrawBegin(3, Bars-ip-1);
   SetIndexDrawBegin(4, Bars-ip-1); 
   SetIndexDrawBegin(5, Bars-ip-1);
   SetIndexDrawBegin(6, Bars-ip-1); 
 //Daily range data
 double RAvgd,dR1,dR2,dR3,dR4,dR5,dR6,dR7,dR8,dR9,dR10,dR11,dR12,dR13,dR14,dR15,dR16,dR17,dR18,dR19,dR20;
  
   dR1  = (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   dR2  = (iHigh(NULL,PERIOD_D1,2)-iLow(NULL,PERIOD_D1,2))/Point;
   dR3  = (iHigh(NULL,PERIOD_D1,3)-iLow(NULL,PERIOD_D1,3))/Point;
   dR4  = (iHigh(NULL,PERIOD_D1,4)-iLow(NULL,PERIOD_D1,4))/Point;
   dR5  = (iHigh(NULL,PERIOD_D1,5)-iLow(NULL,PERIOD_D1,5))/Point;         
   dR6  = (iHigh(NULL,PERIOD_D1,6)-iLow(NULL,PERIOD_D1,6))/Point;
   dR7  = (iHigh(NULL,PERIOD_D1,7)-iLow(NULL,PERIOD_D1,7))/Point;
   dR8  = (iHigh(NULL,PERIOD_D1,8)-iLow(NULL,PERIOD_D1,8))/Point;
   dR9  = (iHigh(NULL,PERIOD_D1,9)-iLow(NULL,PERIOD_D1,9))/Point;
   dR10 = (iHigh(NULL,PERIOD_D1,10)-iLow(NULL,PERIOD_D1,10))/Point;         
   dR11 = (iHigh(NULL,PERIOD_D1,11)-iLow(NULL,PERIOD_D1,11))/Point;
   dR12 = (iHigh(NULL,PERIOD_D1,12)-iLow(NULL,PERIOD_D1,12))/Point;
   dR13 = (iHigh(NULL,PERIOD_D1,13)-iLow(NULL,PERIOD_D1,13))/Point;
   dR14 = (iHigh(NULL,PERIOD_D1,14)-iLow(NULL,PERIOD_D1,14))/Point;
   dR15 = (iHigh(NULL,PERIOD_D1,15)-iLow(NULL,PERIOD_D1,15))/Point;         
   dR16 = (iHigh(NULL,PERIOD_D1,16)-iLow(NULL,PERIOD_D1,16))/Point;
   dR17 = (iHigh(NULL,PERIOD_D1,17)-iLow(NULL,PERIOD_D1,17))/Point;
   dR18 = (iHigh(NULL,PERIOD_D1,18)-iLow(NULL,PERIOD_D1,18))/Point;
   dR19 = (iHigh(NULL,PERIOD_D1,19)-iLow(NULL,PERIOD_D1,19))/Point;
   dR20 = (iHigh(NULL,PERIOD_D1,20)-iLow(NULL,PERIOD_D1,20))/Point;      
    RAvgd=(dR1+dR2+dR3+dR4+dR5+dR6+dR7+dR8+dR9+dR10+dR11+dR12+dR13+dR14+dR15+dR16+dR17+dR18+dR19+dR20)/20;
     double drangesq=MathPow((dR1-RAvgd),2)+MathPow((dR2-RAvgd),2)+MathPow((dR3-RAvgd),2)+MathPow((dR4-RAvgd),2)+MathPow((dR5-RAvgd),2)+
                   MathPow((dR6-RAvgd),2)+MathPow((dR7-RAvgd),2)+MathPow((dR8-RAvgd),2)+MathPow((dR9-RAvgd),2)+MathPow((dR10-RAvgd),2)+
                   MathPow((dR11-RAvgd),2)+MathPow((dR12-RAvgd),2)+MathPow((dR13-RAvgd),2)+MathPow((dR14-RAvgd),2)+MathPow((dR15-RAvgd),2)+
                   MathPow((dR16-RAvgd),2)+MathPow((dR17-RAvgd),2)+MathPow((dR18-RAvgd),2)+MathPow((dR19-RAvgd),2)+MathPow((dR20-RAvgd),2);
      
       double dSDRangemin=MathSqrt(drangesq/20);
        if (dSDRangemin<0) dSDRangemin=0;
     



//===========================================================================================================================
   for(n = i; n <= i + p; n++)
   {
     
     
   } 
//-----------------------------------Std-----------------------------------------------------------------------------------
   
   for(n = i; n <= i + p; n++)
   {
       fx[n] = iOpen(Symbol(),PERIOD_D1,0);
      sqh[n] = fx[n] + 1*(dSDRangemin*Point);
      sql[n] = fx[n] - 1*(dSDRangemin*Point);
      stdh[n] = fx[n] + 2*(dSDRangemin*Point);
      stdl[n] = fx[n] - 2*(dSDRangemin*Point);
      stdkgh[n] = fx[n] + 3*(dSDRangemin*Point);
      stdkgl[n] = fx[n] - 3*(dSDRangemin*Point);
   } 
//-------------------------------------------------------------------------------
   ObjectMove("pr" + sName, 0, Time[p], fx[p]);
//----------------------------------------------------------------------------------------------------------------------------
   return(0);
}
//==========================================================================================================================   

Recommend