Forex
Google

Go Back   Forex Trading > Downloads > Tools and utilities
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 09-13-2006, 03:47 AM
phoenix's Avatar
phoenix phoenix is offline
Senior Member
 
Join Date: May 2006
Posts: 287
phoenix is on a distinguished road
Wink DefindTrade(..) function

i've invented this function and realized that maybe i can share to you all.

PHP Code:
double DefineTrade(string symbol,int MagicNo,int from,int to,int mode,int index)
double D2R =0;
for(
int i=from;i<=to;i++)
{
if(
OrderSelect(iSELECT_BY_POS,mode))
{
if(
OrderSymbol()==symbol || symbol==""//Leave it "" like this to run the overall data
{
if(
OrderMagicNumber()==MagicNo || MagicNo==0//Make it 0 to run the overall data
{
switch(
index)
{
case 
D2R += OrderProfit();break; //index 1 : Real Profit
case D2R += OrderSwap();break; //index 2 : Swap Profit
case D2R += (OrderProfit()+OrderSwap());break;//index 3 : Overall Profit
case D2R += OrderLots();break; //index 4 : OrderLots (Normally count total of from -> to)
case D2R OrderOpenPrice();break; //index 5 : OrderOpenPrice
case D2R OrderOpenTime();break; //iddex 6 : OrderOpenTime 
case D2R OrderStopLoss();break; //index 7 : OrderStopLoss
case D2R OrderTakeProfit();break; //index 8 : OrderTakeProfit
case D2R OrderTicket();break; //index 9 : OrderTicket
case 10D2R OrderClosePrice();break; //index 10: OrderClosePrice
case 11D2R OrderCloseTime();break; //index 11: OrderCloseTime
//case 12: D2R = OrderComment();break; //index 12: OrderComment <-- can not return string
case 13D2R OrderCommission();break; //index 13: OrderCommission
case 14D2R OrderExpiration();break; //index 14: OrderExpiration 
case 15D2R OrderMagicNumber();break; //index 15: OrderMagicNumber
//case 16: D2R = OrderSymbol();break; //index 16: OrderSymbol <-- can not return string
case 17D2R OrderType();break; //index 17: OrderType <-- 0 = OP_BUY
/* 1 = OP_SELL
2 = OP_BUYLIMIT
3 = OP_SELLLIMIT
4 = OP_BUYSTOP 
5 = OP_SELLSTOP 
*/
case 18: {switch(OrderType()) //index 18: OrderProfit in Point
{case OP_SELL D2R = (OrderOpenPrice()-OrderClosePrice())/Point;break;
case 
OP_BUY D2R = (OrderClosePrice()-OrderOpenPrice())/Point;break;
}

case 
19: {switch(OrderType()) //index 19: TotalProfit in Point
{case OP_SELL D2R+= (OrderOpenPrice()-OrderClosePrice())/Point;break;
case 
OP_BUY D2R+= (OrderClosePrice()-OrderOpenPrice())/Point;break;


}
}
}
}
}
return(
D2R);

last Update : 14/sep/2006 04:00 GMT+1

**************

and this , to turn the ordertype into string
PHP Code:
string Val2Type(double val)
{
string S2R;
  switch(
val)
  {
   case 
0:S2R="OP_BUY";break;
   case 
1:S2R="OP_SELL";break;
   case 
2:S2R="OP_BUYLIMIT";break;
   case 
3:S2R="OP_SELLLIMIT";break;
   case 
4:S2R="OP_BUYSTOP";break;
   case 
5:S2R="OP_SELLSTOP";break;
  }

return(
S2R);

last Update : 13/sep/2006 14:00 GMT+1

**************

and print the result like this

PHP Code:
Print("lastticket = ",DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,9),
" | LastOOP = ",DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,5),
" | realProfit = ",DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,1),
" | SwapProfit = ",DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,2),
" | AllProfit = ",DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,3),
" | OrderType = ",Val2Type(DefindTrade(Symbol(),0,HistoryTotal()-1,HistoryTotal(),MODE_HISTORY,17))//<==last Update : 13/sep/2006 14:00 GMT+1
); 
*********

from the above function i want to defind the last closed order
-then i select the period from historytotal-1 to historytotal ,
-select the mode of loop to mode_history,
-defind the index i want ot print out

and this the result

USDJPY,M5: lastticket = 4215030 | LastOOP = 117.87 | realProfit = 78.08 | SwapProfit = -32.38 | AllProfit = 45.7 | OrderType = OP_SELL

*********

hope you like it

Last edited by phoenix : 09-15-2006 at 03:28 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-13-2006, 04:38 AM
increase's Avatar
increase increase is offline
Senior Member
 
Join Date: May 2006
Posts: 605
increase is on a distinguished road
I wish I was clever like what you are phoenix

brilliant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-13-2006, 04:43 AM
phoenix's Avatar
phoenix phoenix is offline
Senior Member
 
Join Date: May 2006
Posts: 287
phoenix is on a distinguished road
Quote:
Originally Posted by increase
I wish I was clever like what you are phoenix

brilliant
THANK YOU

but I was clever like coderguru or the author of multi-lot-scalper
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-13-2006, 04:53 AM
Maji Maji is offline
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Good job Phoenix. You are smart in your own way
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-13-2006, 05:06 AM
phoenix's Avatar
phoenix phoenix is offline
Senior Member
 
Join Date: May 2006
Posts: 287
phoenix is on a distinguished road
Quote:
Originally Posted by Maji
Good job Phoenix. You are smart in your own way
THANKS BUDDY
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-13-2006, 09:25 AM
phoenix's Avatar
phoenix phoenix is offline
Senior Member
 
Join Date: May 2006
Posts: 287
phoenix is on a distinguished road
i've added something new pls take a look the code above again

enjoy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-13-2006, 09:30 AM
pete7's Avatar
pete7 pete7 is offline
Member
 
Join Date: Jan 2006
Posts: 92
pete7 is on a distinguished road
Quote:
Originally Posted by phoenix
i've added something new pls take a look the code above again

enjoy
Very handy function! Thanks a lot mate!

Best Regards,
P7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-13-2006, 09:38 AM
phoenix's Avatar
phoenix phoenix is offline
Senior Member
 
Join Date: May 2006
Posts: 287
phoenix is on a distinguished road
Quote:
Originally Posted by pete7
Very handy function! Thanks a lot mate!

Best Regards,
P7
thank you

but edited something pls take a look again..hehe
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
EA Time function Kurka Fund Expert Advisors - Metatrader 4 4 03-19-2007 07:55 AM
Professional MM function Nicholishen Tools and utilities 13 01-31-2007 06:05 PM


All times are GMT. The time now is 12:00 PM.