| / | Forum |
|
myfuture2025
2007.07.22 07:05
I'm trying to determine direction of "AMA & AMA sig" indicator with
the icustom command. extern int periodAMA = 5; 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. |
|
All about Automated Trading Championship: Additional Materials of Championships 2006-2007 We present to you a selection of these materials that are divided into several parts. The present one contains additional materials about automated trading, Expert Advisors development, etc. |
|
richplank
2007.07.22 08:12
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". |
|
myfuture2025
2007.07.23 01:19
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 ) |
|
myfuture2025
2007.07.23 01:21
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 } |
|
richplank
2007.07.23 03:12
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. |