Forex



Go Back   Forex Trading > Programming > MetaTrader
Forex Forum Register More recent Calendar Advertising Others Help






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

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-20-2008, 06:25 PM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
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, 126 views)
Attached Files
File Type: mq4 MACD_Colored_v102M.mq4 (5.7 KB, 14 views)

Last edited by fxbs; 02-20-2008 at 06:48 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 04:10 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
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 10:24 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:16 AM
Senior Member
 
Join Date: Feb 2006
Posts: 587
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:06 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
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, 75 views)
Attached Files
File Type: mq4 MACD_Colored_v102M1.mq4 (5.9 KB, 7 views)

Last edited by fxbs; 02-28-2008 at 10:25 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 11:16 AM
Senior Member
 
Join Date: Feb 2006
Posts: 587
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 03:00 PM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 3,272
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, 8 views)

Last edited by fxbs; 02-28-2008 at 03:05 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

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


All times are GMT. The time now is 07:34 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.