Forex



Go Back   Forex Trading > Downloads > Tools and utilities
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 09-13-2006, 04:47 AM
phoenix's Avatar
Senior Member
 
Join Date: May 2006
Posts: 319
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 04:28 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
  #2 (permalink)  
Old 09-13-2006, 05:38 AM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 845
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!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 09-13-2006, 05:43 AM
phoenix's Avatar
Senior Member
 
Join Date: May 2006
Posts: 319
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!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 09-13-2006, 05:53 AM
Senior Member
 
Join Date: Mar 2006
Posts: 794
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!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 09-13-2006, 06:06 AM
phoenix's Avatar
Senior Member
 
Join Date: May 2006
Posts: 319
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!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 09-13-2006, 10:25 AM
phoenix's Avatar
Senior Member
 
Join Date: May 2006
Posts: 319
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 09-13-2006, 10:30 AM
pete7's Avatar
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 09-13-2006, 10:38 AM
phoenix's Avatar
Senior Member
 
Join Date: May 2006
Posts: 319
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!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
EA Time function Kurka Fund Expert Advisors - Metatrader 4 4 03-19-2007 09:55 AM
Professional MM function Nicholishen Tools and utilities 13 01-31-2007 07:05 PM


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



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