Announcement

Collapse
No announcement yet.

Line indicator at bar

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

  • Line indicator at bar

    I was wondering can a line or somekind indicator telling me what 50% of a bar would be.

    Say I want the first bar of the day to be 9:30 bar. My graph then goes from 9:30 til closing.


    example:: 9:30 (open $10) (close $11) mark it at $10.50 =50%

    I guess a line from there till closing would be very nice

    I havent done much here lately...I went through and watched most of the videos on the net last week....they took some time to watch them.....

  • #2
    curious to why this got moved

    I read several line drawing posts here before I posted the original, thought that would help, even printed out over 100 pages so I could look at over the weekend. But after reading I didnt think It would work.

    I tried to do fancy writing but had no luck at all, spent a whole night trying to figure it out. Tried using other codes and variables, still no luck.

    Then, it came to me just to use the basic drawline function.

    I figure I would keep it simple. It worked in tick replay, will have to try real time next week. Hope it works in real time??!!

    Here is the code below. It draws a line from the first bar of the day (50% of the open-close) to the graph edge on the right. I also used the code: below

    If this doesnt work, anyone have any ideas??



    PHP Code:
    drawLineRelative(-1low(-1)+((close(-1)-open(-1))*.50), 100low(-1)+((close(-1)-open(-1))*.50), 
    PS_SOLID2Color.RGB(0,0,255), "TAG"
    PHP Code:
    (getHour(0)*100)+getMinute(0)>900 && (getHour(0)*100)+getMinute(0)<920 

    Comment


    • #3
      PATRADER
      The easiest way to do what you want is to create a condition that on a new bar checks to see if the timestamp of the prior bar is equal to 9:30 and then calculates (Open+Close)/2 of the prior bar. To do this declare a global variable called myValue and set it initially to 0. Then in the main function use the sample code enclosed below. Use myValue in the return to plot the value on the chart.
      Alex

      PHP Code:
      if(getBarState()==BARSTATE_NEWBAR){//on a new bar
              
      if((getHour(-1)*100)+getMinute(-1)==930){//if time at prior bar equal to 930
                  
      myValue = (open(-1)+close(-1))/2;//calculate (Open+Close)/2 of prior bar
              
      }
          } 

      Comment


      • #4
        ohh, I'll look into that in the morning...

        here it what I have now..had a few things to consider...
        PHP Code:
        drawLineRelative(-1close(-1)-((close(-1)-open(-1))*.50), 100close(-1)-((close(-1)-open(-1))*.50), PS_SOLID2Color.RGB(0,0,255), "TAG"

        I'll look at your code in the morning...thanks

        Comment


        • #5
          PATRADER
          FWIW you can simplify close(-1)-((close(-1)-open(-1))*.50) by using (open(-1)+close(-1))/2
          Alex

          Comment


          • #6
            Thanks

            I'll try that...always nice to simplify formulas.....I'm getting there...

            thanks for all your help

            Comment

            Working...
            X