highfestiva / finplot

Performant and effortless finance plotting for Python
MIT License
886 stars 180 forks source link

[QUES]How do I draw a tower #525

Open ethanwanggg opened 2 weeks ago

ethanwanggg commented 2 weeks ago

Hi: Does finplot provide the function of TOWER diagram? I tried using volume_ocv or candlestick_ochl function to draw a TOWER, but it didn't look like what I wanted. The TOWER line is a kind of line that divides the rise and fall of the price by the physical bar line of white and black (virtual body, entity), and studies its rise and fall trend It is also the process of fighting between short and long and the change of power shown in the chart, and shows the appropriate time to buy and sell. it The characteristics of the point chart are similar to that of the point chart, that is, it does not record the price change process on a daily or weekly basis, but only when the price continues to hit a new high (or a new high) New low), or reverse the rise or fall, and then record and plot.

Please see the screenshot. image

In short, please tell me a way to achieve this purpose, I would be grateful, thank you!

ethanwanggg commented 2 weeks ago

The instructions for the pagoda line go something like this: The closing price of a starting date is selected as the base to draw the tower line for the first time.

  1. If today's closing price is higher than yesterday's closing price, indicating that the stock price has increased, draw a white (or red, hollow) column today, the height of which is equal to today's closing price minus yesterday's closing price.
  2. If today's closing price is lower than yesterday's closing price, indicating a decline in the stock price, draw a black (or green, solid) column today, whose height is also equal to today's closing price minus the absolute value of yesterday's closing price.
  3. When the stock price continues to rise, as long as the closing price on the following day is not lower than the lowest point of the white (or red) column on the previous day, continue to draw the white (or red) column.
  4. On the contrary, if the stock price continues to decline, the black (or green) column continues to be drawn as long as the closing price on the following day does not exceed the peak of the black (or green) column on the previous day.
  5. If the closing price of a given day falls below the lowest point in the white (or red) column of the previous day, the column of that day starts from this lowest point and the portion to the actual closing price is shown in black (or green), indicating a trend reversal.
  6. Similarly, if the closing price of a given day exceeds the highest point in the black (or green) column of the previous day, the portion of the column from this highest point to the actual closing price is shown in white (or red), which is also a signal of a trend reversal.