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

Problematic Indicator

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

  • NinjaTrader_ChrisL
    replied
    Hi, thanks for posting.

    If you are getting a bars ago indexing error then there are not enough bars on the chart when the command is executed. I agree with Nicholas "it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments" without the full code it's hard to tell. You can use Visual Studio to break when the exception occurs and that wil show you what line is causing the problem:
    https://ninjatrader.com/support/help..._debugging.htm

    Kind regards,
    -ChrisL

    Leave a comment:


  • omololu
    replied
    Originally posted by NicholasJoannette View Post

    That doesn't do what he's suggesting to do. Using
    Code:
    if (CurrentBar < 10) return;
    will just return if the current bar being calculated in OnBarUpdate is within the 10 most recent bars. What nkhoi was suggesting was that you check there are sufficient bars on the chart. Something like
    Code:
    ChartBars.Bars.Count > 10
    NT8 is not like NT7 - if you didn't know about this basic difference above, then it's likely that the issue is originating in the other parts of the code that you deemed irrelevant.



    These Draw functions on their own work well. There is likely an issue with the arguments in your calls. If you converted from NT7 to NT8, it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments. Just a guess though - good luck.

    Code:
    Draw.Line(this,"BD"+Var, CurrentBar - PeakIndex[a], Peak[a], CurrentBar - TroughIndex[DnCount], Trough[DnCount], BullishSetup);
    Thanks for your comments.

    So, how do I use "ChartBars.Bars.Count > 10" ?

    Leave a comment:


  • NicholasJoannette
    replied
    Originally posted by omololu View Post
    Yes, I have tried "if(CurrentBar < 10) return;" but it didn't work.
    That doesn't do what he's suggesting to do. Using
    Code:
    if (CurrentBar < 10) return;
    will just return if the current bar being calculated in OnBarUpdate is within the 10 most recent bars. What nkhoi was suggesting was that you check there are sufficient bars on the chart. Something like
    Code:
    ChartBars.Bars.Count > 10
    NT8 is not like NT7 - if you didn't know about this basic difference above, then it's likely that the issue is originating in the other parts of the code that you deemed irrelevant.

    Originally posted by omololu View Post
    The provided file contains ONLY extracted relevant portions of the indicator ... it is not expected to compile. It is the Draw.Line, Draw.Ray and Draw.Text that seem to have issues.
    These Draw functions on their own work well. There is likely an issue with the arguments in your calls. If you converted from NT7 to NT8, it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments. Just a guess though - good luck.

    Code:
      
    Draw.Line(this,"BD"+Var, CurrentBar - PeakIndex[a], Peak[a], CurrentBar - TroughIndex[DnCount], Trough[DnCount], BullishSetup);

    Leave a comment:


  • omololu
    replied
    Originally posted by NicholasJoannette View Post
    The file you provided doesn't compile and is missing a bunch of code, so it's not of much use. Check your ninjascript output log and the log files as a starter.
    The provided file contains ONLY extracted relevant portions of the indicator ... it is not expected to compile. It is the Draw.Line, Draw.Ray and Draw.Text that seem to have issues.

    Leave a comment:


  • omololu
    replied
    Originally posted by nkhoi View Post
    make sure you have enough bars first for example you want to draw from 10 bar back then making sure the chart has 10 bars first
    Yes, I have tried "if(CurrentBar < 10) return;" but it didn't work.

    Leave a comment:


  • NicholasJoannette
    replied
    The file you provided doesn't compile and is missing a bunch of code, so it's not of much use. Check your ninjascript output log and the log files as a starter.

    Leave a comment:


  • nkhoi
    replied
    make sure you have enough bars first for example you want to draw from 10 bar back then making sure the chart has 10 bars first

    Leave a comment:


  • omololu
    started a topic Problematic Indicator

    Problematic Indicator

    I have attached extracted relevant portions of a problematic indicator that I converted from NT7 to NT8 ... I call the indicator "Problematic". The indicator successfully compiles, but it does not plot the Drawing objects (Lines, Rays, and Texts) when I load it onto a chart. Why are the Drawing objects not plotting or showing up ?

    Problematic.cs

Latest Posts

Collapse

Topics Statistics Last Post
Started by ezrollin, Today, 10:40 AM
5 responses
6 views
0 likes
Last Post NinjaTrader_Jesse  
Started by sidlercom80, Today, 10:20 AM
2 responses
6 views
0 likes
Last Post sidlercom80  
Started by TraderElegante, Today, 09:53 AM
2 responses
16 views
0 likes
Last Post TraderElegante  
Started by Kreyenhagen, Today, 09:03 AM
1 response
7 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by trader3000a, Today, 04:23 AM
1 response
10 views
0 likes
Last Post NinjaTrader_Jesse  
Working...
X