Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Current Range Bar possible High & Low Plot

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

  • cclsys
    replied
    Well, there is still something wrong. With some charts it works perfectly, then with others it displays on every bar. It doesn't seem to like even-numbered ranges for some reason but there is no logic in the code that I can tell that should make that an issue. If anyone can figure out this little thing, would be grateful.

    When I print out Bars.Period.Value for a 4-range chart, there are many lines in the output window. When I print it out in a 5-range chart, only two prints.

    Like most of my indicators in Ninja Script it's just a small visual aid to day-trading, nothing hyper-fancy.

    Print (Bars.Period.Value);
    Attached Files
    Last edited by cclsys; 08-11-2009, 05:37 PM.

    Leave a comment:


  • cclsys
    replied
    Originally posted by NinjaTrader_Josh View Post
    Bars.Period.Value gets you the value you set your range chart to. If you are on a 4 Range chart it will return you 4. Please debug your code to see if you are getting values you are looking for.

    You need to add a new instance of your indicator for changes like Overlay = true.
    Re: "You need to add a new instance of your indicator for changes like Overlay = true."

    Each time I have changed something I have removed the Indicator and reloaded it. Is that what you mean by a 'new instance'? If not, please explain.

    Also, why would changing the code to use Bars.Period.Value versus my previous menu-derived int make the Overlay and Panels shift when loading the indicator again?

    I have found what I think was the problem. In changing the .Set lines I forgot to set the if condition line:
    if ( High[0] == Low[0] + (range*TickSize) || (Low[0] == High[0] - (range*TickSize)) )
    return;

    which was still referencing the menu item 'range'. Now I have changed that line to use Bars.Period and also removed the range input altogether and it seems to be fine. I still don't understand why the Overlay and BarOnClose changed, but since it's not doing that anymore, all seems well.

    Thanks for helping me to learn that Bars.Period.Value coding. Thanks to you the Indicator will load with any range chart and/or when you change the range value you don't have to go to the indicator menu and manually change the range value. Much better!
    Last edited by cclsys; 08-11-2009, 04:49 PM.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    Bars.Period.Value gets you the value you set your range chart to. If you are on a 4 Range chart it will return you 4. Please debug your code to see if you are getting values you are looking for.

    You need to add a new instance of your indicator for changes like Overlay = true.

    Leave a comment:


  • cclsys
    replied
    Thanks, I changed it to

    PossHigh.Set(Low[0]+ (Bars.Period.Value*TickSize));
    PossHigh.Set(Low[0]+ (Bars.Period.Value*TickSize));

    but although it compiles, it doesn't seem to work right. I'll wait until there are more active markets tomorrow but right now it is plotting all the past bars - which it shouldn't - and not plotting the current bar - which it should.

    Also, when I loaded it even though Overlay = true and Calculate on Bar Close = true in the code, it wants to plot it in a new panel (which the other version did not do) and also defaults to Calculate on Bar Close.

    Strange.

    It would be helpful if you could show me how to write it and/or mention any other issues that are required when using this term. I suspect whatever the problem is is simple, but given the Help Menu only gives a one-line example and no other explanation, it's a little hard to figure out.
    Last edited by cclsys; 08-11-2009, 03:41 PM.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    NOT BarsPeriod but Bars.Period.

    Leave a comment:


  • cclsys
    replied
    Originally posted by NinjaTrader_Josh View Post
    From an indicator you have to do Bars.Period.Value not BarsPeriod.
    I wrote:

    PossHigh.Set(Low[0]+ (BarsPeriod.Value*TickSize));
    PossLow.Set(High[0]- (BarsPeriod.Value*TickSize));

    as posted above.

    I don't understand your reply Josh.

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    From an indicator you have to do Bars.Period.Value not BarsPeriod.

    Leave a comment:


  • cclsys
    replied
    Originally posted by NinjaTrader_Josh View Post
    You mean the value of range chart the user is using? You can access that through Bars.Period.Value.
    Thanks.

    I tried writing in:

    PossHigh.Set(Low[0]+ (BarsPeriod.Value*TickSize));

    but it won't compile.

    Original code (which works fine):

    protected override void OnBarUpdate()

    {
    if ( High[0] == Low[0] + (range*TickSize) || (Low[0] == High[0] - (range*TickSize)) )
    return;

    PossHigh.Set(Low[0]+ (range*TickSize)); // range is a variable that can be set in the menu panel for each chart, i.e. for a 5-Range bar chart you input 5.
    PossLow.Set(High[0]- (range*TickSize));

    }

    Substituting:

    PossHigh.Set(Low[0]+ (BarsPeriod.Value*TickSize));
    PossLow.Set(High[0]- (BarsPeriod.Value*TickSize));


    Is this possible or is there some particular way the language has to be used that is not explained in the help menu which only features:

    if (BarsPeriod.Id == PeriodType.Tick && BarsPeriod.Value >= 100)
    ....

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    You mean the value of range chart the user is using? You can access that through Bars.Period.Value.

    Leave a comment:


  • cclsys
    replied
    By the way, is it possible to have the script reference the number of ticks in the Range Bar Chart as specified by the user when loading the chart so that whenever the Indicator loads it automatically knows the correct Range Number versus having to input it manually on each different chart loaded?

    Leave a comment:


  • cclsys
    started a topic Current Range Bar possible High & Low Plot

    Current Range Bar possible High & Low Plot

    I have just started looking at Range Bars and put together this little Hash-Line indicator that plots, only on the current bar, the possible high and low based on whatever Range Bar setting you have. For people using these bars and especially if any bar patterns for trailing stops etc. are part of the method, it should be quite helpful - don't have to keep counting to figure out where the high or low might end up since this plot adjusts automatically as the width of the bar develops over time.
    Attached Files
    Last edited by cclsys; 08-11-2009, 01:42 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
51 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
31 views
0 likes
Last Post PaulMohn  
Started by CarlTrading, 03-31-2026, 09:41 PM
1 response
165 views
1 like
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 04-01-2026, 02:41 AM
0 responses
100 views
1 like
Last Post CarlTrading  
Started by CaptainJack, 03-31-2026, 11:44 PM
0 responses
160 views
2 likes
Last Post CaptainJack  
Working...
X