DefindTrade(..) function

 

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

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(i, SELECT_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 1 : D2R += OrderProfit();break; //index 1 : Real Profit

case 2 : D2R += OrderSwap();break; //index 2 : Swap Profit

case 3 : D2R += (OrderProfit()+OrderSwap());break;//index 3 : Overall Profit

case 4 : D2R += OrderLots();break; //index 4 : OrderLots (Normally count total of from -> to)

case 5 : D2R = OrderOpenPrice();break; //index 5 : OrderOpenPrice

case 6 : D2R = OrderOpenTime();break; //iddex 6 : OrderOpenTime

case 7 : D2R = OrderStopLoss();break; //index 7 : OrderStopLoss

case 8 : D2R = OrderTakeProfit();break; //index 8 : OrderTakeProfit

case 9 : D2R = OrderTicket();break; //index 9 : OrderTicket

case 10: D2R = OrderClosePrice();break; //index 10: OrderClosePrice

case 11: D2R = OrderCloseTime();break; //index 11: OrderCloseTime

//case 12: D2R = OrderComment();break; //index 12: OrderComment <-- can not return string

case 13: D2R = OrderCommission();break; //index 13: OrderCommission

case 14: D2R = OrderExpiration();break; //index 14: OrderExpiration

case 15: D2R = OrderMagicNumber();break; //index 15: OrderMagicNumber

//case 16: D2R = OrderSymbol();break; //index 16: OrderSymbol <-- can not return string

case 17: D2R = 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);

}

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

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

and this , to turn the ordertype into string

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]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

 

I wish I was clever like what you are phoenix

brilliant

 
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

 

Good job Phoenix. You are smart in your own way

 
Maji:
Good job Phoenix. You are smart in your own way

THANKS BUDDY

 

i've added something new pls take a look the code above again

enjoy

 
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

 
pete7:
Very handy function! Thanks a lot mate!

Best Regards,

P7

thank you

but edited something pls take a look again..hehe

Reason: