PDA

View Full Version : Elder's - Force Index


T2020
02-15-2009, 08:45 PM
Anyone ever write this indicator ? It's =
Today's volume x (today's close - yesterdays close )
Smoothed by an 2 or 13 period EMA or of your choice basically .
Plots above or below a zero line . tia

NinjaTrader_Bertrand
02-16-2009, 03:30 AM
Hi, you can take a look at the one in our sharing section - http://www.ninjatrader-support2.com/vb/local_links_search.php?action=show&literal=1&search=force+index&desc=1

T2020
02-16-2009, 06:21 AM
Thanks Bertrand .
Looks like the right formula .

golfer
04-30-2009, 07:54 AM
I am trading the force index on FX Sol Accucharts with the following parameters Period 8, EMA 3 and EMA 8. This combo gives excellent signals. Can anyone guide me to how I could alter the NT version of Force Index to user defined number of periods? And possibly keep it simple...I'm definitely coding challenged.
TIA

NinjaTrader_Bertrand
04-30-2009, 08:01 AM
Hi golfer, welcome to our support forums! You can right click on the chart and bring the 'Indicators' section up, then change the Fast / Slow MA types and periods to your needs.

golfer
04-30-2009, 09:37 AM
Thanks for your reply Bertrand. I want to change the period of the Force Index. The formula gives you a default of 1 period. I would like this to be user adjustable. I prefer 8 periods which I currently use on Accucharts but would prefer to use NT on Gain. Changing the ma's is not the issue. Thanks.

e-man
04-30-2009, 09:44 AM
is that an SMA of the previous 8 periods, upon which you apply the other two EMAs?

golfer
04-30-2009, 09:49 AM
Hi E man. Not sure..I think the 8 periods are the calculation. If not, then it must be sma.I would think something like setting periods for an RSI. As I said below, I'm definately coding challenged. Any help is appreciated

e-man
04-30-2009, 10:06 AM
reviewing the RSI code here to compare ... for the first X bars that are less than {Period}, the RSI is set to 50 (the midline) ... then on the bar that closes equal to {Period}, it initializes the down and up averages by doing an SMA on the previous {Period} bars ... and for each bar after that, it recalcs the up/down to include the latest bar and then does the other smoothing, etc.

here's the formula for ForceIndex:
Volume[0]*(Close[0]-Close[1]);
// multiply volume by the thisBarClose - lastBarClosefollowing the RSI example you cited, we would do nothing for the bars less than {Period} ... but the question becomes: what to do on the {Period} bar?
a) set to an SMA of the previous {Period} bars calculation;
b) take the sum of the volume for the last {Period} bars, multiply that by the sum of last {Period} bars close (including current bar) minus sum of the last {Period} + 1 bars, not including current bar;

if you're following the math on b) ... you would realize that we're canceling out all the {Period} bars except the current one and then subtracting the {Period} -1 bar (eg. if {Period} was 3, then it would be ((close[bar0]+close[bar1]+close[bar2]) - (close[bar1]+close[bar2]+close[bar3])), which is really close[bar0]-close[bar3])

i'll stop now ... perhaps there is a c) that i'm not understanding ... and now that i think about it, maybe a) and b) are the same thing?

what you're proposing is do-able, just need to understand how you want to handle those other periods.

NinjaTrader_Bertrand
04-30-2009, 10:13 AM
Hi golfer and e-man, then you just would need to code the basic force index period as a user defined input, more on this can be found here - http://www.ninjatrader-support2.com/vb/showthread.php?t=5782

If this is above your coding appetite, you can always contact those NinjaScript consultants - http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

golfer
04-30-2009, 10:23 AM
Thanks for your help guys. E-man, does Bertrands reply help? I looked at it the link and it seems to be what I'm after. Now, I'll put on my coding hat and see what I can do.........should prove interesting...:) Does this make sense to you e-man?

e-man
04-30-2009, 11:33 AM
yes, having period as an input parm is a given ...

but you still need to determine whether you want to do an SMA of the forceIndex over {Period} (as i outlined in option-a) or if you want to multiply average volume of last {Period} bars * close[bar0] - close[barX] where barX is the one prior to {Period} (as i outlined in option-b) ...

the SMA is probably easier/quicker, so unless you are confident you want option-b, i can throw together option-a for you and upload it later today and you can have a look ...

having said that, if neither option-a or option-b above are the correct "formula", then if you could suggest the correct formula, that would be helpful.

golfer
04-30-2009, 11:38 AM
E-man..would you mind doing the SMA version..sounds like a typical parameter and I can try it and compare to the one I'm using now.
Your help is greatly appreciated.:)

e-man
04-30-2009, 12:59 PM
ok...here you go. if you set the Period to 1, then it should look exactly like the regular ForceIndex.

let me know if changing the Period in the new indicator achieves the same effect as in accucharts.

and if not, could you post a screenshot that shows the ForceIndex(Period:1) and ForceIndex(Period:8) ;)

golfer
04-30-2009, 02:53 PM
Hi e-man. Sorry for the delay getting back to you. I'm at work and actually had to do some.(work that is) I tried your revamped version and it is close. I did some searching and found the formula accucharts uses and it looks like they use an Ema (Force x= mov"E"). If that was an "S" it would be SMA
Does this help?

FUNCTION( price, period, volume )

VAR
force;
force_x;

BEGIN
IF CurrentBar < period THEN
RETURN;
ELSE
force = volume * (price - price[1]);
IF force <> NaN() THEN
force_x = move (force, period, 0);
END_IF;
END_IF;

FUNCTION = force_x;
END_FUNCTION

golfer
04-30-2009, 02:55 PM
Also, it would be nice to plot the Force in a bar (histo) as there are clues to be gained from it. Thanks again e-man......hate to impose but I go in circles when it comes to coding.

e-man
04-30-2009, 02:58 PM
if it's just swapping EMA for SMA, then that's a 10-second fix:

tools | edit ninjascript | indicator > ForceIndex2

find lines 63-64:
// create SMA-Period of ForceIndex
arrForceIndexPeriod.Set(SMA(arrForceIndex,Period)[0]);change to:
// create EMA-Period of ForceIndex
arrForceIndexPeriod.Set(EMA(arrForceIndex,Period)[0]);hit F5 to compile and then F5 on your chart to refresh and see if that does the trick.

if that solves the "math" issue, then we'll get to the histogram :)

golfer
04-30-2009, 03:08 PM
Thanks e-man....that's it!! looks almost identical to the accucharts and allowing for the fact the data is different, I would say you've got it. Thank you so much!!

e-man
04-30-2009, 03:32 PM
excellent! got your other changes in:
- added the histogram that plots the ForceIndex
- colored histogram up-tick bars green, down-tick bars red like elder's MACD but you can set these to a neutral color if you prefer
- allowed for you to select the PeriodType (EMA, SMA, etc.) and set it to default to EMA
- also added an outline of the ForceIndex, but set the default color to Transparent (this is a personal preference of mine on MACD and figured i'd give you that capability if you like/need).

so here 'tis ... enjoy,
-e

golfer
04-30-2009, 04:15 PM
e-man you da bomb man!! (Randy on American Idol). Really appreciate your expertise on this. I owe you a round of golf if you ever get to Calgary! Can't figure how to load a screenshot (too big) or would attach it for you. Looks identical allowing for the different data. Thanks again e-man!

e-man
04-30-2009, 08:04 PM
sounds like a plan, golfer ... i'll hit you up next time i head to the rockies!

cheers,
-e

ctrlbrk
04-30-2009, 09:16 PM
e-man,

Thank you for this indicator. However, there seems to be a fundamental issue with the display scaling.

I am trying to think of a way to overcome this, but frankly do not know how.

The issue is that in times of lower volume, the indicator will appear to flat-line near the zero-line because the actual Values for the indicator are too small vs. the historical scale.

Any idea on how to make this more of a 0-based indicator, with a max 100/-100 setting?

Mike

NinjaTrader_Bertrand
05-01-2009, 04:00 AM
Hi Mike, you could run this through another osc like Stoch or RSI, maybe also apply Ehlers Fisher Transform to it to normalize.

e-man
05-04-2009, 11:57 AM
hey Mike,

good point on the change needed ... i was looking thru the code for RSI like Bertrand suggested, and these two lines seem to do the magic:

double rs = avgUp[0] / (avgDown[0] == 0 ? 1 : avgDown[0]);
double rsi = 100 - (100 / (1 + rs));

i compared it to Stochastics, and there is some similar code in there as well ... so if i'm understanding your suggestion, we would need to "normalize the range" of the volume bars (histogram up/down) ... only problem there is that the math behind it is:

arrForceIndex.Set(Volume[0]*(Close[0]-Close[1]));

if you compare this to a MACD for example, the math behind the histogram there is the difference of a couple EMAs ... so it's post-processed data, if you will ... haven't had a chance to really think thru this, but figured i'd post my initial thoughts to see if anyone else wanted to weigh in on next steps.

thanks,
-e

John_Aus
05-17-2009, 10:03 PM
Has anyone been able to have the Force Index scale in a better fashion?
John