def _RUN_(): """ p1 = multiprocessing.Process(target = update_all_DB) p2 = multiprocessing.Process(target = list_of_orders) p1.start() p2.start() p1.join() p2.join() """ update_all_DB() orders, magic = list_of_orders() zm = DWX_ZeroMQ_Connector() print( "------------------------------LOAD EXPERT ADVISOR (10 seconds)--------------------------------" ) time.sleep(10) print( "----------------------------- Closing Obsolete Trades-----------------------------" ) for m in magic: if m not in read_from_log(): try: pass # zm._DWX_MTX_CLOSE_TRADES_BY_MAGIC_(m) except: continue write_to_log(magic) for order in orders: try: zm._DWX_MTX_NEW_TRADE_(order) time.sleep(1) except: continue
def _RUN_(): try: update_all_DB() except: pass orders = list_of_orders() zm = DWX_ZeroMQ_Connector() print( "------------------------------LOAD EXPERT ADVISOR (10 seconds)--------------------------------" ) time.sleep(15) for order in orders: try: zm._DWX_MTX_NEW_TRADE_(order) time.sleep(1) except: continue
def trade_sender(_exec_dict): _lock = threading.Lock() dwx = DWX_ZeroMQ_Connector() _lock.acquire() response = dwx._DWX_MTX_NEW_TRADE_(_order=_exec_dict) _lock.release()
import sys sys.path.append( "C:\\Users\\otkin\\dwx_connector\\dwx-zeromq-connector\\v2.0.1\\python\\api" ) from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector _zmq = DWX_ZeroMQ_Connector() # _zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_(DWX_ZeroMQ_Connector, 'EURUSD') my_trade = { '_lots': 0.05, '_SL': 250, '_TP': 750, '_comment': 'we made a trade!' } _zmq._DWX_MTX_NEW_TRADE_(_order=my_trade) # Notes: # MQL4 location C:\Users\otkin\AppData\Roaming\MetaQuotes\Terminal\3B534B10135CFEDF8CD1AAB8BD994B13\MQL4 # mql-zmq-master.zip C:\Users\otkin\dwx_connector
@author: farhad """ from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector a = DWX_ZeroMQ_Connector() a._generate_default_order_dict() a._DWX_MTX_GET_ALL_OPEN_TRADES_() a._DWX_MTX_MODIFY_TRADE_BY_TICKET_(128844168, 200, 200) a._DWX_MTX_CLOSE_TRADE_BY_TICKET_(128844168) a._DWX_MTX_NEW_TRADE_( ) # when this send with no args, default order dict will send a._DWX_MTX_CLOSE_TRADES_BY_MAGIC_(123456) #subscribe to hystorical data of mt4 : a._DWX_MTX_SEND_MARKETDATA_REQUEST_() #subscribe to real market data : # this will fill a dict of our object named Market_Data_DB a._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD') print("response is: ") print(a._get_response_()) a._DWX_MTX_SUBSCRIBE_MARKETDATA_(_symbol='GBPUSD') a._Market_Data_DB['EURUSD']