Last active
June 12, 2023 19:09
-
-
Save mamirjamali/826146b04dc8043aba4d88cc04639ae8 to your computer and use it in GitHub Desktop.
Python - Pivot-Points for 200 past candels integrated with MQL API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas as pd | |
import MetaTrader5 as mt5 | |
import re | |
mt5.initialize() | |
account=###Your Acount###### | |
authorized= mt5.login(account) | |
first_date = datetime.datetime(1970, 1, 1) | |
time_since = datetime.datetime.now() - first_date | |
seconds = int(time_since.total_seconds()) | |
time = str(seconds/(86400*364)) | |
options_symbols=mt5.symbols_get("*EURUSD*") | |
timeframes=[mt5.TIMEFRAME_D1] | |
rates = mt5.copy_rates_from_pos(options_symbols, timeframe, 0, 200) | |
rates_frame = pd.DataFrame(rates) | |
# convert time in seconds into the datetime format | |
rates_frame['time']=pd.to_datetime(rates_frame['time'], unit='s') | |
################ Pivot Calculation ################ | |
pp= ( rates_frame['high'][i]+rates_frame['low'][i]+rates_frame['close'][i])/3 | |
res1= (2 * pp)- rates_frame['low'][i] | |
res2= pp + ( rates_frame['high'][i]- rates_frame['low'][i]) | |
res3= 2*pp + ( rates_frame['high'][i]- 2*rates_frame['low'][i]) | |
res_half=(pp + res1)/2 | |
res_one_half= (res1 + res2)/2 | |
res_two_half= (res2 + res3)/2 | |
sup1= (2 * pp)- rates_frame['high'][i] | |
sup2= pp - ( rates_frame['high'][i]- rates_frame['low'][i]) | |
sup3= 2*pp - ( rates_frame['high'][i]- 2*rates_frame['low'][i]) | |
sup_half=(pp + sup1)/2 | |
sup_one_half= (sup1 + sup2)/2 | |
sup_two_half= (sup2 + sup3)/2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment