Code a simple Trading Robot | Trading with Python

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

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

  • @sebavergarasassi6462
    @sebavergarasassi6462 2 года назад +6

    Your example its amazing! Its better than the all mql5 documentation! I am very glad with you!

  • @martinsbaumanis5981
    @martinsbaumanis5981 День назад

    Thanks for the code, brother. I really needed a break and this is it. I wish you the best.

  • @ATJTraders618
    @ATJTraders618  3 года назад +2

    What type of content do you want to see next? Do you want to see more code examples on different algo trading strategies? Do you want to see more backtests, strategy analysis or live trading? Or do you prefer to go more in-depth into the actual code? Please let me know and have a great day :).

    • @xiangli4314
      @xiangli4314 3 года назад +2

      Hi,thks for your video. It`s very very helpful for me ! I think this is a very good video serial for anyone who wants to learn trading by python.

    • @sammarieobrown6455
      @sammarieobrown6455 3 года назад

      @@xiangli4314 I so much agree!!

    • @sammarieobrown6455
      @sammarieobrown6455 3 года назад

      I see where you did a video on the long and short SMA cross over, could you do a short video on how to deploy it live? would love to see that

    • @TheTherapistsOfficial
      @TheTherapistsOfficial 3 года назад +1

      Can you show the example code of GRID trading with Martingale strategy?

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

      how I can run my python code 24\7 in mt5 ?

  • @ricardoalmeida6350
    @ricardoalmeida6350 2 года назад +4

    Great video mate! Very nice starting point to develop a trading bot using python + MT5.

  • @Grovebuy
    @Grovebuy 9 месяцев назад

    thank you very much for such an instructive and wonderful lesson, it's just super

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

    Hi there.. do you always run your code directly on demo account, or did you some backtesting before dropping the code on the account.?
    If you did backtesting it, how did you do it.?

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

    Excellent video, Thank's sir

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

    Thanks a lot bro.... Thank you so much for this wonderful video

  • @TheTherapistsOfficial
    @TheTherapistsOfficial 3 года назад +1

    Thek you very much, I follow up on your content and it interested me. For the next content, can you show the example code of GRID trading with Martingale strategy?

  • @alpsgrin4501
    @alpsgrin4501 3 года назад +3

    I was knocked out by stop loss. But the indicator conditions were satisfied and the robot sent again the order. Again, the stop loss was knocked out so that it did not continue. You need to write a timeout for 1 hour in the code, for example. until the news spike passes

  • @anilvarma9893
    @anilvarma9893 8 месяцев назад

    Hi, is there any way to copy iCustom indicator or MQL Indicator buffer values into Python?

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

    great tutorial .though I encountered an error 'IndexError: single positional indexer is out of bounds' which occured between lines 93 and 121.I need your help debugging this please.

  • @jayess2226
    @jayess2226 2 года назад +3

    I am new to Trading with Python but I wonder is there a more efficient way than to check for a signal with an infinite loop? Because therefore it requests the former close price many times per second but actually it would be enough to get the close price only when a bar is closed (so once a minute in your example).

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

      you could use time.sleep(60) to pause the program between each loop iteration

  • @bilgassimjalouta1035
    @bilgassimjalouta1035 6 месяцев назад

    big content my friend love it

  • @Peter-kj1fm
    @Peter-kj1fm 2 года назад +1

    Salute Great content ..
    Am trading local Stokes and am trying to figure out if it is possible to create a price alert bot if non of the brokers in my area are featured on mt5.
    Thanks in advance

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

    Hey man, this is beautiful. Thanks.

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

    how would you set the timeframe so that it runs through multiple time frames?

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

    Thank you and thank you again great content

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

    did it try it with any exchanges in Cryptocurrency or you could try to optimize it with Binance exchange.

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

    Maybe I missed it, but where do you have a TP?

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

    for me this doesnt work because you are setting the last close bar > sma to signal buy and vice versa. it doesnt mean buy when the price is above the moving average and sell when it is below the sma. when i run this code it sells when the last close bar of a timeframe specified if it is below the sma then sell and above then buy. when i look on your screen it seems your code runs differently for some reason.

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

    If I want to change my instrument what adjustment should I do?

  • @mrtumbi2974
    @mrtumbi2974 9 месяцев назад

    Can I use it in Indian stock market

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

    can you use this python script to backtest in MT5 terminal...If yes please make a video on that I couldn't find a single video on this topic.

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

    how did you get the command prompt on mac?

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

    TraderPy ---many thanks

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

    Hi, it was a great presentation and good to see the nice code.
    Would you be able to share code or checked in some where please?

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

    how to applied this in nasdaq, bei, or stock market?

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

    Thank you very much for sharing, But How can I stop the prompt to display any text, just run the algo without any output in the commandline?

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

    Is it possible to get the stategy parameters from an INI file ?

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

    hi i coding that like but with supertrend . Can you share about like video? Thank you

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

    Hi i have created sma cross over strategy on 5 min timeframe and i am getting tick by tick data but i need some help to updat code of one logic can ypu help me the same . I am happy to share the code

  • @leonardobalocchi-w8o
    @leonardobalocchi-w8o Год назад

    It return me an error inside the function definition "signal()", it say to me "index out of bound", is it correct to change iloc[-1] with iloc[0] to target the first element?

  • @georgitanev-w4b
    @georgitanev-w4b 2 года назад

    Do you have any Github repos with this code?

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

    This phyton tools will work in tester?

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

      Unfortunately, it will not but we have our own backtester to evaluate the results.

  • @sesto-dev
    @sesto-dev 4 месяца назад

    The code link for this video does not work.

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

    How to loop through all the symbols using this code ?😊

  • @fransjacowillemse6782
    @fransjacowillemse6782 2 года назад +3

    Love your videos! to the point, have you ever done a bot that can choose a strategy based on a market condition, e.g. trending or ranging market then choose strat A or B or maybe adding some logic to determine the current market direction before executing the order, as some bots don't work well with certain market conditions, that way you can keep your bot running and it will only trade if the market is e.g. trending.

  • @abdullahahmad9334
    @abdullahahmad9334 3 года назад

    you are good bro thank you again and again.

  • @alpsgrin4501
    @alpsgrin4501 3 года назад

    please tell me what would you add in the code ??? to implement a stop sending an order ??? Or a slip function ??? if I added an indicator and the overbought or oversold zone did not come and do not want to enter a trade without confirmation of the second indicator

    • @ATJTraders618
      @ATJTraders618  3 года назад +1

      That is a good question. You can add an extra condition before you want to place on order.
      Let's say you have a crossover and you also want to check another condition, so the logic would look as follows:
      if bullish_crossover and rsi_oversold:
      Buy
      You can create a new indicator column and check other conditions as well which serve as filters for entries.

  • @timothyyoung980
    @timothyyoung980 6 месяцев назад

    The discord link doesn't work

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

    Can you elaborate a bit more on how order type is determined thru dictionary. The order type should written in full, for ex: mt5.ORDER_TYPE_BUY

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

    HI, where is set up the connection to the metatrader account? only if I run the python script in windows cmd, it will be worked? Thanks

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

      Did you find the answer yet i have the same question

  • @xiangli4314
    @xiangli4314 3 года назад +1

    Hi, I don't understand why u don't active this robot directly with ur code editor?(like: pycharm)

    • @ATJTraders618
      @ATJTraders618  3 года назад

      Hi Xiang Li, it is a habit of mine to run finished code in the command prompt. PyCharm is a heavy IDE and may take up alot of memory. When deploying robots on a VPS, you want to maximize resources.
      I do run my code in PyCharm for testing purposes but for this video, I decided to present it it cmd window.

  • @cc-musics6382
    @cc-musics6382 2 года назад +1

    great but please teach us how to run our python but on a host or server because it just run on our computer because it need to run metatrader5.exe first in order to trade .thanks

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

    When I try to run the code like you in the command prompt, it does show that the code is analyzing the MT5 data. But no trades are opening on my MT5. What problem might I have? How can I fix it?

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

      Hi, do you receive any message back when you send an order? Please make sure that Auto Trading is enabled in the MetaTrader5 platform.

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

      Got it! Seemed to work now, what had happened was I needed to change the 'mt5.ORDER_FILLING_IOC' to 'mt5.ORDER_FILLING_FOK'. Would you know how I can write code to input stop loss and take profit for my risk management? Thanks for all the helpful videos

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

    Great video! I have installed pandas & MT5 successfully, however I am getting errors in code (after MT5 is opened with focus on instrument e.g. EURUSD): 'DataFrame' object has no attribute 'close' and another one 'IndexError: single positional indexer is out-of-bounds' .. how can I resolve these.

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

      Hi, most likely, the DataFrame is empty. Please make sure that all symbols in the market watch are enabled.
      Also, try to enter a shorter time period in MT5. Sometimes, when the period is too long, it won't return any data.

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

    Great content, would recomend you to add the overlap of a 10 and 15 EMAs as a signal in your enviroment.

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

      Trading bots are mostly scams... but there are exceptions. You just need a lot a patience to backtest and run many bots, discard the ones that are scams and keep playing with the ones that are good. EDIT: since so many of you ask, yes I use Galileo FX..

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

      @@RobinArgumido 😁

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

    I have also built a trading bot...but I am having some issues...so i need your help.

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

    Hey. I recently discovered a lot of your videos on Python and trading because I am a student. I really enjoy it when a presentation goes into such detail and explains everything with codes. I also came across another such video by QuantInsti that talks about backtesting a trading strategy - "Full Algo Trading Course | Python Trading Bot | Python Quantitative Trading | 3/3".
    Quite curious to try both. Thank you!

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

    Can you please share on how to convert SMA to EMA.

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

    the source code link doesnt work , what can I do to open it on an IDE?

  • @fbrand
    @fbrand 3 года назад +1

    Thank you again for laying our foundational understanding in these programs. What I wanted to know if you can also sometime show how to trade more than one currency pair and also what about trading the EU and EJ, then the decimals differ. Also as an add-on what is the best way to run these scripts, as I have previous tried and they run for a few hours, but then crash when just starting then straight from CMD. Cheers

    • @ATJTraders618
      @ATJTraders618  3 года назад +2

      Hey, regarding the decimals, you can adjust the point values based on the digit based on each symbol.
      Each symbol has its own decimal point value which you can get from symbol_info(). Therefore, the point value is easilly calculated using the following formula:
      point value = contract size / (10^digits)
      Regarding the script crash, there may be many causes. Do you have the error logged upon crash? If so, you can send me more details to tu@traderpy.com and I will happily have a further look.

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

    Hello Sir. its an amazing script. i would like to make it take profit once the trade runs in profit in seconds. how can i do that?

  • @Penta_Penguin_237
    @Penta_Penguin_237 3 года назад

    You are great Man! Just wanna say that. Thank you for all!

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

    Can i use this script for volitality index?

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

      Hi, yes of course. All you need to find a broker who offers trading the VIX. IC Markets, the broker I'm affiliated with, offers it. Check the description for more info. :)

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

    What's your coding environment like? Can you deploy on linux?

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

      I use windows VPS where I deploy using Remote Desktop Connection.

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

    Hello. Can you create multihedge strategy with python?

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

      Hi, do you have any link where I can read more details about this strategy?

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

    I can't install MT5 lib on mac
    Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)

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

    I love you man

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

    IndexError: single positional indexer is out-of-bounds
    I gee this error when I try to run the code
    Please help

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

    I tried this code on JUPYTER NOTEBOOK and i was getting this error of "IndexError: single positional indexer is out-of-bounds" due to the "iloc" builtin function in the SIGNAL function definition whenever i run the code, if anyone can sort it out kindly. Thank you!

  • @itsely6608
    @itsely6608 7 месяцев назад

    Maybe it’s worth adding a command (Sleep) so that the broker doesn’t ban you for the number of requests to the exchange???

    • @ATJTraders618
      @ATJTraders618  7 месяцев назад

      From our experience, the requests do not interfere with the broker server and the it shouldn't cause a problem. A sleep function of 1 second is implemented in the code already.

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

    Please help with how to set up the mql5 environment with python i keep getting this error
    "C:\Users\USER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\python.exe" -u "C:\Users\USER\AppData\Roaming\MetaQuotes\Terminal\A5862E2007921267C73493E43631301B\MQL5\Scripts\testing.py" unknown 1 failed
    in the mt5 journal and also
    'Python testing2': python process thread create error [The system cannot find the file specified. (2)]

  • @kannadastories652
    @kannadastories652 3 года назад +1

    Bro code price action strategy algo

  • @LucasAlves-rw2ch
    @LucasAlves-rw2ch 2 года назад

    I really need your help in your code, it runs perfectly, the only parameter missing is stoploss and takeprofit
    I'm trying to put a stoploos of 20 points and a takeprofit and 1 point, but when I do that it doesn't send the orders to the market

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

      Hi, try to use floats instead of integers. Also sl and tp params are set as exact price levels.

    • @LucasAlves-rw2ch
      @LucasAlves-rw2ch 2 года назад

      @@ATJTraders618 Ok, I contacted your email explaining better, thanks for the help

  • @timothyyoung980
    @timothyyoung980 6 месяцев назад

    Anyone know where I can get the code from in this video?

    • @ATJTraders618
      @ATJTraders618  6 месяцев назад

      Hi, the description has been updated with the download link.

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

    Hello, Nice Video
    Please i have a trading strategy that i want to turn into a trading bot

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

    Can I run it using VS CODE?

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

    Can you run the code on mt4?

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

    hello sir i am new here i want your help sir please sir kindly write a code on crossing moving averages exponential method where two line cross over take buy or sell

  • @vandesar9114
    @vandesar9114 3 года назад

    Please create a video of trading robot using Machine Learning or Some Ai Tools inside the Python . Thanks

    • @ATJTraders618
      @ATJTraders618  3 года назад +4

      Hi Van De Sar, I am currently studying ML but as of this moment, I don't have enough practice to be confident in presenting this topic. Maybe sometime in the future.
      I do recommend Ernest Chan who is a great role model in developing ML models for trading: ruclips.net/video/BhaJVZNpL4M/видео.html

    • @vandesar9114
      @vandesar9114 3 года назад

      @@ATJTraders618 Don't worry, I just made a suggestion for your future plans. The videos you currently make are great.

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

    Can anyone plz suggest me the documentation

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

      Hi, you can find the documentation for MT5 and the source code in the descriptions.

  • @wongchenkeat1842
    @wongchenkeat1842 8 месяцев назад

    MetaTrader 5 library no longer working in python.

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

    i have error 'unsupported filling mode'

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

      Hi, it means that your broker only accepts certain order types.
      You can specify it filling type parameter and try different values like:
      FOK
      GTC
      IOC

  • @viettuannguyen1638
    @viettuannguyen1638 3 года назад

    could u share the code scripts as text so I can copy to run on my server?

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

    good day bro, if you can read my comment, I came across this tutorial and it is very useful but it seems it does not work anymore.

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

    Source code?

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

    last_close = bars_df.iloc[-1].close
    it gives an "IndexError: single positional indexer is out-of-bounds" in the line above. What should i do? why we index it to [-1]?

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

    Statistical Arbitrage!!!👋👋👋👋👋

  • @Peter-kj1fm
    @Peter-kj1fm 2 года назад

    Hola

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

    Such a great video! It seriously helped me create my very own trading bot. If you're a beginner like me, this video is a must-watch.
    Also, check out "Algorithmic Trading Tutorial Python | Build Trading Algorithm from Scratch" by QuantInsti - another awesome video that helped me understand the fundamentals of algorithmic trading and build my own algorithm. Super helpful and definitely worth watching!
    Big thanks to both videos for giving me the knowledge and confidence to create my trading bot. Can't wait to see what it can do! 😄🚀