AccountProfit( ) return as pips?

 

I am using the following code to display the profit of my trades right on the chart:

double accp = AccountProfit();

ObjectCreate("ap", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap","Profit: $",14, "Arial Bold", White);

ObjectSet("ap", OBJPROP_CORNER, 0);

ObjectSet("ap", OBJPROP_XDISTANCE, 900);

ObjectSet("ap", OBJPROP_YDISTANCE, 2);

ObjectCreate("ap1", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap1",DoubleToStr (accp, 2),14, "Arial Bold", White);

ObjectSet("ap1", OBJPROP_CORNER, 0);

ObjectSet("ap1", OBJPROP_XDISTANCE, 995);

ObjectSet("ap1", OBJPROP_YDISTANCE, 2);

Is there any way to make the function return the profit as pip's like you can do in the Terminal - Trade tab?

 
Mazoem:
I am using the following code to display the profit of my trades right on the chart:

double accp = AccountProfit();

ObjectCreate("ap", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap","Profit: $",14, "Arial Bold", White);

ObjectSet("ap", OBJPROP_CORNER, 0);

ObjectSet("ap", OBJPROP_XDISTANCE, 900);

ObjectSet("ap", OBJPROP_YDISTANCE, 2);

ObjectCreate("ap1", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap1",DoubleToStr (accp, 2),14, "Arial Bold", White);

ObjectSet("ap1", OBJPROP_CORNER, 0);

ObjectSet("ap1", OBJPROP_XDISTANCE, 995);

ObjectSet("ap1", OBJPROP_YDISTANCE, 2);

Is there any way to make the function return the profit as pip's like you can do in the Terminal - Trade tab?

no. theres no way.

 

could you make some kind of var that holds ask or bid and assoiate that with specific entrys and compare to current ask or bid

 
lowphat:
could you make some kind of var that holds ask or bid and assoiate that with specific entrys and compare to current ask or bid

I was hoping to just find a function call I didnt know about... but I understand what your saying.

 
squigglefunk:
no. theres no way.

Wow, that is a fantastic answer with a reason. It must have taken you all week to figure that one out.

 
Mazoem:
I am using the following code to display the profit of my trades right on the chart:

double accp = AccountProfit();

ObjectCreate("ap", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap","Profit: $",14, "Arial Bold", White);

ObjectSet("ap", OBJPROP_CORNER, 0);

ObjectSet("ap", OBJPROP_XDISTANCE, 900);

ObjectSet("ap", OBJPROP_YDISTANCE, 2);

ObjectCreate("ap1", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ap1",DoubleToStr (accp, 2),14, "Arial Bold", White);

ObjectSet("ap1", OBJPROP_CORNER, 0);

ObjectSet("ap1", OBJPROP_XDISTANCE, 995);

ObjectSet("ap1", OBJPROP_YDISTANCE, 2);

Is there any way to make the function return the profit as pip's like you can do in the Terminal - Trade tab?

Cool. i've been looking for an indicator to do this. Could you post the actual indicator code

 
waaustin:
Cool. i've been looking for an indicator to do this. Could you post the actual indicator code

I sent you a PM to find out more.

 

I think it is possible:

Just:

1. Check number of open trades,

2. for each open trade {

- Calculate the pip value of this symbol using the following function

- Calculate profit and calculate profit / pipvalue

- add this value to total pips

- Calculate the value of the swap for this order

- Add (swap / pipvalue) to swappips

}

//+--------- --------- --------- --------- --------- --------- ----+

//+ Calculate cost in USD of 1pip of given symbol

//+--------- --------- --------- --------- --------- --------- ----+

double PipCost (string TradeSymbol) {

double Base, Cost;

string TS_13, TS_46, TS_4L;

TS_13 = StringSubstr (TradeSymbol, 0, 3);

TS_46 = StringSubstr (TradeSymbol, 3, 3);

TS_4L = StringSubstr (TradeSymbol, 3, StringLen(TradeSymb ol)-3);

Base = MarketInfo (TradeSymbol, MODE_LOTSIZE) * MarketInfo (TradeSymbol,

MODE_POINT);

if ( TS_46 == "USD" )

Cost = Base;

else if ( TS_13 == "USD" )

Cost = Base / MarketInfo (TradeSymbol, MODE_BID);

else if ( PairExists ("USD"+TS_4L) )

Cost = Base / MarketInfo ("USD"+TS_4L, MODE_BID);

else

Cost = Base * MarketInfo (TS_46+"USD" , MODE_BID);

return(Cost) ;

}

//+--------- --------- --------- --------- --------- --------- ----+

//+ Returns true if given symbol exists

//+--------- --------- --------- --------- --------- --------- ----+

bool PairExists (string TradeSymbol) {

return ( MarketInfo (TradeSymbol, MODE_LOTSIZE) > 0 );

}

If you need help coding this I can help you tomorow.

roger

 
kokas:
I think it is possible:

Just:

1. Check number of open trades,

2. for each open trade {

- Calculate the pip value of this symbol using the following function

- Calculate profit and calculate profit / pipvalue

- add this value to total pips

- Calculate the value of the swap for this order

- Add (swap / pipvalue) to swappips

}

//+--------- --------- --------- --------- --------- --------- ----+

//+ Calculate cost in USD of 1pip of given symbol

//+--------- --------- --------- --------- --------- --------- ----+

double PipCost (string TradeSymbol) {

double Base, Cost;

string TS_13, TS_46, TS_4L;

TS_13 = StringSubstr (TradeSymbol, 0, 3);

TS_46 = StringSubstr (TradeSymbol, 3, 3);

TS_4L = StringSubstr (TradeSymbol, 3, StringLen(TradeSymb ol)-3);

Base = MarketInfo (TradeSymbol, MODE_LOTSIZE) * MarketInfo (TradeSymbol,

MODE_POINT);

if ( TS_46 == "USD" )

Cost = Base;

else if ( TS_13 == "USD" )

Cost = Base / MarketInfo (TradeSymbol, MODE_BID);

else if ( PairExists ("USD"+TS_4L) )

Cost = Base / MarketInfo ("USD"+TS_4L, MODE_BID);

else

Cost = Base * MarketInfo (TS_46+"USD" , MODE_BID);

return(Cost) ;

}

//+--------- --------- --------- --------- --------- --------- ----+

//+ Returns true if given symbol exists

//+--------- --------- --------- --------- --------- --------- ----+

bool PairExists (string TradeSymbol) {

return ( MarketInfo (TradeSymbol, MODE_LOTSIZE) > 0 );

}

If you need help coding this I can help you tomorow.

roger

WOW! Now that is good stuff... I will start working with this right now. Thank you very much. I may have a few questions for you later.

Thanks again,

Jon

Reason: