Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with DrawLine

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

    Problem with DrawLine

    I have logic in my strategy to draw a set of lines above pivots if the trend is up and below the pivots if the trend is down:-

    if(BarsInProgress == 0) // draw pivots on primary bars in progress
    {
    if(this.indPivAverage.ExtrnTrend[0] == 1)
    {
    DrawLine("r2l" + sessionCount, false, Bars.BarsSinceSession, Math.Max(r2 + entryAllowance * TickSize, r2 + (r3 - r2)*0.25) , 0 , Math.Max(r2 + entryAllowance * TickSize, r2 + (r3 - r2)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("r1l" + sessionCount, false, Bars.BarsSinceSession, Math.Max(r1 + entryAllowance * TickSize, r1 + (r2 - r1)*0.25) , 0 , Math.Max(r1 + entryAllowance * TickSize, r1 + (r2 - r1)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("ppl" + sessionCount, false, Bars.BarsSinceSession, Math.Max(pp + entryAllowance * TickSize, pp + (r1 - pp)*0.25) , 0 , Math.Max(pp + entryAllowance * TickSize, pp + (r1 - pp)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("s1l" + sessionCount, false, Bars.BarsSinceSession, Math.Max(s1 + entryAllowance * TickSize, s1 + (pp - s1)*0.25) , 0 , Math.Max(s1 + entryAllowance * TickSize, s1 + (pp - s1)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("s2l" + sessionCount, false, Bars.BarsSinceSession, Math.Max(s2 + entryAllowance * TickSize, s2 + (s1 - s2)*0.25) , 0 , Math.Max(s2 + entryAllowance * TickSize, s2 + (s1 - s2)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("s3l" + sessionCount, false, Bars.BarsSinceSession, Math.Max(s3 + entryAllowance * TickSize, s3 + (s2 - s3)*0.25) , 0 , Math.Max(s3 + entryAllowance * TickSize, s3 + (s2 - s3)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    }

    if(this.indPivAverage.ExtrnTrend[0] == -1)
    {

    DrawLine("r3s" + sessionCount, false, Bars.BarsSinceSession, Math.Min(r3 - entryAllowance * TickSize, r3 - (r3 - r2)*0.25) , 0 , Math.Min(r3 - entryAllowance * TickSize, r3 - (r3 - r2)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("r2s" + sessionCount, false, Bars.BarsSinceSession, Math.Min(r2 - entryAllowance * TickSize, r2 - (r2 - r1)*0.25) , 0 , Math.Min(r2 - entryAllowance * TickSize, r2 - (r2 - r1)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("r1s" + sessionCount, false, Bars.BarsSinceSession, Math.Min(r1 - entryAllowance * TickSize, r1 - (r1 - pp)*0.25) , 0 , Math.Min(r1 - entryAllowance * TickSize, r1 - (r1 - pp)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("pps" + sessionCount, false, Bars.BarsSinceSession, Math.Min(pp - entryAllowance * TickSize, pp - (pp - s1)*0.25) , 0 , Math.Min(pp - entryAllowance * TickSize, pp - (pp - s1)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("s1s" + sessionCount, false, Bars.BarsSinceSession, Math.Min(s1 - entryAllowance * TickSize, s1 - (s1 - s2)*0.25) , 0 , Math.Min(s1 - entryAllowance * TickSize, s1 - (s1 - s2)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    DrawLine("s2s" + sessionCount, false, Bars.BarsSinceSession, Math.Min(s2 - entryAllowance * TickSize, s2 - (s2 - s3)*0.25) , 0 , Math.Min(s2 - entryAllowance * TickSize, s2 - (s2 - s3)*0.25) ,Color.Orange,DashStyle.DashDotDot,1);
    }
    }


    however on somedays it is plotting both above and below the pivots and some days not plotting at all.I have gone though a debug with visual studio and it is processing as I expected, so im not sure why this is happening?


    When I eliminate all other draw items it still wont draw?
    Last edited by GKonheiser; 07-25-2014, 04:34 AM.

    #2
    GKonheiser, then you would need to continue to strip it / isolate even further - first thing would be the condition you use to draw the lines and decide which trend direction to use, does that trigger as you expect? Just print the values you would use for the drawing. That would give the most direct feedback how your code is processed.

    Comment


      #3
      I am trying to use this print statement to pin point the issue but am getting an error with it:-

      Print(Time[0] + this.indPivAverage.ExtrnTrend[0] );

      I cant see what is wrong with it??

      Comment


        #4
        What error do you exactly get?

        Comment


          #5
          Operator '+' cannot be applied to operands of type 'System.DateTime' and 'double'

          Comment


            #6
            I see, ok. Would try adding a space in there, which would be beneficial on top for reading formatting -

            Print(Time[0] + " " + this.indPivAverage.ExtrnTrend[0] );

            Comment


              #7
              ya your right worked perfectly.

              Comment


                #8
                Found the problem, it is switching the value of this.indPivAverage.ExtrnTrend[0] at 22.00, still in session, and then of course printing back the whole session. Thanks for your help. : )

                Comment


                  #9
                  So if I want to exclude a particular time what is the formatting,

                  This isn't working,

                  if(this.indPivAverage.ExtrnTrend[0] == -1 && Time[0].TimeOfDay != 22:00:00);

                  Comment


                    #10
                    TimeOfDay would be given you a TimeSpan so you want to compare to one for your condition, too -

                    .... != new TimeSpan(22, 0, 0)

                    Comment


                      #11
                      if i just want to use Time[0], why would this not work?

                      ....&& Time[0] != 2200);

                      Comment


                        #12
                        Time[0] is giving you a DateTime return, which your int 2200 would not be and the compiler would not know how to translate between the two. You can work though with feeding the datetime into ToTime to arrive at an integer representation.

                        ToTime(Time[0]) != 220000

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        573 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        575 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X