You might want to add some logging to your script to see if your code is reaching the point where an order would be placed:
import MetaTrader5 as mt import time print("Initializing MT5 connection...") mt.initialize() symbol = 'XAUUSD' while True: current_second = time.localtime().tm_sec if current_second == 1: print("The second is 1, but no order should be placed.") # Setting timeframe = mt.TIMEFRAME_M1 start_bar = 0 num_bars = 50 # Add your logging or print statements here
Running this script should help you verify whether the script itself is responsible for the order or if something else is triggering it. If your script is indeed the culprit, you may need to share the complete script for a more thorough examination. If it's not your script, you'll need to investigate the MT5 terminal settings and any other running EAs or scripts.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone,
I'm trying to use Python for automatic trading (Demo account), but I found that MT5 Auto places a Buy order when I do nothing.
And only one time when start
Here is my code, only initialize, nothing else
Then, when the second is 1, MT5 auto places a Buy order with 0.01 lot.
I don't know why it happened.
Please help me.