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

Indicator in Real Time

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

  • NinjaTrader_DaveI
    replied
    Hello,

    That is correct. The code that I sent was only meant as a sample to show you the mechanics of how this can work. At minimum, you will to change the timeframes used in the conditions (I recommend setting up public properties for this), and possibly implement something that resets the running value whenever you would like (once per week, for example).

    Leave a comment:


  • lee612801
    replied
    Hi Dave,

    I took a look and implemented the code you provided. The code I sent previously (look at the 26th) would calculate a daily delta that would change the value from day to day both negative and positive. This is basically what I am looking for but it only works correctly when the ToTime feature is set to the last bar of the intraday period. So the running value does not obtain a large magnitude. The new code provides a continuously increasing value. I like the simplicity of the approach but not sure how I can get it to do what I was hoping for. Maybe a simple tweak can fix this.

    Thanks,

    Lee

    Leave a comment:


  • lee612801
    replied
    Hi Dave,

    Thank you for the sample indicator. It looks good and cleaner than what I have. I will take this integrate into my current indicator to see how if works.

    thanks again for all the help and support.

    Regards,

    Lee

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    Hello,

    I've uploaded a brief sample that will illustrate a simpler way to accomplish what you are looking for. Please note that this is only intended as a sample, and it will need some tweaking before it can be employed.
    Attached Files

    Leave a comment:


  • lee612801
    replied
    Hi Dave,

    No problem. Thanks for the support.

    Regards,

    Lee

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    Hello,

    I just wanted to let you know that I've picked up this thread, since Patrick is out today. I've been working on an alternative way to accomplish what you are looking for, and I should have something for you soon. If not today, then I'll make it a priority in the morning. Thank you for your patience.

    Leave a comment:


  • lee612801
    replied
    Hi Patrick

    I did a little work myself and came up with the attached version. It's not exactly what I was looking for, but I think its closer. I'm evaluating the accuracy by the agreement of the real time during replay and the historical values. Here is what I have found with this.

    It seems to work but only for a 30 min period, and for the last bar (EOD) setting. If I change the ToTime setting in the code, for instance to 11:30am, it still gives me something, but it does not agree with the real time values.

    Also, if I choose the COBC option, it does not seem count the last bar of the day...

    Maybe you can shed some light on these issues.

    Thanks,

    Lee
    Attached Files

    Leave a comment:


  • lee612801
    replied
    Ok, sounds good.

    Thanks Patrick.

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello Lee,

    Thank you for your response.

    I will test the code further and see if I can produce a working example for you.

    Leave a comment:


  • lee612801
    replied
    Hi Patrick,

    So what I imagine as the result is the most up to date running sum of an intraday price delta. Lets say the price change between 1:00 and 2:00 pm. I would like to take that difference (positive or negative) and just have that add to a running sum from day to day. So if we were to look at it in real time, from 9:30am to 2:00 pm, the value over all bars would be constant based on the running sum from the previous day. Once 2:00 pm hits, it will change to the new running sum which is a summation of the previous day plus the new delta.

    RS1 = Previous day Running sum
    DD = todays delta

    Today's Calculations:
    From 9:30am to 2:00pm = RS1
    After 2:00pm = RS1 + DD = RS2

    Tomorrows Running sum = RS2

    I think this will fix the problem and provide continuous data for the program to compute. But I'm not sure why with the current code it continuously updates the running sum value during the first bar, but then not after? So I really just want to the most up to date running sum that will not cause the code to fail or provide a different answer from real time to historical comparisons.

    Thanks,

    Lee

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello Lee,

    You are correct.

    With this line "if (Time[1].Date != Time[0].Date)", it would not update until the previous bar does not match the current or End Of Day.

    So what are you looking to do here? What is the end result?

    Leave a comment:


  • lee612801
    replied
    Hi Patrick,

    thank you for the response.

    I will have to double check if I was last running on SP500 or SPY, but when I run it with Market replay, the results do not seem to update unless I refresh once the days trading is finished. So if you run it with a 30 min period, you will get one answer when running, then once the day is through, you refresh and it will provide another answer, which I believe is the correct calculation. This also matches the values you get if you just use historical data.

    I believe this is due to the fact that the range I am considering is at the EOD. So it can't update until it has this data?? But then it does not seem to update once the day is through either. So I am a little confused.

    If you compare the replay results with the historical, do you get the same answer?

    I will try to run some cases on my end as well and provide to you.

    Regards,

    Lee

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello lee612801,

    Thank you for your patience.

    I am not fully understanding what scenario you are running into that you are trying to fix. Can you provide further details to reproduce this? Such as instrument, period type and interval, and any screenshots?

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello Lee,

    I am reviewing and testing your code.

    I will follow up when I have further details.

    Leave a comment:


  • lee612801
    started a topic Indicator in Real Time

    Indicator in Real Time

    Hello,

    I have a simple indicator I have been working, but have found that it does not perform in real time (during market replay) as I would like because of how the data is gathered intraday. I am simply trying to get a price range delta between a specific time period during the day and then maintain that as a running value by adding to the next days value...So on and so on.

    I found that if I pick a range at the end of the day, it can't update intraday because it does not have the info so the real time execution does not work well. At least that is my theory. So I had a couple ideas:

    1) If I lag the calculation by one day, then it should always have enough data to continue a running sum. This may not be the best option, but I think it will work.

    2) Use the first option, but also have a range intraday that then carries from that point on... So I would have the last days range, then at a specific time, it would add the intraday range and carry that value forward. So I may have an early morning range that then is added to the previous days value and runs until EOD.

    The issue I am having is coding the indicator to do either of these. Right now it works fine when just used for historical or backtesing purposes. But when I run real time, i see the problem. So I'm hoping I can get some suggestions on how to do this. I'm getting hung up on setting Values as well... Still not real clear how to use the last days value as todays. Also, I would think that I could pick an intraday period (lets say in the morning) and then have that add to the previous days value and carry that forward for the remainder of the day. (I'll have to add another set of input parameters to do this).

    I have attached what I have for review. I am currently just testing this on SPY with a 30 min period. Please feel free to suggest better ways as well. I was thinking maybe a ToTime approach for the specific period might work better and be simpler, but it was not clear to me if this is the case.

    Thanks to all of you that help us novice C# ers.

    Regards,

    Lee
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by Perr0Grande, Today, 08:16 PM
0 responses
2 views
0 likes
Last Post Perr0Grande  
Started by elderan, Today, 08:03 PM
0 responses
3 views
0 likes
Last Post elderan
by elderan
 
Started by algospoke, Today, 06:40 PM
0 responses
10 views
0 likes
Last Post algospoke  
Started by maybeimnotrader, Today, 05:46 PM
0 responses
9 views
0 likes
Last Post maybeimnotrader  
Started by quantismo, Today, 05:13 PM
0 responses
7 views
0 likes
Last Post quantismo  
Working...
X