Automated Price Trend Lines in Python | Algorithmic Trading Indicator

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 36

  • @rverm1000
    @rverm1000 ปีที่แล้ว +5

    Nice just shows I got along way to go to get better at programming

  • @zendatastudio
    @zendatastudio 8 หลายเดือนก่อน +5

    Additional things to try:
    1. Define a quality score: calculated as how closely the trendline matches the highs and lows (this rules out sudden price change and pave way for dynamic trend lines)
    2. Dynamic trend line: set a range of periods (7-30), calculate trend line for each period but only select one with best quality score (We can call it true trend line).

  • @GaryBernstein
    @GaryBernstein ปีที่แล้ว +2

    can you share the C/C++ code?

  • @LongTu167
    @LongTu167 10 หลายเดือนก่อน +1

    Amazing, thank you very much!!!

  • @parklife6384
    @parklife6384 6 หลายเดือนก่อน

    Thanks for your videos, they are very informative and well explained.

  • @SataMoore
    @SataMoore 9 หลายเดือนก่อน

    I am wondering how to ensure k bars within the tread channel as shown in the presentation, since with MSE the fitted data (the low values in the support mode for instance) must scatter along the trendline.

  • @nattyzaddy6555
    @nattyzaddy6555 ปีที่แล้ว +5

    I ran your code but it created a static matplotlib graph instead of the real-time updated graph that you show in the video

    • @iloos7457
      @iloos7457 ปีที่แล้ว

      use plotly
      or search interactive on google

    • @freddy77.
      @freddy77. หลายเดือนก่อน

      You have to stream prices to data file and make it running like that

  • @mhalan2198
    @mhalan2198 10 หลายเดือนก่อน +1

    why didn't you connect the two furthest pivots and that's it?

  • @jassbinks3301
    @jassbinks3301 7 หลายเดือนก่อน

    Can we have acces to C++ algorithme ?

  • @MelarDev
    @MelarDev 8 หลายเดือนก่อน

    like someone said, c++ code would be great if you could share plz

  • @brendanlydon5272
    @brendanlydon5272 ปีที่แล้ว +1

    Would you consider the normal equation instead of GD if n < 10^4? Unreal content btw. Would love to see a video on a long/short strategy with a neural net and playing with many feature variables predicting X candles ahead. Distance to vwap, 2nd stddev bollinger bands, maybe distance to top/bottom trend lines in current trend?

    • @neurotrader888
      @neurotrader888  ปีที่แล้ว +3

      Since we have the constraint of the trend lines being above and below all points we can't use the normal equation. As far as I know..
      I'll do some neural net content eventually it has been requested a few times. Its a complex topic so its difficult for me to make a one-off video for it.

  • @KereellOlorin
    @KereellOlorin 7 หลายเดือนก่อน

    I'm a newby to trading. Please tell where I should scrape the data into csv files from? Or it is posible to get this files from tradingview (or similar resourses) ?

    • @nuweariho6884
      @nuweariho6884 7 หลายเดือนก่อน

      Get from mt5 by just right clicking the chart and click save. It will offer you option to save as CSV. But if u want to automate then use mt5 python documentation. It will help u to access data into your python code from mt5.

  • @poisonza
    @poisonza 10 หลายเดือนก่อน +3

    computationally too expensive, the gradient descent part could go away.
    Given data window compute zigzag to find pivot points
    Enumerate all possible trend line using pivoot points.
    choose trend line with minimum error(distance between data and trendline).
    So essentially you compute way less but get similar result. cheers

  • @ancientindian
    @ancientindian ปีที่แล้ว

    very nice. thanks. Have you also worked on automating the horizontal breakout levels (up, down), say for past 50 periods? So, instead of slant trendlines, you have horizontal breakout levels touched by maximum opens and closes of all candles in a given range.

    • @neurotrader888
      @neurotrader888  ปีที่แล้ว +4

      Yes I have. I have experimented with a few methods for horizontal levels or support/resistance levels. I'll make a video(s) about one or more of them eventually. Essentially they all search for prices that the market has repeatedly formed a local top/bottom. ( Local top/bottom finding algorithms will actually be my next video, in progress)
      One good approach I've used is presented in this paper:
      Zapranis, A. and Tsinaslanidis, P. 2012. Identifying and evaluating horizontal support and resistance levels: an empirical study on US stock markets. Applied Financial Economics. 22 (19), pp. 1571-1585.
      Another method I've tried finds local tops/bottoms and estimates the distribution of their prices using the parzen window method. Then the horizontal levels can be found by finding peaks in that distribution.
      Thanks for watching

    • @ancientindian
      @ancientindian ปีที่แล้ว

      @@neurotrader888 will check out your paper, look fwd to your next vid. thanks

  • @hasa4628
    @hasa4628 ปีที่แล้ว

    hey where i can learn more about algorithms for trading?

    • @neurotrader888
      @neurotrader888  ปีที่แล้ว

      I have a video of books I like. Many of the books have code.

  • @probablyonthemoon
    @probablyonthemoon ปีที่แล้ว

    Howdy Brother, love your work! Was wondering, do you log-transform price data before testing? Crypto prices can be very YEEHAW exponential

  • @ponkieponkz
    @ponkieponkz ปีที่แล้ว

    I dont understand how the pivot is calculated or stored in the dataframe...
    ***Never mind... Newbie here. I started learning python in april this year.
    I am retrofitting your codde to a Freqtrade dataframe. You are working with numpy arrays.
    Learned some new stuff thanks to this challeng.. Thanks for the content.

  • @sethlupo4736
    @sethlupo4736 4 หลายเดือนก่อน

    I love your content!!! I was wondering if this can be optimized by GPU, because we have all this tech for gradient descent with tensors. I implemented a similar gradient descent algorithm but with porch GPU acceleration for the optimization. I had to make the gradient continuous everywhere, so I opted to make the loss function the sum of the squares + 1000 * an extra penalty for any squares wrongly above/below the trend line.
    This definitely allows some quick computation. I was able to compute a bounding line to be created in

  • @cwayne4
    @cwayne4 5 หลายเดือนก่อน

    I think i found a faster way. Compute Line of best fit. Compute the diffs of the line and the closing prices. Get the maximum diff of the first half of the line, thats your first pivot. Get the maximum diff of the second half of the the line, thats your second pivot. The trendline then can be calculated with the two pivots. Except for the fitting of the line all other operations are just lookups. Or am I missing something?

    • @neurotrader888
      @neurotrader888  5 หลายเดือนก่อน +1

      That would probably work most of the time. But imagine the input window of prices made a V shape. When fitting the lower line, there would be one well defined pivot-- the point of the V. The other pivot won't be well defined, and would likely end up being some random point. With my moethod, an optimal middle ground is found. The final line doesn't necessarily touch price at two locations.
      An argument could be made that in such a situation a trendline isn't appropriate, but I prefer having a calculation that provides a reasonable solution regardless of the input.

    • @cwayne4
      @cwayne4 5 หลายเดือนก่อน

      @@neurotrader888 you are absolutely right. A V-shaped series would result in a poorly fitted trendline indeed. It will still work, though. speed vs quality

  • @poyolplays2825
    @poyolplays2825 ปีที่แล้ว

    Hello Sir. I've been searching for an algorithm to detect trendlines for days until I found this. Fatnastic work! I've implemented your algorithm in nodejs and it works perfectly, However my original intention was to detect those trendlines like the beginning and end of the video. How can i use the result of this TrendLineAutomation
    to calculate those two lines?

  • @DeAdBiGeYeFiSh
    @DeAdBiGeYeFiSh ปีที่แล้ว +2

    I think that a simpler way (in terms of steps of calculations) performs better in terms of computational complexity.
    For the bottom line: Start with a line joining the pivot point (or starting point) with the next point of close/low. Then go on checking the next points one by one. If the next is above the line, just pass. Otherwise, switch the line with the line joining the starting pivot point with this new point. By the end you have the desired trend line.
    I find your steps more conceptually appealing though, the people who would probably disagree would be CS heads that tend to prefer faster iterative/recursive algorithms.

    • @ranitbose9609
      @ranitbose9609 ปีที่แล้ว

      This isn't equivalent to what he's doing. This is because the line that minimises the MSE while having all points above the line doesn't necessarily pass through two points.
      However, I actually like your approach better and I think it aligns more with how trendlines should be drawn

    • @DeAdBiGeYeFiSh
      @DeAdBiGeYeFiSh ปีที่แล้ว

      @@ranitbose9609 It is equivalent.
      Assume it doesn't. Then every point past the pivot point is strictly above the line. Therefore you can increase the angular coefficient of the line, obtaining one that is still not above any point but that is closer to every point past the pivot - therefore having a smaller MSE, contradicting the assumption that it minimizes it.

    • @poisonza
      @poisonza 10 หลายเดือนก่อน

      Similar enough IMO. Difference neglegible

  • @lennard4454
    @lennard4454 ปีที่แล้ว +1

    Something I don't like about this algorithm is, that it seems only to combine highs with highs and lows with lows. However rather often, previous Support becomes Resistance and reverse...

  • @salexkorsan8790
    @salexkorsan8790 ปีที่แล้ว

    Mr dude send me the code i wanna make a bot, i will send you too