Martingale Swing Trading Strategy Algorithmic Backtest In Python

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2024

Комментарии • 42

  • @santhosh6700
    @santhosh6700 2 года назад +2

    Hi bro...
    Finally I have made a script for scraping trading view real time data..and creating the real time alert for intraday trading..
    You are one my inspiration...
    Thank you for your videos...keep it up
    🇮🇳

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +1

      Hi thank you for your comment, I am glad these videos are of help. Good luck with your trading

    • @STSamurai
      @STSamurai 2 месяца назад

      Tv feed ????

  • @tradewithaakash2939
    @tradewithaakash2939 Год назад +2

    one more awesome video explaining the concept. thankyou so much for your valuable time and effort

    • @CodeTradingCafe
      @CodeTradingCafe  Год назад

      Thank you for taking the time to write these comments, much appreciated!

  • @thibautglerant4300
    @thibautglerant4300 Год назад

    Interesting video thanks for that !! But I think you do have a look forward bias in the definition of your support and resistance. E.g. if today is a support we only know that by the closing of the day after tomorrow (if n2=2). Don't you think?

    • @CodeTradingCafe
      @CodeTradingCafe  Год назад

      Hi thank you, yes it's probably the case I am wondering now about my other videos using this code part... although it might not affect the results significantly... hopefully

    • @thibautglerant4300
      @thibautglerant4300 Год назад +1

      @@CodeTradingCafe 2 possibilities: The quick fix is to take the enter trade 2 days later when we observe that the candle is engulfed and there was a support at the same time. Spoiler: the return deteriorate quite a lot ... (i am doing it on the SP500 daily from 1999).
      Or we need to think in another manner: for example buy when you do have the candle pattern if you are in a bullish trend we buy (I am working on it)
      Do you have any strategies live by the way?

    • @CodeTradingCafe
      @CodeTradingCafe  Год назад

      Hi thank you for the feedback, it's disappointing the return deterioration! I did have parallel live strategies bringing around 7-9 percent per year. Moved countries and didn't have enough time to take care of it recently... in my mind at some point will run it again

    • @thibautglerant4300
      @thibautglerant4300 Год назад

      ​@@CodeTradingCafe I am coding and constructing a strategy as well at the moment. If you want to share knowledge in private it will be with pleasure !!

    • @CodeTradingCafe
      @CodeTradingCafe  Год назад +1

      @@thibautglerant4300 I find that support resistance and candles patterns are the best indicators for most probable future movements. The rest in the strategy is how you manage entry and exit, and it's better to have 2 uncorrelated strategies if one is not doing well the other will compensate.

  • @StillChrist
    @StillChrist 2 года назад +1

    Probably better to find how to employ 100% capital. For example, if you risk only 2% capital per attempt, try to find 50 other, more or less uncorrelated signals to attempt. This is where computational power can really shine.

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +2

      Actually you're right I had something slightly different in mind, using like 10 somehow winning algo strategies at the same time, when few are going through rough period the others will make up, the whole system will always yield positive returns

    • @StillChrist
      @StillChrist 2 года назад +1

      @@CodeTradingCafe Yes, that should be sufficiently uncorrelated. Best if can find a broker that will recognize your stops so to free up the rest of the capital. But even with same strategy, different time frames, or slight variation, can probably also give semi uncorrelated.

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +1

      I think if the broker provides a Python API with Stop function then it should work, I tried my bots on oanda demo account all was automated properly including SL and TP

  • @badinibeats5939
    @badinibeats5939 6 месяцев назад +1

    lol i ran this startegy with no martinagale because the results where so good ran it live for like 2 weeks didnt take one trade because the n2 candles where 2 and there was never a signal printed in real time fml serves me right for just copy pasting someone elses code without really knowing what was going on, even though it was on a small bankroll for live testing ahah pretty stupid of me

    • @CodeTradingCafe
      @CodeTradingCafe  6 месяцев назад +1

      Hi, good it didn't trade, risk avoided, I usually test on paper accounts before switching to real money... don't be impatient it's too risky (friendly tip).

    • @badinibeats5939
      @badinibeats5939 5 месяцев назад

      @@CodeTradingCafe yeah defiantly lesson learnt back to my crappy code i know works haha

  • @mdjuneid3553
    @mdjuneid3553 2 года назад

    hi can you make a video on BitMEX API there are no videos on that api

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад

      Hi I checked it quickly I am afraid I am not familiar with their API

  • @santhoshdasari7
    @santhoshdasari7 2 года назад

    Thanks a lot for sharing…

  • @planb5386
    @planb5386 2 года назад

    thank you.

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад

      Thank you for your constant support, I hope these videos are of help

  • @souvikdey3910
    @souvikdey3910 2 года назад

    very great explanation sir. May we try with multiple stocks in the live market sir.. ? where we can scan all stocks simultaneously.

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +1

      Thank you for your comment, it is possible it might be data intensive working on a laptop though

    • @souvikdey3910
      @souvikdey3910 2 года назад

      @@CodeTradingCafe respected Sir, It will be a blessing for me if you kindly make a live demostation video, where we can run this to scan multiple stocks in the live market to generate signals. It will be a great learning for us.

  • @jflebas1217
    @jflebas1217 2 года назад

    Nice vid my dude, but i would not use martingale in real trading

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +1

      Hi thank you for your support, yes indeed it is to be avoided just made the video for demonstration, but martingale is closer to gambling in this case

  • @yusufalp
    @yusufalp 2 года назад +1

    1-2-2-4 stop is better

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад

      Hi thanks for sharing, did you try it with the code?

    • @yusufalp
      @yusufalp 2 года назад

      @@CodeTradingCafeonly in manuel trading

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад

      @@yusufalp ok can you give more details about it 1 2 2 4 how do you use it? I can plug it in one of the future strategy videos see how it goes

    • @yusufalp
      @yusufalp 2 года назад

      @@CodeTradingCafe 1 is real position, deep 2 deep 2 is for buy sell for average . stay with 1 first position only... 4th is for escaping... or stop // rule is waiting in the loss. //

  • @aaronkellie5785
    @aaronkellie5785 2 года назад +1

    ⭐ ???????

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад

      I will take this as a supportive comment 😂

  • @OneCreator87
    @OneCreator87 2 года назад +1

    Why would you ruin a good system by using a Martingale tho :(

    • @CodeTradingCafe
      @CodeTradingCafe  2 года назад +1

      You're right, I tried this just out of curiosity, and to show results it's always good to know.

  • @xnum-te8lx
    @xnum-te8lx Год назад +1

    Hey GOAT, I'm trying to implement this logic in real-time. However, It's generating a signal for before the last two rows (two days behind).
    I asked ChatGPT:
    The for loop iterates over each row in the DataFrame, starting from backCandles and stopping at len(df)-n2.
    This is because the signal cannot be generated for the last n2 rows due to the support and resistance functions requiring a minimum amount of data to work with.
    is there a way to modify the support and resistance functions to generate a signal for the current day ?

    • @CodeTradingCafe
      @CodeTradingCafe  Год назад +1

      Hi thank you for your comment. I think you can compute the SR levels using only backcandles and discarding the current candle. As long as you have let's say 20 recent candles it should be enough to have the SR level.