If it's easy or something could someone post one?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Volume Weighted EMA?
Collapse
X
-
Hi GGAG33, welcome to the forum!Originally posted by GGAG33 View PostI spent 10+ hours trying to make one or figure it out and just couldn't figure out what I was doing wrong.
If it's easy or something could someone post one?
Have you tried our regular VWMA? This is like a normal SMA, but weighted by volume.
Do you mind sharing any references you have for the Vol Weighted EMA you are talking about?
Thanks!
-
Can you at least translate it into how Ninjatrader calculates it for me?
Here's the formula.
VWEMA(t-1) + (K * [Price(t) * Volume(t) - VWEMA(t-1])
------------------------------------------------------
VWEMA(t-1) (K * [Volume(t) - VWEMA(t-1)
So can anyone translate into something that Ninjatrader would understand?
Comment
-
As a last resort you can try one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htmJosh P.NinjaTrader Customer Service
Comment
-
T is Current barOriginally posted by mrlogik View PostGGA,
Can you post the code.
In order to translate this, we would need to know what
- t is
- K is
T - 1 is the past bar
K is 2 / (Period + 1)
And I have nothing worthy of posting because its just 20+ errors in them + I can't figure out how the hell Ninjatrader calculates a EMA because it looks nothing like the real equation...
This is Ninjatraders : Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]
Normal: EMA(t - 1) + (K x [Price(t) - EMA(t - 1)]
I suggest you guys change it, because all the other platforms I have tried besides this one is self explanatory. Most of the time it takes me like 10-15 minutes.
Comment
-
I know that its C#, my problem is that how do I know what Input[0] is or Value[1] is?Originally posted by NinjaTrader_Josh View PostGGAG33,
That is standard C# code. NinjaTrader is not built on a simple scripting language. You have the full power of a true programming language at your finger tips.
It says nothing about it.
Comment
-
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * Volume[0] (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]) / Input[1] * (K * Volume[0] - (1 - (2.0 / (1 + Period))) * Value[1]Originally posted by NinjaTrader_Josh View Post
Look right?
Comment
-
GGAG33,
You will have to test the accuracy of the code yourself. We are not experts on the format you are trying to convert from and as such we are not in a position to advise you. Please see this tip on debugging that you can use to help determine if you are getting accurate values: http://www.ninjatrader-support.com/v...ead.php?t=3418Josh P.NinjaTrader Customer Service
Comment
-
Okay you guys I'm having a problem...
This is happening, but it only happens if I have the Volume[0] added to the regular EMA equation.
Any suggestions on how I can fix it.
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * Volume[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
Comment
-
The picture you uploaded looks fine to me. You're plotting the exponential moving average of price*volume. What did you expect? If you want to scale your result back down to price values, you need to divide your result by the EMA of volume.Originally posted by GGAG33 View PostThis is happening, but it only happens if I have the Volume[0] added to the regular EMA equation.
That first formula you posted in this thread isn't even correct. A volume-weighted average is simply
(average of price*volume) / (average volume).
It doesn't matter if you calculate the 'average' as simple average, exponential average, or some other smoothing method. In your case, you want EMA(price*volume)/EMA(volume).
Once you understand what the indicator means, it becomes clear how to implement it. I'd do it something like this:
For brevity, I didn't include code to initialize the plot or declare 'period'.Code:(variables) private DataSeries pv; (initialization) pv = new DataSeries(this); (onbarupdate) pv.Set(Input[0] * Volume[0]); double vema = EMA(Volume,period)[0]; if (vema == 0.0) vema=1.0; Value.Set(EMA(pv,period)[0] / vema);
-AlexLast edited by anachronist; 10-08-2008, 10:52 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment