Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-20-2008, 05:25 PM
fxbs fxbs is offline
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,630
fxbs is on a distinguished road
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
File Type: gif macd102m.gif (9.7 KB, 99 views)
Attached Files
File Type: mq4 MACD_Colored_v102M.mq4 (5.7 KB, 10 views)

Last edited by fxbs : 02-20-2008 at 05:48 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 03:10 AM
fxbs fxbs is offline
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,630
fxbs is on a distinguished road
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 09:24 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 07:16 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 509
Michel is on a distinguished road
Quote:
Originally Posted by fxbs View Post
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]);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 09:06 AM
fxbs fxbs is offline
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,630
fxbs is on a distinguished road
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
File Type: gif lable shift test.gif (12.2 KB, 49 views)
Attached Files
File Type: mq4 MACD_Colored_v102M1.mq4 (5.9 KB, 3 views)

Last edited by fxbs : 02-28-2008 at 09:25 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 10:16 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 509
Michel is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 02:00 PM
fxbs fxbs is offline
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,630
fxbs is on a distinguished road
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]);    

Attached Files
File Type: mq4 MACD_Colored_v102M2.mq4 (6.0 KB, 4 views)

Last edited by fxbs : 02-28-2008 at 02:05 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Distance until retrace indicator. sprtn Indicators - Metatrader 4 0 07-26-2007 11:36 PM
Objects events kicking off scripts Pervaz Setup Questions 1 07-24-2007 06:20 PM
Distance trading traderforex777 Tools and utilities 7 05-15-2007 11:38 PM
Too much distance from real price in Open Orders echnaton Metatrader 4 2 02-25-2007 11:05 AM
Question about objects on an EA thn5625 Metatrader 4 2 01-30-2007 06:49 PM


All times are GMT. The time now is 11:11 AM.