Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Fire Event to call OnBarUpdate manually

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_JoshP
    replied
    Unfortunately it cannot be done that simply because of the distinctions between a strategy and an indicator. What you can try is maybe using Draw() methods to draw out a line bar by bar. This is not an official approach nor is it supported. Just an idea I am throwing out there that you can try.

    Leave a comment:


  • astrolobe
    replied
    I have done that in other circumstances, but that does not work if I need to process two time frames to build the indicator. So I am trying to create an indicator using the strategy class, which allows multi-time frame processing. Now I am at the point using the strategy class where I have processed the two time frames, but I need to plot the values on the chart like an indicator.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    You can add indicators to the strategy by doing something like
    Code:
    Add(SMA(5));

    Leave a comment:


  • astrolobe
    replied
    If we code a strategy like an indicator, how do we get it to plot the indicator on the chart?
    I tried using the indicator code to create the plot:
    Add(new Plot(penMotionLine,PlotStyle.Line, "tradingML")); but it would not compile. I assume it is because the strategy does not inherit any of the indicator methods. If this is so, is there a way to plot the indicator from within the strategy?

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    You are right. Thank you for catching this.

    Leave a comment:


  • KBJ
    replied
    Update() Description in Help

    Is that a typo in the Update() help description?

    It currently says,

    Code:
    tripleValue = 0;
    
    private double 
    protected override void OnBarUpdate()
    I'm wondering if it should really say something like this:

    Code:
    private double tripleValue = 0;
     
    protected override void OnBarUpdate()
    Thanks.

    Leave a comment:


  • Rollins
    replied
    Great stuff, appreciate it! Too bad that I didn't know this when I coded the indicator. This stuff might come in handy somewhen.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Hi Rollins,

    I thought you might find some interest in this property: Update()
    I have never used it before, but it seems like it might be fitting for your needs.

    Leave a comment:


  • Rollins
    replied
    Unfortunately the strategy doesn't allow me to draw anything on the chart(maybe it does, but that is what i think ).

    Gumphrie didn't use NT indicators in his multi time frame approach, so he didn't have to deal with the DataSeries problem.

    I opted for reimplementing the indicators MIN, MAX, SUM, EMA, SMA, RSI, CCI, MACD and Stochastics so they could work without the DataSeries.

    The results have been barely tested but the values matched the ones of the original.

    The whole indicator can be found here.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    My pleasure. Good luck.

    Leave a comment:


  • Rollins
    replied
    Thank you very much Josh for writing all this. I'll post the results if i can get my indicator to work. Right now the strategy seems to the easiest to accomplish what i have in mind, but can't say for sure.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Mm. Perhaps you could just use a NinjaScript strategy instead? You could just load up a strategy onto your chart and in your strategy just code it like an indicator instead of a strategy. In a strategy you can sync the DataSeries to whatever time frame you need the data from. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3572

    Alternatively, have you considered writing out the data/calculations to a txt file and then just reading the data and using various time frames in that fashion? You might have issues with read/write operating on the same file object at the same time though so your mileage may vary with this approach. Here are reference samples related to this endeavor:



    Perhaps you could mess around with how Gumphrie did multi-timed framed indicators on this one here:


    Hope that gives you some ideas.

    Leave a comment:


  • Rollins
    replied
    The problem is that i have an indicator which uses several time frames. If i'd use a normal DataSeries the count would be as much as the chosen time frame. That's why i constructed my own DataSeries with a null indicator and the data stored in a list, and update them with a new value when n-bars have been printed. So far the indicators aren't complaining but since there is no data and get/set can't be overriden, it's just hidden, they will sooner or later. I think it simply can't be done with a DataSeries, so i am intending to writing methods instead of using pre-defined indicators and feeding them the data manually. My C# and NT experience is pretty limited, any suggestions would be appreciated. Thanks

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Sorry to mislead you. The method is invoked by the event of incoming data whether the data is historical or real-time data.

    If you could please elaborate more on what you mean by "no instrument set" perhaps I can help think about possible workarounds to achieve what exactly you are trying to accomplish.

    Leave a comment:


  • Rollins
    replied
    The way i interpret your post is that, OnBarUpdate is not called by an event, but is invoked in the code? Is there any way to tell an indicator that there is new data available?

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Option Whisperer, Today, 09:55 AM
1 response
11 views
0 likes
Last Post bltdavid  
Started by port119, Today, 02:43 PM
0 responses
1 view
0 likes
Last Post port119
by port119
 
Started by Philippe56140, Today, 02:35 PM
0 responses
3 views
0 likes
Last Post Philippe56140  
Started by 00nevest, Today, 02:27 PM
0 responses
2 views
0 likes
Last Post 00nevest  
Started by Jonafare, 12-06-2012, 03:48 PM
5 responses
3,986 views
0 likes
Last Post rene69851  
Working...
X