Navigation:Home > Content >

Cons.mq4

Time: 2013-02-01 | Download file:Cons.mq4

//+------------------------------------------------------------------+
//|                                                         Cons.mq4 |
//|                                           Copyright © 2011, AZM. |
//|                                                 [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, AZM."
#property link      "[email protected]"

#property indicator_chart_window
extern color      BoxColor=Red;
extern color      Box2Color=DarkOrchid;
extern int boxheight=10;
extern int boxlength=11;
extern int levelUp=45;
extern int levelDn=45;
extern int chart=0;

int dec;double digit;
//+------------------------------------------------------------------+
int init() {
   digit  = MarketInfo(Symbol(),MODE_DIGITS);// sp  = MarketInfo(Symbol(),MODE_SPREAD); 
   if (digit==5 || digit==3) dec=10;//if(digit==5)k=100000;if(digit==3)k=1000;
   if (digit==4 || digit==2) dec=1; //if(digit==4)k=10000; if(digit==2)k=100;
 //  ml=MarketInfo(Symbol(),MODE_MINLOT);  s=MarketInfo(Symbol(),MODE_STOPLEVEL);   
return(0);}
//+------------------------------------------------------------------+
int deinit()
{for(int i=ObjectsTotal()-1;i>=0;i--)
   {string name=ObjectName(i);
    if(StringFind(name,"Cons")==0) ObjectDelete(name);}
return(0);}
//+------------------------------------------------------------------+
int start()
{int limit;
 int counted_bars=IndicatorCounted();
 if(counted_bars>0) counted_bars--;
 limit=Bars-counted_bars;
 for(int i=0; i(iOpen(Symbol(),chart,i)+(dec*(boxheight/2)*Point))||
    iMA(Symbol(),chart,1,0,MODE_SMA,PRICE_OPEN,i+i2)<(iOpen(Symbol(),chart,i)-(dec*(boxheight/2)*Point))){cons=false;break;}
 }
if(cons)
     {
     string name="Cons"+TimeToStr(iTime(Symbol(),chart,i));
     string name1="Cons_level1";
     string name2="Cons_level2";          
      //ObjectDelete(name1);ObjectDelete(name2);
      ObjectCreate(name,OBJ_RECTANGLE,0,iTime(Symbol(),chart,i),(iOpen(Symbol(),chart,i)+(dec*(boxheight/2)*Point)),iTime(Symbol(),chart,i+i2-1),(iOpen(Symbol(),chart,i)-(dec*(boxheight/2)*Point)));
      ObjectSet(name,OBJPROP_BACK,true);
      ObjectSet(name,OBJPROP_COLOR,BoxColor);
      name="Cons_l"+TimeToStr(iTime(Symbol(),chart,i));
     // ObjectDelete(name);
      ObjectCreate(name,OBJ_RECTANGLE,0,iTime(Symbol(),chart,i),(iOpen(Symbol(),chart,i)+(dec*levelUp*Point)),iTime(Symbol(),chart,i+i2-1),(iOpen(Symbol(),chart,i)-(dec*levelDn*Point)));
      ObjectSet(name,OBJPROP_BACK,true);
      ObjectSet(name,OBJPROP_COLOR,Box2Color);      
      
      ObjectCreate(name1,OBJ_HLINE,0,0,iOpen(Symbol(),chart,i)+(dec*levelUp*Point));
      ObjectCreate(name2,OBJ_HLINE,0,0,iOpen(Symbol(),chart,i)-(dec*levelDn*Point));
            
      }
}return(0);}
//+------------------------------------------------------------------+

Recommend