Hi !
You are using the same Object-Name for all your Lines. Therefore you get only one Line.
grace27: Please guys can you help me out on this code. I'm try to build a gridlines indicator but the lines are no drawing, here are the codes :
-
Play videoPlease edit your post.
For large amounts of code, attach it.
double GridArray[]; : for( int i= 1; i< index; i++){ GridArray[i] = RS_MIN + ( i * STEP_RANGE ) ;
Your array has no size to nothing can be assigned. If you had use property strict, you would have known the problem.
eddie: You are using the same Object-Name for all your Lines. Therefore you get only one Line.
Wrong, definitely generating a unique name per line:for(J=RS_MIN; J<RS_MAX; J+=STEP_RANGE){ RS_PRICE = J * Point; string RS_HGLineName = RS_LINES + DoubleToStr ( RS_PRICE , Digits ) ; //< 46> ObjectCreate ( RS_HGLineName
Hi Grace,
Were you successfull in making this indicator to work properly?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Please guys can you help me out on this code. I'm try to build a grid lines indicator but the lines are no drawing, here are the codes :
#define RS_LINES
//--- input parametersinput double GridMax=2.0;
input double GridMin=1.0;
input double GridStep=10.0;
input color GridColor=clrWhite;
input int GridBackground=clrBlack;
input int GridStyle =2;
double TickSize;
double pips;
double GridArray[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
TickSize = MarketInfo(Symbol(),MODE_TICKSIZE);
if(TickSize ==0.00001 || Point == 0.001)
pips= TickSize * 10;
else pips= TickSize;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int deinit()
{
double RS_MAX = MathRound(GridMax / Point);
double RS_STEP = MathRound(GridStep/ Point);
double RS_MIN = MathRound(GridMin / Point);
double STEP_RANGE = (RS_STEP * pips);
int index= MathFloor(RS_MAX / RS_STEP);
for( int i= 1; i< index; i++)
{
GridArray[i] = RS_MIN + (i * STEP_RANGE ) ;
string RS_HGLineName = RS_LINES + DoubleToStr ( GridArray[i] , Digits ) ;
ObjectDelete( RS_HGLineName = RS_LINES + DoubleToStr ( GridArray[i] , Digits ));
}
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
double RS_MAX = MathRound(GridMax / Point);
double RS_STEP = MathRound(GridStep/ Point);
double RS_MIN = MathRound(GridMin / Point);
double STEP_RANGE = (RS_STEP * pips);
int index= MathFloor(RS_MAX / RS_STEP);
for( int i= 1; i< index; i++)
{
GridArray[i] = RS_MIN + ( i * STEP_RANGE ) ;
string RS_HGLineName = RS_LINES + DoubleToStr (GridArray[i] , Digits ) ; //< 46>
ObjectCreate ( RS_HGLineName , OBJ_HLINE , 0 , 0 , GridArray[i] ) ; //< 47>
ObjectSet ( RS_HGLineName , OBJPROP_COLOR , GridColor ) ; //< 48>
ObjectSet ( RS_HGLineName , OBJPROP_STYLE , GridStyle ) ; //< 49>
ObjectSet ( RS_HGLineName , OBJPROP_BACK , GridBackground ) ; //< 50>
}
//--- return value of prev_calculated for next call
return(0);
}
//+------------------------------------------------------------------+
I will really appreciate it if the code is corrected......
when i did it as a single variable it worked properly but when i then converted it to arrays,its stoped drawing horizontal lines, here is the Gridlines that worked as single variable :
#property strict
#property indicator_chart_window
#define RS_LINES
//--- input parameters
input double RSG_HGmax=2.0;
input double RSG_HGstep=50;
input double RSG_HGmin=1.0;
input color RSGI_HGcolor= 0;
input int RSGI_HGstyle=2;
input int RSGI_HGbackground=0;
double TickSize;
double pips;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
TickSize = MarketInfo(Symbol(),MODE_TICKSIZE);
if(TickSize ==0.00001 || Point == 0.001)
pips= TickSize * 10;
else pips= TickSize;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int deinit()
{
double RS_MAX = MathRound(RSG_HGmax / Point);
double RS_STEP = MathRound(RSG_HGstep/ Point);
double RS_MIN = MathRound(RSG_HGmin / Point);
double RS_PRICE ;
double I;
double STEP_RANGE = (RS_STEP *pips);
for( I=RS_MIN; I<RS_MAX; I+=STEP_RANGE)
{
RS_PRICE = I * Point;
string RS_HGLineName = RS_LINES + DoubleToStr ( RS_PRICE , Digits ) ;
ObjectDelete( RS_HGLineName = RS_LINES + DoubleToStr ( RS_PRICE , Digits ));
} // for
//---
return(0);
}
int start()
{
//---
int counted_bars=IndicatorCounted();
double RS_MAX = MathRound(RSG_HGmax / Point) ;
double RS_STEP = MathRound(RSG_HGstep/ Point);
double RS_MIN = MathRound(RSG_HGmin / Point);
double RS_PRICE ;
double J;
double STEP_RANGE = (RS_STEP *pips);
for(J=RS_MIN; J<RS_MAX; J+=STEP_RANGE)
{
RS_PRICE = J * Point;
string RS_HGLineName = RS_LINES + DoubleToStr ( RS_PRICE , Digits ) ; //< 46>
ObjectCreate ( RS_HGLineName , OBJ_HLINE , 0 , 0 , RS_PRICE ) ; //< 47>
ObjectSet ( RS_HGLineName , OBJPROP_COLOR , RSGI_HGcolor ) ; //< 48>
ObjectSet ( RS_HGLineName , OBJPROP_STYLE , RSGI_HGstyle ) ; //< 49>
ObjectSet ( RS_HGLineName , OBJPROP_BACK ,RSGI_HGbackground ) ; //< 50>
}
return(0);
}
//+------------------------------------------------------------------+
Waiting for your reply .....