Open Pusherman2 opened 1 year ago
Same error comment=no price
Hi guys, apologie for the late reply, I didn't get the notifications. I just published a new version of it, the logic of trading with supply and demand, and liquidity pool remains. The bot now is fully optimized ready to be executed with no bugs. BUT, before executing the bot, adjust the self.sec_to_shift valiable according with your local timestamp, an explanation is given inside the script on the top. If you having trouble, comment here and I'll help you out.
hello , thnaks for your effort and your update
we got a new error i dont know if that error or logging
`
df['LCC'].fillna(0, inplace=True)
D:\Python\binacebot\main3.py:257: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
df['HCC'].fillna(0, inplace=True)
D:\Python\binacebot\main3.py:258: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
df['LCC'].fillna(0, inplace=True)
D:\Python\binacebot\main3.py:257: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
df['HCC'].fillna(0, inplace=True)
D:\Python\binacebot\main3.py:258: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
df['LCC'].fillna(0, inplace=True)`
hi , this when i prent a resuot of send order
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURJPY', volume=0.01, price=169.315, stoplimit=0.0, sl=169.35063182107984, tp=169.23988124601522, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened EURJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08198, stoplimit=0.0, sl=1.0822803134490748, tp=1.0815195690075223, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened EURUSD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPAUD', volume=0.01, price=1.9016, stoplimit=0.0, sl=1.9018572785500036, tp=1.900771241993745, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened GBPAUD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPJPY', volume=0.01, price=196.912, stoplimit=0.0, sl=196.84679888786943, tp=196.98265152917955, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened GBPJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='USDJPY', volume=0.01, price=156.486, stoplimit=0.0, sl=156.50504955894215, tp=156.44080685645457, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
mmh, the error could be caused by a new version of pandas. The version of pandas that I use is the 2.1.3. If its not a problem for you, please uninstall your version nad install the 2.1.3. Also, be sure you have correctly set the self.sec_to_shift on the script. I currently trading with this bot and on my machine works fine, try to do these chenges, then let me know.
hi , thanks for fast reply , i will test 2.1.3 , comment='Invalid stops',
Opened EURUSD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDUSD', volume=0.01, price=0.66257, stoplimit=0.0, sl=0.662441019847765, tp=0.661892347709323, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDUSD
OrderSendResult(retcode=10009, deal=11942986, order=11058444, volume=0.01, price=1.47718, bid=0.0, ask=0.0, comment='Request executed', request_id=578486253, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURCAD', volume=0.01, price=1.47684, stoplimit=0.0, sl=1.4765622084342134, tp=1.4774594634029565, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURCAD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDCAD', volume=0.01, price=0.90451, stoplimit=0.0, sl=0.9042825473690412, tp=0.9036827473675684, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDCAD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDJPY', volume=0.01, price=103.639, stoplimit=0.0, sl=103.63082616878619, tp=103.54573901791899, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
thanks , is solved by back to 2.1.3 and fix ,
but i got many error on order :
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:756: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
Looking for pattern in [{'AUDUSD': 4.0}, {'EURCAD': 8.0}, {'USDCAD': 7.5}, {'AUDCAD': 5.0}, {'AUDJPY': 500.0}, {'CADJPY': 500.0}, {'EURAUD': 8.0}, {'EURGBP': 5.0}, {'EURJPY': 750.0}, {'EURUSD': 5.5}, {'GBPAUD': 8.5}, {'GBPJPY': 800.0}, {'USDJPY': 700.0}]...
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDUSD', volume=0.01, price=0.66255, stoplimit=0.0, sl=0.6626687748488084, tp=0.6622441845828886, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDUSD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURCAD', volume=0.01, price=1.4767700000000001, stoplimit=0.0, sl=1.4765399653028368, tp=1.4772525477085992, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURCAD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='USDCAD', volume=0.01, price=1.36511, stoplimit=0.0, sl=1.365434108133832, tp=1.3648068513159812, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened USDCAD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDJPY', volume=0.01, price=103.657, stoplimit=0.0, sl=103.68673723864656, tp=103.59711129686099, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='CADJPY', volume=0.01, price=114.606, stoplimit=0.0, sl=114.56368568107527, tp=114.64280718852149, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened CADJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURAUD', volume=0.01, price=1.633, stoplimit=0.0, sl=1.6323582861122476, tp=1.6333598565956593, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURAUD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURGBP', volume=0.01, price=0.85938, stoplimit=0.0, sl=0.8593902600262882, tp=0.8591521424638537, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08185, stoplimit=0.0, sl=1.081578817650794, tp=1.081985375730158, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURUSD
OrderSendResult(retcode=10009, deal=51224086903, order=51242698025, volume=0.01, price=1.9002599999999998, bid=1.9002599999999998, ask=1.9002599999999998, comment='Request executed', request_id=1801487137, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPAUD', volume=0.01, price=1.9002599999999998, stoplimit=0.0, sl=1.8996991125003948, tp=1.9009124703119569, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened GBPAUD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPJPY', volume=0.01, price=196.973, stoplimit=0.0, sl=197.0051553653484, tp=196.90028637264598, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened GBPJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='USDJPY', volume=0.01, price=156.457, stoplimit=0.0, sl=156.4759344753362, tp=156.41909009641273, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened USDJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, pric
please, confirm that you have correctly set the self.sec_to_shift variable acconrding to your local time as explained in the script. Also have you run the TEST function and checked the close price of the last 10 candles on both EURUSD metatrader chart and the output given by the TEST function, this is the only way to ensure you have correctly set the self.sec_to_shift variable.
hello , my local county time is UTC+3 , so i make self.sec_to_shift = 36000 , so i think value is good do you discoud please ?
please mate, you don't have to believe/think that 36000 is good. Test it. Execute the TEST function and look at the output.
Trade.TEST()
> python .\main3.py
D:\Python\binacebot\main3.py:768: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
406 1.08200
407 1.08186
408 1.08175
409 1.08175
410 1.08185
411 1.08180
412 1.08181
413 1.08191
414 1.08184
415 1.08189
Name: close, dtype: float64
these are the close price of the last 10 candles, look at the chart now of EURUSD and ensure that the last 10 candles (close price only) match each one with each line of the output of the TEST function
hi , Yes they match perfectly
try to execute this
Trade.open_market_position('EURUSD', -1, 0.01)
See if it opens a
short position immediately
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:768: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08201, stoplimit=0.0, sl=1.0820582516699575, tp=1.0816586539538087, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
delete the last function and paste this one
def execution_main(self):
counterr = 1
print(f'Looking for pattern in {self.symbol_list}...')
while True:
try:
self.main(counterr), self.main_close()
counterr = counterr + 1
if counterr > 5:
counterr = 1
time.sleep(28)
except KeyboardInterrupt:
print('\n\KeyboardInterrupt. Stopping.')
exit()
if __name__ == '__main__':
Trade = River()
Trade.execution_main()
You get issue because I set the bot to work on sessions. Replace the code with the above one and the bot should always work.
i do it
Y': 800.0}, {'USDJPY': 700.0}, {'XAUUSD': 700.0}]...
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDUSD', volume=0.01, price=0.66229, stoplimit=0.0, sl=0.6616496356445343, tp=0.6627430009887654, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened AUDUSD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURCAD', volume=0.01, price=1.47596, stoplimit=0.0, sl=1.4759927090879261, tp=1.4776250250041014, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURCAD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='USDCAD', volume=0.01, price=1.36456, stoplimit=0.0, sl=1.363955907498117, tp=1.365129377190089, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened USDCAD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDCAD', volume=0.01, price=0.90519, stoplimit=0.0, sl=0.9048347284961543, tp=0.9029709983177878, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDCAD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='AUDJPY', volume=0.01, price=103.713, stoplimit=0.0, sl=103.66393410727166, tp=103.46934060250145, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened AUDJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='CADJPY', volume=0.01, price=114.526, stoplimit=0.0, sl=114.44249210523097, tp=114.66694835530744, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened CADJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURAUD', volume=0.01, price=1.63208, stoplimit=0.0, sl=1.6317678735940329, tp=1.632699173808205, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURAUD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURGBP', volume=0.01, price=0.85906, stoplimit=0.0, sl=0.8589531623684764, tp=0.8600144017433451, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened EURGBP
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURJPY', volume=0.01, price=169.309, stoplimit=0.0, sl=169.3136087347644, tp=169.05566298969902, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened EURJPY
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08201, stoplimit=0.0, sl=1.0818542316581476, tp=1.081226681470047, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened EURUSD
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPAUD', volume=0.01, price=1.90084, stoplimit=0.0, sl=1.900346837908083, tp=1.8970293478763862, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened GBPAUD
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='GBPJPY', volume=0.01, price=196.823, stoplimit=0.0, sl=196.6519099546009, tp=197.07962381242373, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened GBPJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='USDJPY', volume=0.01, price=156.399, stoplimit=0.0, sl=156.36832287137375, tp=156.4530560518611, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1L1 - Long Opened USDJPY
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='XAUUSD', volume=0.01, price=2358.2, stoplimit=0.0, sl=2358.652203344195, tp=2356.200720401731, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
1S1 - Short Opened XAUUSD
can you confirm that you exeute the Trade.open_market_position('EURUSD', -1, 0.01)
and it didn't open any position? If so, the problem could be on the timing.
Could you please execute and share again the output of the TEST function?
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:768: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
D:\Python\binacebot\main3.py:790: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08201, stoplimit=0.0, sl=1.0819995946276046, tp=1.0810505573870435, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
490 1.08184
491 1.08184
492 1.08189
493 1.08189
494 1.08182
495 1.08159
496 1.08168
497 1.08161
498 1.08160
499 1.08160
Name: close, dtype: float64
sometime no price and other Invalid stops
so make sure the time_shifting correct my local time is UTC+3 (12:44 AM) now , what shoud value be ?
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:768: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
D:\Python\binacebot\main3.py:790: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08194, stoplimit=0.0, sl=1.0819995946276046, tp=1.0810505573870435, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
490 1.08184
491 1.08184
492 1.08189
493 1.08189
494 1.08182
495 1.08159
496 1.08168
497 1.08161
498 1.08160
499 1.08155
Name: close, dtype: float64
I assume the prices are on the 5 min timeframe. These are the prices just given on my machine on EURUSD: 490 1.08190 491 1.08188 492 1.08195 493 1.08196 494 1.08197 495 1.08183 496 1.08184 497 1.08171 498 1.08177 499 1.08176
As you can see there's a mismatch. Please, review the self.sec_to_shift, probably 36000 its the wrong value, this could happen sometimes because some brokers give data to from a different source, meaning different datetime, only for the developers. So you have to adjust the variable according.
Here’s how you calculate it: 3 hours = 3 60 minutes/hour 60 seconds/minute = 10800 seconds So, you should set sec_to_shift to 10800.
now i use 10800
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:768: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
D:\Python\binacebot\main3.py:790: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08197, stoplimit=0.0, sl=1.0818865675911462, tp=1.0811109695621741, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
490 1.08184
491 1.08189
492 1.08189
493 1.08182
494 1.08159
495 1.08168
496 1.08161
497 1.08160
498 1.08156
499 1.08158
Name: close, dtype: float64
i use demo MT5 server
my discord : "anaspro_pro" if you text me please
use this TEST function:
` def TEST(self):
SYMBOL = self.SYMBOL
number_of_candles = 500
looknow = int(datetime.utcnow().timestamp())
lookback = (looknow - (number_of_candles * 5)*60) # in sec
df = pd.DataFrame(mt5.copy_rates_range(SYMBOL, self.TIMEFRAME_5M, lookback + self.sec_to_shift, looknow + self.sec_to_shift))
df['time'] = pd.to_datetime(df['time'], unit='s')
df = df.drop(['spread','real_volume'],axis=1)
print(df[['time', 'close']].tail(10))
return df`
thanks for update test function
is is 100% match with my local time and my pc
self.sec_to_shift = 10800
PS D:\Python\binacebot> python .\main3.py
D:\Python\binacebot\main3.py:780: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
D:\Python\binacebot\main3.py:802: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08196, stoplimit=0.0, sl=1.0818225753016053, tp=1.0812702089602928, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
time close
490 2024-05-14 23:50:00 1.08189
491 2024-05-14 23:55:00 1.08182
492 2024-05-15 00:00:00 1.08159
493 2024-05-15 00:05:00 1.08168
494 2024-05-15 00:10:00 1.08161
495 2024-05-15 00:15:00 1.08160
496 2024-05-15 00:20:00 1.08156
497 2024-05-15 00:25:00 1.08157
498 2024-05-15 00:30:00 1.08159
499 2024-05-15 00:35:00 1.08158
Trade.open_market_position('EURUSD', -1, 0.01)
Trade.open_market_position('EURUSD', 1, 0.01)
> python .\main3.py
D:\Python\binacebot\main3.py:780: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
D:\Python\binacebot\main3.py:802: SyntaxWarning: invalid escape sequence '\K'
print('\n\KeyboardInterrupt. Stopping.')
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08196, stoplimit=0.0, sl=1.0818225753016053, tp=1.0812702089602928, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08162, stoplimit=0.0, sl=1.0813574246983948, tp=1.0819097910397073, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
PS D:\Python\binacebot>
the issue can only be on the self.sec_to_shift. You cant even open a position by executing the open_market_position function, which is using the ATR for sl and tp, and the ATR takes the data from the Historical function. There's a mismatch. Unfortunately you have to figure it out by yourself, indeed this is a problem already brought up by others, have a look at this forum
You have to adjust it by yourself mate, then try to open a position.
the problem showing error not price but i do this , see the output
print(mt5.symbol_info_tick(Trade.SYMBOL).ask)
print(mt5.symbol_info_tick(Trade.SYMBOL).bid)
Trade.open_market_position('EURUSD', -1, 0.01)
Trade.open_market_position('EURUSD', 1, 0.01)
PS D:\Python\binacebot> python .\main3.py
1.08196 <<<<<<<<<<<<<
1.08162 <<<<<<<<<<<<<
OrderSendResult(retcode=10016, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Invalid stops', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08196, stoplimit=0.0, sl=1.0818226966440039, tp=1.081341292114495, deviation=20, type=1, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
OrderSendResult(retcode=10021, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='No prices', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=2222, order=0, symbol='EURUSD', volume=0.01, price=1.08162, stoplimit=0.0, sl=1.0814173033559962, tp=1.0818987078855051, deviation=20, type=0, type_filling=1, type_time=0, expiration=0, comment='River', position=0, position_by=0))
PS D:\Python\binacebot>
move on discord
thanks for follow up. waiting you there
Dear, thanks for your support the issues are solved by reverse .ask with .bid on order function
i really intersted if that any new update for your script code
Hello mr.Jessika, i still waiting your update :)
Hi there,
Interesting project!
I tried running it for demo account (ECN) but I got error message 10016 for invalid stops using MT5. I assume it had to do with rounding issues to I tried rounding upto 4 decimal points but no dice. The error occurred for GBPUSD but I think I also saw some other pairs and no orders/trades being placed.
Do you know how I can prevent this error from occurring?
Thank you and kind regards.