NexusFi: Find Your Edge


Home Menu

 





Projecting a Moving Average


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 10 posts (26 thanks)
    2. looks_two vegasfoster with 6 posts (2 thanks)
    3. looks_3 ThatManFromTexas with 4 posts (1 thanks)
    4. looks_4 WolfieWolf with 3 posts (0 thanks)
      Best Posters
    1. looks_one ehlaban with 4 thanks per post
    2. looks_two Fat Tails with 2.6 thanks per post
    3. looks_3 cusp with 2 thanks per post
    4. looks_4 vegasfoster with 0.3 thanks per post
    1. trending_up 13,664 views
    2. thumb_up 36 thanks given
    3. group 11 followers
    1. forum 30 posts
    2. attach_file 6 attachments




 
Search this Thread

Projecting a Moving Average

  #11 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


NJAMC View Post
@ Fat Tails,

So you are saying the projected value (next bar or whatever) would simply be stored under the current bar index [0], but simply offset on the chart? Is there a parameter that can be loaded in the Init to set the offset?

I was not saying anything.... I just showed how to add a projection period in the end of the indicator.

The indicator uses the displacement feature of NinjaTrader. In order to display a plot, which extends into the future, I used the following approach

-> determine the number of bars N that you want to produce a forecast for
-> shift the plot N bars to the right by selecting a displacement equal to the forecast period - do not try to do this in Initialize(), you need to set the Displacement in OnStartUp()
-> correct the values up to CurrentBar - N to compensate for the impact of the shift
-> add the forecast values for the last N bars by using the selected algorithm

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
Futures True Range Report
The Elite Circle
 
  #12 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

Thanks for the responses, but I didn't appear to successfully convey my thought process. I want to displace all bars back one bar, including the current bar, and then insert another current bar so that both the current bar and previous bar will both use the last price. I am not actually trying to project or forecast what I think the value of the moving average will be at the end of the next bar based upon what has happened. I just want to know if the price were to close right now, what would the value be at the open of the next bar. It's not the same value as the close of the current bar, because the last bar in the current series will drop off at the open of the next bar. Hope that makes sense. Again, thanks for any help.

Started this thread Reply With Quote
  #13 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844



Fat Tails View Post
Here is a little indicator that adds a linear forecast to any indicator plot that is selected as input series. The chart below shows the LinearForecast indicator applied to each of the 3 MACD Plots.

Of course it is possible to recode any indicator to include this little feature. You can also modify the linear forecast indicator to allow for different algorithms to extrapolate the plot values.


Sorry, I didnt see this post before making my last post, lemme see if this will help me, thank you very much.

Started this thread Reply With Quote
  #14 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

Hmmm, thanks for posting and correct me if I am wrong, but I don't think the analinearforecast is what I am trying to do.

Started this thread Reply With Quote
  #15 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


vegasfoster View Post
Thanks for the responses, but I didn't appear to successfully convey my thought process. I want to displace all bars back one bar, including the current bar, and then insert another current bar so that both the current bar and previous bar will both use the last price. I am not actually trying to project or forecast what I think the value of the moving average will be at the end of the next bar based upon what has happened. I just want to know if the price were to close right now, what would the value be at the open of the next bar. It's not the same value as the close of the current bar, because the last bar in the current series will drop off at the open of the next bar. Hope that makes sense. Again, thanks for any help.

@ vegasfoster: Yes, this is something different. Moreover, you confused us, because the MultiCharts example that you used showed a linear projection, which is what I have done for NinjaTrader.


Here comes another indicator, which is probably the DIRTIEST and the SHORTEST piece of code that was ever written for NinjaTrader. Don't insult me, if it does not work.

To be used with CAUTION. No warranties given.


The code can be used to predict the indicator values for the coming 3 bars by using the close of the current bar as the numerical base for the forecast of the following indicator values.


This is how the indicator is to be applied: If you want the prediction feature, just apply your indicator and select ana3BarPredictor as the input series. Also set the displacement manually to 3 via indicator dialogue box.


Attached is a chart that shows the predicted values for the RSI.



Attached Files
Elite Membership required to download: 3BarPredictor.zip
Reply With Quote
  #16 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


Fat Tails View Post
@ vegasfoster: Yes, this is something different. Moreover, you confused us, because the MultiCharts example that you used showed a linear projection, which is what I have done for NinjaTrader.

Here comes another indicator, which is probably the DIRTIEST and the SHORTEST piece of code that was ever written for NinjaTrader. Don't insult me, if it does not work.

To be used with CAUTION. No warranties given.

The code can be used to predict the indicator values for the coming 3 bars by using the close of the current bar as the numerical base for the forecast of the following indicator values.

This is how the indicator is to be applied: If you want the prediction feature, just apply your indicator and select ana3BarPredictor as the input series. Also set the displacement manually to 3 via indicator dialogue box.

Attached is a chart that shows the predicted values for the RSI.

Okay @Fat Tails,

What kind of black magic is this? How does [-3] even exist, and how does the RSI use this to forecast 3 bars ahead!?!?!?

 
Code
        protected override void OnBarUpdate()
        {
            try
            {    
                Value.Set(Input[-3]);
            }
            catch
            {
                Value.Set(Input[0]);
            }
        }

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
  #17 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


NJAMC View Post
Okay @ Fat Tails,

What kind of black magic is this? How does [-3] even exist, and how does the RSI use this to forecast 3 bars ahead!?!?!?

 
Code
        protected override void OnBarUpdate()
        {
            try
            {    
                Value.Set(Input[-3]);
            }
            catch
            {
                Value.Set(Input[0]);
            }
        }

That is the reason that I said that it is the dirtiest piece of code ever. I just published it, because I wanted to let you all test the master piece, as I do not know myself what will be happening.

Please report any incidents.

Reply With Quote
Thanked by:
  #18 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


Fat Tails View Post
That is the reason that I said that it is the dirtiest piece of code ever. I just published it, because I wanted to let you all test the master piece, as I do not know myself what will be happening.

Please report any incidents.

I just had one!

Reply With Quote
Thanked by:
  #19 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

You can easily extend a moving average with overriding the Plot() method.
There are some examples and indicators build with it from NT.

Another method


Reply With Quote
  #20 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348



ehlaban View Post
You can easily extend a moving average with overriding the Plot() method.
There are some examples and indicators build with it from NT.

Another method



ehlaban View Post
I intend to make an upgrade without the plotting so you can use it as an add in, like you did,
to plot into the future with other indicators.

@ehlaban

Are you still working on this?

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
Thanked by:




Last Updated on May 13, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts