Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4


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

 
 
LinkBack Thread Tools
 
Old 03-19-2007, 01:03 AM
Kurka Fund's Avatar
Senior Member
 
Join Date: Sep 2006
Location: San Diego
Posts: 139
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!
 
Old 03-19-2007, 02:12 AM
Senior Member
 
Join Date: Mar 2006
Posts: 787
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!
 
Old 03-19-2007, 03:42 AM
Kurka Fund's Avatar
Senior Member
 
Join Date: Sep 2006
Location: San Diego
Posts: 139
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!
 
Old 03-19-2007, 06:33 AM
igorad's Avatar
Senior Member
 
Join Date: Oct 2005
Location: Ukraine
Posts: 814
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!
 
Old 03-19-2007, 07:55 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
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!
 

Bookmarks
Thread Tools

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 06:05 PM
MT4 Function Details BC Brett Questions 3 04-25-2006 10:38 PM
MT4 function/EA question eastmaels Questions 2 04-16-2006 03:43 AM
function details niva Questions 4 04-08-2006 07:15 PM


All times are GMT. The time now is 08:49 AM.



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