- Detailed explanation of iCustom - MQL4 forum
-
You provide no information, no code, nothing; no mind readers here.
Here are the Indicator Code. It determines whether we are in Asc Swing 1 or Desc Swing - 1 just that.
SwingShow.
#property indicator_buffers 1 // Number of buffers
#property indicator_color1 Blue // Color of the line
double Buf_0[];
int i, swing_inicio, swing_fim;
string swing;
int OnInit()
{
SetIndexBuffer(0,Buf_0);
SetIndexStyle (0,DRAW_HISTOGRAM,STYLE_SOLID,5);
int FirstBar = iBars(NULL,0) -1;
swing_inicio = FirstBar;
swing_fim = FirstBar;
if (iClose(NULL,0,FirstBar-1) < iClose(NULL,0,FirstBar)) swing = "desc";
else swing = "asc";
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[] )
{
int x = rates_total - 1 - prev_calculated;
for (i=x; i > 0; i--)
if (swing == "desc")
{
Buf_0[i] = -1;
if (close[i-1] > open[swing_fim])
{
swing_inicio = swing_fim;
swing_fim = i-1;
swing = "asc";
}
if (close[i-1] < close[swing_fim])
{
swing_fim = i-1;
}
}
else if (swing == "asc")
{
Buf_0[i] = 1;
if (close[i-1] < open[swing_fim])
{
swing_inicio = swing_fim;
swing_fim = i-1;
swing = "desc";
}
if (close[i-1] > close[swing_fim])
{
swing_fim = i-1;
}
}
return(rates_total);
Now when i call it from the EA trhought iCustom function it dosen't return the expected value. Instead it shows always a very big number like 123215......
double Swing;
Swing = iCustom(Symbol(),PERIOD_CURRENT,"SwingShow",0,0);
-
Play videoPlease edit your post.
For large amounts of code, attach it.
You never set element zero. for (i=x; i > 0; i--) : Buf_0[i] = -1;
So why would you expect to read anything from element zero? Swing = iCustom(Symbol(),PERIOD_CURRENT,"SwingShow",0,0);
Thank you very much.
Big blunder :)
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
Hello.
I have made an Custom Indicator (SwingShow) that is working just fine.
Now i'm trying to make a ExpertAdvisor based on this Custom Indicator.
i have this code OnTick
....
Swing = iCustom(Symbol(),PERIOD_CURRENT,"SwingShow",0,0);
....
But when i check Swing it does not change, it keeps always the same.
Can anyone help please?