Announcement

Collapse
No announcement yet.

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));
    http://www.ninjatrader-support.com/H...uide.html?Add1

    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:
    http://www.ninjatrader-support.com/v...ead.php?t=3475
    http://www.ninjatrader-support.com/v...ead.php?t=3476

    Perhaps you could mess around with how Gumphrie did multi-timed framed indicators on this one here:
    http://www.ninjatrader-support.com/v...7&postcount=43

    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 DavidThornbery, Today, 09:03 PM
0 responses
1 view
0 likes
Last Post DavidThornbery  
Started by jmneto, 03-02-2017, 11:34 AM
5 responses
1,588 views
0 likes
Last Post anon84
by anon84
 
Started by nikorrriko, Today, 04:42 PM
2 responses
11 views
0 likes
Last Post nikorrriko  
Started by rajeshks1988, Yesterday, 05:32 AM
1 response
17 views
0 likes
Last Post cincai
by cincai
 
Started by MaraAnkh, Yesterday, 08:44 PM
1 response
23 views
0 likes
Last Post cincai
by cincai
 
Working...
X