| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #1 | ||
![]() | Iff Function Different Averages regards this is the code: Inputs: Price (c),Period (30); vars : val(0); if BarType >= 2 then val= volume else val = ticks; value1 = iff (Momentum (Price, 1) > 0, momentum(price,1)*val, 0.0001); value2 = average(value1,period); value3 = Average (iff (Momentum (Price, 1) > 0, momentum(price,1)*val, 0.0001), Period); plot1(value2); plot2(value3); | ||
| |
|
| | #2 | ||
![]() | Re: Iff Function Different Averages because the current value of val is used for every iteration of the "average" calculation.
__________________ Only an idiot would reply to a stupid post | ||
| |
|
| | #3 | ||
![]() | Re: Iff Function Different Averages you mean this average summation is the following momentum(price,1)*val + momentum(price,1)[1] *val to period instead momentum(price,1)*val + momentum(price,1)[1] *val[1] to period .. maybe i havn't understood though. regards | ||
| |
|
| | #4 | ||
![]() | Re: Iff Function Different Averages Quote:
I don't understand what you are talking about either. just use plot1 and you won't have the problem.
__________________ Only an idiot would reply to a stupid post | ||
| |
|
| | #5 | ||
![]() | Re: Iff Function Different Averages vars : val(0),return(0); if BarType >= 2 then val= volume else val = ticks; if 100 - 100 / (1 + Average (iff (Momentum (Price, 1) > 0, Momentum (Price, 1) * val, 0), Period) / Average (iff (Momentum (Price, 1) < 0, -1 * Momentum (Price, 1) * val, 0), Period)) <> 0 then Return = 100 - 100 / (1 + Average (iff (Momentum (Price, 1) > 0, Momentum (Price, 1) * val, 0), Period) / Average (iff (Momentum (Price, 1) < 0, -1 * Momentum (Price, 1) * val, 0), Period)) ; if 100 - 100 / (1 + Average (iff (Momentum (Price, 1) > 0, Momentum (Price, 1) * val, 0), Period) / Average (iff (Momentum (Price, 1) < 0, -1 * Momentum (Price, 1) * val, 0), Period)) = 0 then Return = .0001; plot1(return); the code above is the original indicator..gives floating point errors when period<30.. i try to simplify the code by the following lines vars :prval(0),plusval(0); prval = c-c[1]; if prval > 0 then plusval = prval*val else plusval = 0; value1 = iff (Momentum (Price, 1) > 0, momentum(price,1)*val, 0); value2 = average(value1,period); value3 = Average (iff (Momentum (Price, 1) > 0, momentum(price,1)*val, 0), Period); plusval and value1 are exactly the same so do their averages value2 and the eqivelent average of plusval.. value3 plots slightly different values.. but these is the segment of the original code.. so i was wondering why the average of the iff value(value2) is different than value3.. i was thinking maybe there is something between these two statments worth exploring thanks for your patience regards | ||
| |
|
| | #6 | ||
![]() | Re: Iff Function Different Averages see the # symbol in the reply box. Code: ... put codes here ...
__________________ Only an idiot would reply to a stupid post Last edited by Tams; 08-31-2009 at 12:18 PM. | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Zero Lag Moving Averages | phase21 | Trading Indicators | 2 | 08-14-2009 02:54 AM |
| Moving Averages Again... | TacTrader | Technical Analysis | 5 | 01-12-2009 02:16 PM |
| MACD with Hull Moving Averages | Soultrader | Trading Indicators | 2 | 09-06-2007 05:52 PM |
| Moving Averages: Which one should I use? | Blaze | Technical Analysis | 7 | 08-27-2006 08:04 AM |