The usual and most straight forward way is to code an indicator for calculating and drawing the lines then use iCustom() in the EA to get the values from the indicator.
The usual and most straight forward way is to code an indicator for calculating and drawing the lines then use iCustom() in the EA to get the values from the indicator.
Thanks for your direction. I found a good explanation of iCustom at, https://book.mql4.com/samples/shared.
- MisterDog:My Polyline code does exactly that. It's easier to make CIs, but if you need to verify iCustom data in the EA or the values are generated in the EA, then PL works reasonable. I even use it to plot how it trailed the SL which can't be done in a CI.
Is it possible to draw something like a Moving Average line from an Expert Advisor like you can and Indicator?
- MisterDog:See also Detailed explanation of iCustom - MQL4 forum
Thanks for your direction. I found a good explanation of iCustom at, https://book.mql4.com/samples/shared
I give up! What’s my trouble here with iCustom? My iCustom should return the price of some envelope bands but it does not. It returns the value, 2147483647.
I have read the Book and forum discussions on iCustom.
Here is what I have in the Indicator:
Indicator name:
“Pentaria-Ind-v1”
All external properties:
extern int MAPeriod = 20;
extern int SlopePeriod = 10;
extern double EnvSpread = 0.0005;
extern double BandPush = 3.5;
Indicator defined buffers:
SetIndexBuffer(0,MABuffer);
SetIndexBuffer(1,EnvTopBuffer);
SetIndexBuffer(2,EnvBotBuffer);
And a bit of code from the Indicator Start function:
…
TopBuf = (EnvSpread+(Delta*BandPush))+iMA(NULL,0,MAPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
BotBuf = (-EnvSpread+(Delta*BandPush))+iMA(NULL,0,MAPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
EnvTopBuffer[i] = TopBuf;
EnvBotBuffer[i] = BotBuf;
Alert ("Ind: High-",High[1]," EnvTopBuffer-",TopBuf," | Low-",Low[1]," EnvBotBuffer-",BotBuf);
Everything works fine with the indicator. It draws envelope bands and the values of the Alert are reasonable.
Here is what I am doing in the EA:
The relevant external EA properties are identical:
…
extern int MAPeriod = 20;
extern int SlopePeriod = 10;
extern double EnvSpread = 0.0005;
extern double BandPush = 3.5;
…
Here is the relevant code from the EA Start function:
…
double EnvTopB = iCustom(NULL,0,"Pentaria-Ind-v1", MAPeriod, SlopePeriod, EnvSpread, BandPush, 1, 0);
double EnvBotB = iCustom(NULL, 0, "Pentaria-Ind-v1", MAPeriod, SlopePeriod, EnvSpread, BandPush, 2, 0);
Alert (MAPeriod," - ",SlopePeriod," - ",EnvSpread," - ",BandPush);
Alert ("High-",High[1]," EnvTopB-",EnvTopB," | Low-",Low[1]," EnvBotB-",EnvBotB);
…
The first Alert returns reasonable values but in the second Alert, EnvTopB and EnvBotB both return the value, 2147483647. I am expecting a reasonable price from these variables.
I noticed in several examples that #define was used. I think this is optional.
Is there something obvious here?
--Thanks
The first Alert returns reasonable values but in the second Alert, EnvTopB and EnvBotB both return the value, 2147483647.
--Thanks
I give up! What’s my trouble here with iCustom? My iCustom should return the price of some envelope bands but it does not. It returns the value, 2147483647.
I have read the Book and forum discussions on iCustom.
Here is what I have in the Indicator:
Indicator name:
“Pentaria-Ind-v1”
All external properties:
extern int MAPeriod = 20;
extern int SlopePeriod = 10;
extern double EnvSpread = 0.0005;
extern double BandPush = 3.5;
Indicator defined buffers:
SetIndexBuffer(0,MABuffer);
SetIndexBuffer(1,EnvTopBuffer);
SetIndexBuffer(2,EnvBotBuffer);
And a bit of code from the Indicator Start function:
…
TopBuf = (EnvSpread+(Delta*BandPush))+iMA(NULL,0,MAPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
BotBuf = (-EnvSpread+(Delta*BandPush))+iMA(NULL,0,MAPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
EnvTopBuffer[i] = TopBuf;
EnvBotBuffer[i] = BotBuf;
Alert ("Ind: High-",High[1]," EnvTopBuffer-",TopBuf," | Low-",Low[1]," EnvBotBuffer-",BotBuf);
Everything works fine with the indicator. It draws envelope bands and the values of the Alert are reasonable.
Here is what I am doing in the EA:
The relevant external EA properties are identical:
…
extern int MAPeriod = 20;
extern int SlopePeriod = 10;
extern double EnvSpread = 0.0005;
extern double BandPush = 3.5;
…
Here is the relevant code from the EA Start function:
…
double EnvTopB = iCustom(NULL,0,"Pentaria-Ind-v1", MAPeriod, SlopePeriod, EnvSpread, BandPush, 1, 0);
double EnvBotB = iCustom(NULL, 0, "Pentaria-Ind-v1", MAPeriod, SlopePeriod, EnvSpread, BandPush, 2, 0);
Alert (MAPeriod," - ",SlopePeriod," - ",EnvSpread," - ",BandPush);
Alert ("High-",High[1]," EnvTopB-",EnvTopB," | Low-",Low[1]," EnvBotB-",EnvBotB);
…
The first Alert returns reasonable values but in the second Alert, EnvTopB and EnvBotB both return the value, 2147483647. I am expecting a reasonable price from these variables.
I noticed in several examples that #define was used. I think this is optional.
Is there something obvious here?
--Thanks
Don't give up that easie. The day you born wasn't the day you walked. you had to learn that also..
2147483647 is same as EMPTY_VALUE the buffer has at bar 0 still this value
To know how iCustom works with your indicator you can make a helpEA or helpIndicator to check what is inside the buffers of the indicator
This way you learn the most about checking commands in MT4. Read here https://www.mql5.com/en/forum/138379
make something like that and you will learn how to use it..... in the EA's you wanna make
I give up! What’s my trouble here with iCustom? My iCustom should return the price of some envelope bands but it does not. It returns the value, 2147483647.
I have read the Book and forum discussions on iCustom.
Here is what I have in the Indicator:
- Detailed explanation of iCustom - MQL4 forum
- deVries:2147483647 is the value EMPTY_VALUE not EMPTY. They are different
2147483647 is same as empty value the buffer has at bar 0 still empty value - If you were getting zero, I'd suggest that the iCustom was failing and ask what GetLastError() returned. But since you are getting EMPTY_VALUE I think the iCustom is working. The indicator doesn't update bar zero. Add the indicator to a chart, open the data window, mouse to bar zero and look at the data window to confirm.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is it possible to draw something like a Moving Average line from an Expert Advisor like you can and Indicator? Or do I need to make an Indicator that uses the same logic as the EA so I can have a visual of what is going on? Is there a good way of linking the two so for example the Indicator and the EA would draw from the same Global Variable? Thanks in advance for your help.