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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    582 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    338 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X