Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

access prior close in volcandle bar type indi

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

    access prior close in volcandle bar type indi

    no matter what I tried I can't seem to get correct Close value of the prior vol bar so I can't color the current vol bar correctly.
    ================

    ...
    double dblBarwidth;
    //Cory add prevClose
    double prevClose = 0;

    for (int idx = fromIdx; idx <= toIdx; idx++)
    {
    //calc dynamic bar width
    dblBarwidth = k * bars.GetVolume(idx) + m;
    barWidth = (int)(Math.Round(dblBarwidth, 0));

    barColor = chartControl.GetBarColor(bars, idx);
    // barWidth = GetBarPaintWidth(barWidthValue);
    closeValue = bars.GetClose(idx);
    close = chartControl.GetYByValue(bars, closeValue);
    high = chartControl.GetYByValue(bars, bars.GetHigh(idx));
    low = chartControl.GetYByValue(bars, bars.GetLow(idx));
    openValue = bars.GetOpen(idx);
    open = chartControl.GetYByValue(bars, openValue);
    x = chartControl.GetXByBarIdx(bars, idx);

    //Cory load prevClose when idx < toIdx
    if (idx > fromIdx && idx < toIdx) {
    prevClose = close; }

    ......

    //Cory -set color for doji bar
    if (open == close && prevClose > 0 )
    {
    if (close < prevClose) {
    Pen2.Color = Color.Red;}

    if (close >= prevClose) {
    Pen2.Color = Color.Green; }
    }


    if (high < Math.Min(open, close))
    graphics.DrawLine(Pen2, x, high,x,Math.Min(open, close));
    if (low > Math.Max(open, close))
    graphics.DrawLine(Pen2, x, low, x,Math.Max(open, close));
    ......
    Attached Files

    #2
    Hello nkhoi,

    Thanks for your note.

    Is there any particular reason you are accessing the open, high, low, close by using ChartControl?

    This method is unsupported.

    The supported method of accessing the previous bars open, high, low, close is through the dataseries created for each of these.

    For example to compare the current bars close to the previous bars close use:
    Close[0] < Close[1]

    or for the high use:
    High[0] < High[1]

    Below is a link to the help guide on Close. (High, Open, Low will all be used in the same manner).
    http://www.ninjatrader.com/support/h.../nt7/close.htm


    I look forward to your reply.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      This is a new bar type, bar width expanse/shrink based on volume. This is how the original author coded to get open, close for his new bar type. I am trying to obtain the previous bar close using his method but not too successful.
      Last edited by nkhoi; 05-17-2013, 10:46 AM.

      Comment


        #4
        Hello nkhoi,

        Thank you for your reply.

        Unfortunately, we cannot provide support for creating custom bar types. However, I will keep this thread open so that others may offer you replies.

        I recommend that you post this inquiry in the unsupported thread as well.
        http://ninjatrader.com/support/forum...ad.php?t=22435

        Also, below is a link to our NinjaScript Consultants page should you wish to get assistance from a professional NinjaScript developer.
        http://www.ninjatrader.com/partners#...pt-Consultants


        Please let me know if there is any supported NinjaScript code I can assist you with.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        617 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        357 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        561 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        566 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X