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

How can I draw my pivots in a strategy

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

    How can I draw my pivots in a strategy

    I am writing a strategy that uses pivots. I'd like to draw these pivots on the screen but I can't figure out a way to do it.

    What I want is for each day I have a horizontal line, for example 1200. I successfully coded it to draw from 1 bar ago to the current bar but that is incredibly slow and unusable.

    Then I decided I could just draw the pivot at the end of the day. But I can't get that to work. If I put bars ago = 390 I get an error on the first day.

    What makes more sense is to draw the pivot at the beginning of the day. But it seems that the DrawLine method uses two bars parameters. Passing in -390 (for 390 bars into the future) doesn't work.

    I'm a bit stuck. I can program so I just need a hint on how to do it.

    Thanks

    #2
    Finally got something working. A bit sloppy, maybe someone has a suggestion to improve it. Believe it or not I spent about 4 hours on this. I guess that should tell you a little about my programming skills.

    one of the problems is it is coded for 1 minute bars. I like to be able to test different times.

    Code:
                    if (ToTime(Time[0]) == ToTime(21, 59, 00)) {
                        Log("Plotting pivots", LogLevel.Information);
                    int date = ToDay(Time[0]);
                    string dateString = date.ToString();
                    int barsAgo = GetBar(new DateTime(int.Parse(dateString.Substring(0,4)), int.Parse(dateString.Substring(4,2)), int.Parse(dateString.Substring(6,2)), 15, 30, 0));                    
                    Log("barsAgo=" + barsAgo, LogLevel.Information);
                    int i=0;
                    foreach (double pivot in pivots) {
                        DrawLine("Pivot" + ToDay(Time[0])+ToTime(Time[0])+i, barsAgo, pivot, 0, pivot, Color.Blue);        
                        i++;
                    }
                    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kujista, Today, 05:44 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by elderan, Yesterday, 08:03 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by samish18, Yesterday, 08:57 AM
    8 responses
    25 views
    0 likes
    Last Post samish18  
    Started by DJ888, 04-16-2024, 06:09 PM
    3 responses
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by RookieTrader, Today, 07:41 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X