Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X