terminal PROFIT variable in the graph

[Deleted]  

Hi,

to get a full graphics display (without a visible terminal) i'd like the 'profit' as a visible point in the graphics.

Where can i find that 'profit' variable ?

 
[Deleted]  

Waw quick reply :)

Thanks it's orderselect() + orderprofit() i think.

But what about ALL the current orders ?

[Deleted]  

double profit = 0;

int total=OrdersTotal();

for(int pos=0;pos<total;pos++) // open orders
{

if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

profit += (pos, OrderProfit()); // sum of all orders-profit

}

 
mate41:

double profit = 0;

int total=OrdersTotal();

for(int pos=0;pos<total;pos++) // open orders
{

if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

profit += (pos, OrderProfit()); // sum of all orders-profit

}




save your time AccountProfit()
[Deleted]  

any help needed to change the settings when the total of profit changed......

Does AccountProfit return the total amount of the orders in use ??

Here is my temporary code:

#property indicator_chart_window

extern color color1 = Yellow;
extern int FontSize = 12;
extern string note5 = "WHAT CORNER?";
extern string note6 = "UPPER LEFT=0; UPPER RIGHT=1";
extern string note7 = "LOWER LEFT=2; LOWER RIGHT=3";
extern int WhatCorner = 1;
extern int TempOrderOffset = 90;


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("TempOrderProfit");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int gi_1 = 18; // used to determine position on graph
int li_0;
int li_1;

double profit=0; // profit current orders

int total=OrdersTotal(); // count nbr of orders
if (total < 1) return (0);

if (WhatCorner == 2 || WhatCorner == 3) { // where to set the indicator
li_0 = gi_1 + 8;
li_1 = 1;
}
if (WhatCorner == 0 || WhatCorner == 1) {
li_0 = 1;
li_1 = gi_1 + 8;
}

for(int pos=0;pos<total;pos++) // count orders in use
{
if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
profit += OrderProfit(); //sum of order profits
}
// display profit in desired corner

ObjectCreate("TempOrderProfit", OBJ_LABEL, 0, 0, 0);
ObjectSetText("TempOrderProfit",DoubleToStr(profit, 2), FontSize, "Arial", color1);
ObjectSet("TempOrderProfit", OBJPROP_CORNER, WhatCorner);
ObjectSet("TempOrderProfit", OBJPROP_XDISTANCE, 1);
ObjectSet("TempOrderProfit", OBJPROP_YDISTANCE, li_0 + TempOrderOffset);

return (0);
}

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

 
mate41:

Does AccountProfit return the total amount of the orders in use ??


yes
[Deleted]  
qjol:
yes

Thanks for your time,

Sorry, it's my first code and i have to be sure..

here are the changes:

int start()
{
int gi_1 = 18; // used to determine position on graph
int li_0;
int li_1;

double profit=0; // profit current orders

int total=OrdersTotal(); // count nbr of orders
if (total < 1) return (0);

if (WhatCorner == 2 || WhatCorner == 3) { // where to set the indicator
li_0 = gi_1 + 8;
li_1 = 1;
}
if (WhatCorner == 0 || WhatCorner == 1) {
li_0 = 1;
li_1 = gi_1 + 8;
}

/*for(int pos=0;pos<total;pos++) // count orders in use
{
if(OrderSelect(pos,SELECT_BY_POS)==false) continue;
profit += OrderProfit(); //sum of order profits
} */
ObjectDelete("TempOrderProfit");
// display profit in desired corner
if(ObjectFind("TempOrderProfit") != 0) {
ObjectCreate("TempOrderProfit", OBJ_LABEL, 0,Time[0], 0);
ObjectSetText("TempOrderProfit",DoubleToStr(AccountProfit(), 2), FontSize, "Arial", color1);
ObjectSet("TempOrderProfit", OBJPROP_CORNER, WhatCorner);
ObjectSet("TempOrderProfit", OBJPROP_XDISTANCE, 1);
ObjectSet("TempOrderProfit", OBJPROP_YDISTANCE, li_0 + TempOrderOffset);
} else
{
ObjectMove("TempOrderProfit", 0, Time[0], Close[0]);
}
return (0);

}