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

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 andrewtrades, Today, 04:57 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        9 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        20 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X