How to plot Profit & Loss? Nobody know?

 

Is there an example of how to call the AccountProfit function in an indicator

anywhere as I can't find it? Yes I am a frustrated NEWBIE !


How can this be so DIFFICULT ?

 

1 should write a EA use AccountProfit function, and set profit to some globle variables.

2 inside indicator file, get those globle variables to set indicator buffer arrays, and draw them in separate window.

you can test it use EA test mode, but maybe not easy test it on real mode, since in real mode, such indicator has no histor to draw,

in other word, maybe you only can watch the profit change after MT runing, since AccountProfit only can get current state of account.

 
DxdCn:

1 should write a EA use AccountProfit function, and set profit to some globle variables.

2 inside indicator file, get those globle variables to set indicator buffer arrays, and draw them in separate window.

you can test it use EA test mode, but maybe not easy test it on real mode, since in real mode, such indicator has no histor to draw,

in other word, maybe you only can watch the profit change after MT runing, since AccountProfit only can get current state of account.


Hello DxdCn, this seems to work.


//+------------------------------------------------------------------+
//| Current_Profits.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

ExtMapBuffer1[0] = AccountProfit();
return(0);
}
//+------------------------------------------------------------------+

Reason: