INNER CODE UNIT · Python
Buy_req
Mo-Khalifa96/Forex-Trading-Bot · OrderProcessing.py:37
def Buy_req(symbol, entryp, min_val, avg_val):
'''This function creates and returns a buy request.'''
#Get lot amount
lot = get_lot(mt5.account_info()._asdict()['balance'])
#Double the lot if price is closer to the average line
if entryp >= np.mean([min_val, avg_val]):
lot = round(lot*2,2)
#Get decimals for current symbol
decimals = (5 if 'JPY' not in symbol else 3)
#Create buy request
req = {
'action': mt5.TRADE_ACTION_DEAL,
'symbol': symbol,
'volume': lot,
'type': mt5.ORDER_TYPE_BUY,