//+------------------------------------------------------------------+ //| BarLabel.mq4 | //| Copyright © 2006, iExpertAdvisor, LLC | //| http://www.iExpertAdvisor.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, iExpertAdvisor, LLC" #property link "http://www.iExpertAdvisor.com" extern int NumberOfBars=25; #define FONT_SIZE 9 #define FONT_NAME "Times Roman" #define FONT_COLOR Red //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { fnLabelTheBars(true, NumberOfBars); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectsDeleteAll( 0, OBJ_TEXT); return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { fnLabelTheBars(false, NumberOfBars); return(0); } int fnLabelTheBars( bool bInit, int iNumBars ) { string strObjName, strText; double dTime, dPrice, now; static int LastBar; now = CurTime(); if( (LastBar == Bars) && (bInit == false) ) return(0); LastBar=Bars; for( int k=0; k<=iNumBars; k++ ) { strObjName=StringConcatenate( "BarLabel", k ); dPrice = High[k]; dTime = now - (k*Period()*60); strText = k; //Print(" k=", k, " dTime=", dTime, " dPrice=", dPrice ); ObjectCreate( strObjName, OBJ_TEXT, 0, dTime, dPrice ); ObjectSetText( strObjName, strText, FONT_SIZE, FONT_NAME, FONT_COLOR ); ObjectSet(strObjName, OBJPROP_TIME1, dTime); ObjectSet(strObjName, OBJPROP_PRICE1, dPrice); ObjectsRedraw(); } return(0); }