Register
Welcome to Forex-TSD! , one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more
02-20-2008, 06:25 PM
Senior Member
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
objects: set time zero+- X distance
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);
Attached Images
Attached Files
Last edited by fxbs; 02-20-2008 at 06:48 PM .
02-28-2008, 04:10 AM
Senior Member
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
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".
Last edited by fxbs; 02-28-2008 at 10:24 AM .
02-28-2008, 08:16 AM
Senior Member
Join Date: Feb 2006
Posts: 587
Quote:
Originally Posted by
fxbs
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 right
int customTime(int a)
{
if(a<0)
return(Time[0]-Period()*60*a);
else return(Time[a]);
}
02-28-2008, 10:06 AM
Senior Member
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
Thank you, Michel!
I'll try!
let me show how it was done with indi above:
before:
PHP Code:
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 );
}
after:
PHP Code:
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 ]);
}
Attached Images
Attached Files
Last edited by fxbs; 02-28-2008 at 10:25 AM .
02-28-2008, 11:16 AM
Senior Member
Join Date: Feb 2006
Posts: 587
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.
02-28-2008, 03:00 PM
Senior Member
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
yepp, thank you, Michel!
so overall shift formula will be:
PHP Code:
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 ]);
}
Last edited by fxbs; 02-28-2008 at 03:05 PM .
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT. The time now is 07:34 PM .