again, thank you everybody who helped:
when setting time (moving an object) to the right, use this function
int customTime(int a)
{
if(a<0)
return(Time[0]+Period()*60*MathAbs(a));
else return(Time[a]);
}
if you call it with - argument (say customTime(-5)) you are going to get FUTURE time and your object is going to be shifted to the rightint customTime(int a)
{
if(a<0)
return(Time[0]-Period()*60*a);
else return(Time[a]);
}
again, thank you everybody who helped - that's what i find out:
"When setting time (moving an object) to the right, use this function
int customTime(int a)
{
if(a<0)
return(Time[0]+Period()*60*MathAbs(a));
else return(Time[a]);
}
if you call it with - argument (say customTime(-5)) you are going to get FUTURE time and your object is going to be shifted to the right".
Thank you, Michel!
I'll try!
let me show how it was done with indi above:
before:
string objname=WindowExpertName()+","+Symbol()+","+Period();
if(ObjectFind(objname)<0)
ObjectCreate(objname,OBJ_TEXT,
WindowFind(WindowExpertName()+" ("+FastEMA+","+SlowEMA+","+SignalSMA+")"),
Time[0]+Period()*60,MacdBuffer[0]/2);
else
ObjectMove(objname,0,Time[0]+Period()*60,MacdBuffer[0]/2);
if(pips!=0)
ObjectSetText(objname,DoubleToStr(pips,0),FontSize,"Courier",FontColor);
else
ObjectSetText(objname,"",FontSize,"Courier",FontColor);
//---- done
return(0);
}[/PHP]
after:
[PHP]
string objname = ShortName;
int window = WindowFind(ShortName);
int labelShift = -5;
if(ObjectFind(objname)<0)
ObjectCreate(objname,OBJ_TEXT,window,customTime(labelShift),MacdBuffer[0]/2);
else ObjectMove(objname,0 ,customTime(labelShift),MacdBuffer[0]/2);
if(pips!=0)
ObjectSetText(objname,DoubleToStr(pips,0),FontSize,"Courier",FontColor);
else ObjectSetText(objname," " ,FontSize,"Courier",FontColor);
//---- done
return(0);
}
//+------------------------------------------------------------------+
int customTime(int a)
{
if(a<0)
return(Time[0]+Period()*60*MathAbs(a));
else return(Time[a]);
}It seems ok, just you do not need to use the MathAbs() function, as there you are inside the "if(a<0)" condition so always negative.
yepp, thank you, Michel!
so overall shift formula will be:
string objname = ShortName;
int window = WindowFind(ShortName);
int labelShift = -5; // or it goes to: extern int labelShift = -5;
if(ObjectFind(objname)<0)
ObjectCreate(objname,OBJ_TEXT,window,customTime(labelShift),MacdBuffer[0]/2);
else ObjectMove(objname,0 ,customTime(labelShift),MacdBuffer[0]/2);
if(pips!=0)
ObjectSetText(objname,DoubleToStr(pips,0),FontSize,"Courier",FontColor);
else ObjectSetText(objname," " ,FontSize,"Courier",FontColor);
//---- done
return(0);
}
//+------------------------------------------------------------------+
int customTime(int a)
{
if(a<0)
return(Time[0]-Period()*60*a);
else return(Time[a]);
}- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
basically - how to shift lable on macd to the right?
-it don't wanna go easy way...
...
string objname=WindowExpertName()+","+Symbol()+","+Period();
if(ObjectFind(objname)<0)
ObjectCreate(objname,OBJ_TEXT,
WindowFind(WindowExpertName()+" ("+FastEMA+","+SlowEMA+","+SignalSMA+")"),
Time[0]+Period()*60,MacdBuffer[0]/2);
else
ObjectMove(objname,0,Time[0]+Period()*60,MacdBuffer[0]/2);
if(pips!=0)
ObjectSetText(objname,DoubleToStr(pips,0),FontSize,"Courier",FontColor);
else
ObjectSetText(objname," ",FontSize,"Courier",FontColor);