Note that the second last argument to iCustom is the index of the data buffer to
pick a value from. You have used "MODE_SIGNAL" which incidentally is
1 and thus it happens to be the index for the up signal data buffer of the "AMA & AMA sig" indicator. The down signal data buffer has index 2. You might want a code snippet like the following:
if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE, 1, 0) != 0 ) { .. up signal } else if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE, 2, 0) != 0 ) { .. down signal } else { .. no signal }As for showing up as 0 or 1 only, I suspect your AmaSig variable is declared as "int" rather than "double".
Hi richplank,
Thanks for your help, however i still get "AmaSig no signal:" all time even trend going up or down. Do you have any other idea please help.
if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE,
1, 0) != 0 )
{
Comment("AmaSig up:");//.. up signal
}
else if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast,
PRICE_CLOSE, 2, 0) != 0 )
{
Comment("AmaSig down:");//.. down signal
}
else
{
Comment("AmaSig no signal:");//.. no signal
}
if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE,
1, 0) != 0 )
{
Comment("AmaSig up:");//.. up signal
}
else if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE, 2, 0) != 0 )
{
Comment("AmaSig down:");//.. down signal
}
else
{
Comment("AmaSig no signal:");//.. no signal
}
{
Comment("AmaSig up:");//.. up signal
}
else if ( iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE, 2, 0) != 0 )
{
Comment("AmaSig down:");//.. down signal
}
else
{
Comment("AmaSig no signal:");//.. no signal
}
The indicator "AMA & AMA sig" is of the kind that "repaints the
past", i.e., as a new bar comes in, it recomputes values for all the bars
on the charts, including any signals. By the looks of it, the calculations are
stable, and should produce the same values for all bars, except for the two most
recent bars, which get updated with new values. In particular, I would guess that
bar 0 is a useless value, and you should probably access the bar 1 value instead.
You'd use 1 as last argument to the iCustom(...) function for this.
Alternatively, you edit the indicator code and replace all "Close[..]" with "Open[. .]".
The point is that the indicator uses the bar close values, which is fine for all bars except the most recent one, since that bar has just begun to be formed when the calculations happen. At the time of the calculation, the close of bar 0 coincides with the open of bar 0, and then it keeps changing as new ticks come in, although the indicator doesn't recalculate for that bar until the next bar begins.
Alternatively, you edit the indicator code and replace all "Close[..]" with "Open[. .]".
The point is that the indicator uses the bar close values, which is fine for all bars except the most recent one, since that bar has just begun to be formed when the calculations happen. At the time of the calculation, the close of bar 0 coincides with the open of bar 0, and then it keeps changing as new ticks come in, although the indicator doesn't recalculate for that bar until the next bar begins.
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
I'm trying to determine direction of "AMA & AMA sig" indicator with the icustom command.
This is what i have so far:
extern int periodAMA = 5;
extern int nfast = 2;
extern int nslow = 30;
AmaSig = iCustom(NULL, 0, "AMA & AMA sig", periodAMA, nslow, nfast, PRICE_CLOSE, MODE_SIGNAL, 0);
Comment(" AmaSig: ",AmaSig);
I received mostly AmaSig=0 value even the trend going up or down. Sometimes i received AmaSig=1 but i don't understand why it show value 1. i think the receive value is not correct.
I want to know when the indicator "AMA & AMA sig" signal trend up or trend down.
How would i determine the trend of the "AMA & AMA sig" indicator with the icustom function?
Thanks