Also when I Compile the code AGAIN in MetaEditor, Indicator is fixed in Metatrader.
Any Opinion?
double FreeMargin = AccountFreeMargin(); double Equity = AccountEquity();These are constant throughout the loop. Posting your histogram on previous bars is nonsense.
William Roeder #:
These are constant throughout the loop. Posting your histogram on previous bars is nonsense.
These are constant throughout the loop. Posting your histogram on previous bars is nonsense.
It works fine until the terminal is open. it change constantly and no problem with it.
The problem appears when I close the terminal and re-open it.
By the way,
AccountFreeMargin()
AccountEquity()
Dont have any argument. How can I use them as variable?
#property strict #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 clrBlue #property indicator_style1 STYLE_SOLID #property indicator_type1 DRAW_HISTOGRAM #property indicator_width1 2 double g_adbExposure[]; int OnInit() { SetIndexBuffer( 0, g_adbExposure, INDICATOR_DATA ); return( INIT_SUCCEEDED ); }; int OnCalculate( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) { if( rates_total > 0 ) { double dbAccountMarginFree = AccountInfoDouble( ACCOUNT_MARGIN_FREE ); g_adbExposure[ 0 ] = ( dbAccountMarginFree > 0.0 ) || ( dbAccountMarginFree < 0.0 ) ? 100.0 * ( AccountInfoDouble( ACCOUNT_EQUITY ) - dbAccountMarginFree ) / dbAccountMarginFree : 0.0; }; return rates_total; };
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi. I want to check account used margin so I write this code and use it as an indicator:
Everything is Ok, but when I close Metatrader terminal and I open it again, the values disappear and the indicator values are null and nothing is calculated (Look at the below picture). So I have to run the indicator again. What is the reason and how can I fix it?
I appreciate any help or advise.
Thanks.