INNER CODE UNIT · Python
Execute_Buy_Order
Mo-Khalifa96/Forex-Trading-Bot · OrderProcessing.py:93
def Execute_Buy_Order(symbol, openp, min_val, avg_val):
'''This function creates and sends a buy order.'''
#Create buy request
buy_request = Buy_req(symbol, openp, min_val, avg_val)
#Create buy order
buy_order = mt5.order_send(buy_request)
#Check Order Status
if buy_order.retcode == mt5.TRADE_RETCODE_REQUOTE:
print(f'\nRequote required! Trying again...')
loop_n = 0
while loop_n < 10: #Try again 10 times...
#Send order
buy_request = Buy_req(symbol, openp, min_val, avg_val)
buy_order = mt5.order_send(buy_request)
if buy_order.retcode == mt5.TRADE_RETCODE_DONE: