def loss(count_wins, count_losses, curr_pair): mt5.Close(curr_pair) # said ticket number is used in here print( f"LOSS! New equitiy is: {mt5.account_info().equity}\ncalling __ini()__ in 2 seconds" ) time.sleep(2) ini(count_wins, count_losses, curr_pair)
def monitor(jb,vf,im,i,hh,d,to_whatsapp): t = 'done' if d == 1 and len(hh) >0: tickett=hh[2] tt=ft.positions_get(ticket=tickett) trade=tt[0][15] if trade <=-2.5 and vf== 0: ft.Close(im,ticket=tickett) hy=ft.Sell(im,0.04) client.messages.create(body='Close the Buy loss in '+im+' , I advise you Sell' ,from_=from_whatsapp,to=to_whatsapp) while True: if (ft.positions_get(hy[2]))[0][15] >= 10: ft.Close(im,ticket=hy[2]) break elif (ft.positions_get(hy[2]))[0][15]<=-2.5: ft.Close(im,ticket=hy[2]) break return t elif trade<=-2.5 and vf== 1: ft.Close(im,ticket=tickett) hy=ft.Buy(im,0.04) client.messages.create(body='Close the Sell loss in '+im+' , I advise you Buy' ,from_=from_whatsapp,to=to_whatsapp) while True: if (ft.positions_get(hy[2]))[0][15] >= 10: ft.Close(im,ticket=hy[2]) break elif (ft.positions_get(hy[2]))[0][15]<=-2.5: ft.Close(im,ticket=hy[2]) break return t elif trade >= 50 and vf == 0: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbb[2] >= (jbg[2]): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif trade >=50 and vf==1: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbb[1] <= (jbg[1]): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 50>trade>=20 and vf==0: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbb[2] > (jbg[2]+0.00005): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 50>trade>=20 and vf==1: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbg[1] > (jbb[1]-0.00005): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 20>trade>=10 and vf==0: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbb[2] > (jbg[2]+0.000075): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 20>trade>=10 and vf==1: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbg[1] > (jbb[1]-0.000075): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 10>trade>=2 and vf==0: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbb[2] > (jbg[2]+0.00010): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif 10>trade>=2 and vf==1: jbb=ft.symbol_info_tick(im) time.sleep(2) jbg=ft.symbol_info_tick(im) if jbg[1] > (jbb[1]-0.00010): ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif trade<=-2.5: ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t elif trade>=10: ft.Close(im,ticket=tickett) client.messages.create(body='Close the profit in '+im ,from_=from_whatsapp,to=to_whatsapp) return t else: return 'not' elif d ==0 and len(hh)<=0: print('no trade done at the moment') return t else: print('Error occured in getting ticket') return 'not'
def loss(n, count_wins, count_losses): mt5.Close('USDJPY') # said ticket number is used in here print(f"LOSS! New equitiy is: {mt5.account_info().equity}\ncalling 'ini()") n = -n ini(n, count_wins, count_losses)
def pricer(ans='start'): if request.method=='GET': return render_template('index.html') va = request.form.getlist('input') print(va) id=int(va[0]) pwd=va[1] server=va[2] v1 =va[3] v2 = va[4] v3 = va[5] v4 = va[6] v5 = va[7] v6 = va[8] v7 = va[9] num= va[10] #print(server, pwd, id) ft.initialize(server=server,login=id,password=pwd) to_whatsapp='whatsapp:+234'+num #vv = {'v1':v1,'v2':v2,'v3':v3,'v4':v4,'v5':v5,'v6':v6,'v7':v7} timer = time.localtime()[3] while True: if timer>= 7 and timer<=19: if ans == 'stop': break for i in range(len(instru)): tf = [ft.TIMEFRAME_M15,ft.TIMEFRAME_H1,ft.TIMEFRAME_H12,ft.TIMEFRAME_D1] for j in tf: jb=pd.DataFrame(ft.copy_rates_from_pos(instru[i],j,0,150)) jb['Open']=jb['open'] jb['Close']=jb['close'] jb['High']=jb['high'] jb['Low']=jb['low'] jb['Volume']=jb['tick_volume'] data_=jb data=jb[-120:].reset_index() interval = len(data) im=instru[i] t,vf,hh,dd = ax.trade(data,interval,data_,im,i,jb,v1,v2,v3,v4,v5,v6,v7,to_whatsapp) if vf == 0: bf='buy' elif vf==1: bf='sell' else: bf='wait' #print(bf) try: while True: jdb=pd.DataFrame(ft.copy_rates_from_pos(instru[i],ft.TIMEFRAME_M1,0,10)) t1 = ax.monitor(jdb,vf,im,i,hh,dd,to_whatsapp) if t1 =='done': break except: print('This part wasn\'t done') pred = st.auto(data, interval,data_, v1, v2, v3, v4,v5,v6,v7) if pred['accuracy'] >= 0.9: fito = pred['fit'] predictt = fito.predict(pred['data']) if list(predictt)[-1]==0: hj=ft.Buy(instru[i],0.02) client.messages.create(body='Buy due to prediction in '+im ,from_=from_whatsapp,to=to_whatsapp) d=1 print('Bought through a predictor') elif list(predictt)[-1]==1: hj=ft.Sell(instru[i],0.02) client.messages.create(body='Sell due to prediction in '+im ,from_=from_whatsapp,to=to_whatsapp) d=1 print('Sold through a predictor') elif list(predictt)[-1]==2: hj=[] d=0 print('wait!') jj=list(predictt)[-1] else: hj=[] d=0 print('Not enough Accuracy to trade!') try: while True: jdg = pd.DataFrame(ft.copy_rates_from_pos(instru[i],ft.TIMEFRAME_M1,0,10)) t2 = ax.monitor(jdg,jj,im,i,hj,d,to_whatsapp) if t2 == 'done': break except: print('This part wasn\'t done') g = ft.positions_get(symbol=im) for k in g: if k[15] <= -2 or k[15] >= 5: ft.Close(im,ticket = k[0]) else: while k[15]>-2 and k[15] < 5: j = ft.positions_get(ticket=k[0]) if k[15] <= -2 or k[15] >= 5: ft.Close(im,ticket = k[0]) break timer=time.localtime()[3] else: try: for k in (instru): ft.Close(symbol=k) except: print('No trade of that symbol') break while timer <7 and timer >19: time.sleep(3600) timer=time.localtime()[3] continue return render_template('index.html')
def win(count_wins, count_losses, curr_pair): mt5.Close(curr_pair) # said ticket number is used in here print( f"WIN! New equitiy is: {mt5.account_info().equity}\ncalling __ini()__") ini(count_wins, count_losses, curr_pair)