Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
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 03-19-2007, 03:03 AM
Kurka Fund's Avatar
Senior Member
 
Join Date: Sep 2006
Location: San Diego
Posts: 138
Kurka Fund is on a distinguished road
EA Time function

Can anyone help with this.....

I am trying to calculate the the % growth for the day. The problem is I cannot seem to set the begining balance variable.

Here is what I tried
PHP Code:


   double DailystartBal
;
   
int CurrentTime TimeCurrent();
   if (
CurrentTime == StartHour) {       //Start hour = 17
      
DailystartBal AccountEquity();
      }
   
double DailyGrowth = ((AccountEquity() - DailystartBal)/DailystartBal); 
I Just need to set DailystartBal to AccountEquity() @ a specified time. Anyone here know what I am doing wrong ?

Thanks,

KK
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 03-19-2007, 04:12 AM
Senior Member
 
Join Date: Mar 2006
Posts: 794
Maji is on a distinguished road
Try this:

PHP Code:
 
  double DailystartBal
;
   
int CurrentTime TimeHour(TimeCurrent());
   if (
CurrentTime == StartHour-1) {DailystartBal AccountEquity();}
   
double DailyGrowth = ((AccountEquity() - DailystartBal)/DailystartBal); 
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 03-19-2007, 05:42 AM
Kurka Fund's Avatar
Senior Member
 
Join Date: Sep 2006
Location: San Diego
Posts: 138
Kurka Fund is on a distinguished road
Quote:
Originally Posted by Maji
Try this:

PHP Code:
 
  double DailystartBal
;
   
int CurrentTime TimeHour(TimeCurrent());
   if (
CurrentTime == StartHour-1) {DailystartBal AccountEquity();}
   
double DailyGrowth = ((AccountEquity() - DailystartBal)/DailystartBal); 
No go. it still Resets the DailystartBal everytime AccountEquity() changes. returning a dailygrowth of 0.

Here is the entire function ...

PHP Code:
//ChartComment
void ChartComment() {
   
   
double DailystartBal;
   
int CurrentTime TimeHour(TimeCurrent());
   if (
CurrentTime == StartHour-1) {DailystartBal AccountBalance();}
   
double DailyGrowth = ((AccountBalance() - DailystartBal)/DailystartBal); 

   
string sComment   "";
   
string sLine      "--------------------------------------------------------------";
   
string sNewLine   "\n";

   
sComment sComment sLine sNewLine;
   
sComment sComment "- KURKA TRADER, My 2 ipps  - "sNewLine;
   
sComment sComment sLine sNewLine;
   
sComment sComment "Account Name           : " " KURKA FUND " sNewLine;
   
sComment sComment "Current Balance         : $ " DoubleToStr(AccountBalance(),2) + sNewLine;
   
sComment sComment "Account Equity          : $ " DoubleToStr(AccountEquity(),2) + sNewLine;
   
sComment sComment "Account FreeMargin   : $ " DoubleToStr(AccountFreeMargin(),2) + sNewLine;
   
sComment sComment "Floating P&L              : $ " DoubleToStr(AccountProfit(),2) + sNewLine;
   
sComment sComment "Percentage Growth      : % " DoubleToStr(DailystartBal,4) + sNewLine;
   
sComment sComment sLine sNewLine;
   
    
sComment sComment "OPEN POSITIONS : " DoubleToStr(OrdersTotal(), 2)+ sNewLine;
    
sComment sComment sLine sNewLine;
    
sComment sComment ":  Type  "": Ticket   " " :  Lots   "+" :   Swap   "+" :    Profit   "+sNewLine;
    
int total OrdersTotal();
    for(
int cnt=0;cnt<total;cnt++){
      
OrderSelect(cntSELECT_BY_POSMODE_TRADES);  
        if (
OrderType() == OP_BUY){
            
sComment sComment ":   Buy    :"+" # "DoubleToStr(OrderTicket( ),0)+"     :   "+DoubleToStr(OrderLots( ),2)+"   :  $ "+DoubleToStr(OrderSwap(),2)+"   :  $ "+DoubleToStr(OrderProfit(),2)+sNewLine;    
            }
        if (
OrderType() == OP_SELL){
            
sComment sComment ":   Sell   :"+" # "DoubleToStr(OrderTicket( ),0)+"     :   "+DoubleToStr(OrderLots( ),2)+"   :  $ "+DoubleToStr(OrderSwap(),2)+"   :  $ "+DoubleToStr(OrderProfit(),2)+sNewLine;    
            }    
           }
   
sComment sComment sLine sNewLine;   
   
sComment sComment "Upper Trigger : " DoubleToStr(HighTrigger4) + " BID : " DoubleToStr(Bid4)+ sNewLine;
   
sComment sComment "Lower Trigger : " DoubleToStr(LowTrigger4) + " ASK : " DoubleToStr(Ask4)+ sNewLine;
   
sComment sComment sLine sNewLine;
   
Comment(sComment);


I like the chart comment for backtesting. it helps allot to see exactly what your EA is doing espically with multiple open positions. The ability to see the % growth would be great...
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 03-19-2007, 08:33 AM
igorad's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Ukraine
Posts: 963
igorad is on a distinguished road
You should describe DailystartBal in global variables.
I tried, and it works.
__________________
Let's improve trade skills together
http://finance.groups.yahoo.com/group/TrendLaboratory
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 03-19-2007, 09:55 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
You may well want to keep the value as a global variable, as it then would survive EA invocations, as long as the MT4 program i running. In either case, you need two variables: one for the value, and another to tell whether the value has been assigned today or not.

You could use the following code snippet would make the assignment once with the first tick of the selected StartHour:

PHP Code:
void ChartComment() {
    if ( 
TimeHour(TimeCurrent()) == StartHour ) {
        if ( 
GlobalVariableGet"DailystartBalAssigned" ) == ) {
            
GlobalVariableSet"DailystartBal"AccountEquity() );
            
GlobalVariableSet"DailystartBalAssigned");
        }
    } else {
        
GlobalVariableSet"DailystartBalAssigned");
    }
    
double DailystartBal GlobalVariableGet"DailystartBal" );
    ....

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
Professional MM function Nicholishen Tools and utilities 13 01-31-2007 07:05 PM
MT4 Function Details BC Brett Questions 3 04-25-2006 11:38 PM
MT4 function/EA question eastmaels Questions 2 04-16-2006 04:43 AM
function details niva Questions 4 04-08-2006 08:15 PM


All times are GMT. The time now is 05:30 AM.



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