Specification
import pandas as pd
import numpy as np
def generate_signals(data):
signals = pd.DataFrame(index=data.index)
signals['price'] = data['Close']
# Calculate moving averages
signals['short_ma'] = data['Close'].rolling(window=20, min_periods=1).mean()
signals['long_ma'] = data['Close'].rolling(window=50, min_periods=1).mean()
# Generate buy signals
signals['buy_signal'] = np.where(signals['short_ma'] > signals['long_ma'], 1, 0)
# Generate sell signals
signals['sell_signal'] = np.where(signals['short_ma'] < signals['long_ma'], -1, 0)
return signals
def backtest_strategy(signals, initial_capital=10000):
positions = pd.DataFrame(index=signals.index).fillna(0.0)
positions['asset'] = 1000 * signals['buy_signal'] + -1000 * signals['sell_signal']
# Calculate portfolio value
portfolio = positions.multiply(signals['price'], axis=0)
pos_diff = positions.diff()
portfolio['holdings'] = (positions.multiply(signals['price'], axis=0)).sum(axis=1)
portfolio['cash'] = initial_capital - (pos_diff.multiply(signals['price'], axis=0)).sum(axis=1).cumsum()
portfolio['total'] = portfolio['cash'] + portfolio['holdings']
portfolio['returns'] = portfolio['total'].pct_change()
return portfolio
# Example usage:
# Assuming 'data' is a DataFrame containing historical price data with 'Date' as index and 'Close' as a column
# signals = generate_signals(data)
# portfolio = backtest_strategy(signals)
# print(portfolio.tail())
Responded
1
Rating
Projects
222
58%
Arbitration
7
29%
/
29%
Overdue
7
3%
Working
2
Rating
Projects
440
26%
Arbitration
125
21%
/
56%
Overdue
96
22%
Working
3
Rating
Projects
402
38%
Arbitration
82
41%
/
20%
Overdue
70
17%
Working
Similar orders
Need to convert 3 MQL4 files to MQL5
100 - 150 USD
These three mql4 files are working and functioning correctly as intended. All I want is convert all these three files into mql5 compliant and should be running just as it would in mql4 files
I am looking for an expert NinjaTrader developer to help me backtest a custom trading strategy I've developed. The ideal candidate will have extensive experience in trading, particularly with backtesting and strategy evaluation on the NinjaTrader platform. Your expertise will be crucial to the success of this project. Key Requirements: Custom Strategy Backtesting: Develop and backtest a unique trading strategy based
Great Opportunity 👍🤞
30+ USD
Just have a look make it better enjoy and have fun 😊 this is the first time I am trying this, I got ripped off 3 times before. I hope this time works with all your help. Thank you kindly
I have an MT5 EA which I like to modify to run on custom symbol chart. I can backtest the EA on the custom symbol chart, but I cannot run on the chart to trade. When I attach the EA to the custom symbol chart, it gives me error: "2024.06.07 21:27:59.270 Trades '1520250871': failed request buy 0.1 BTCUSD_ATR10_M1 at 69260.30000 [Invalid request]" Please help me to modify the EA to run on custom symbol chart. EA is
I will provide pine script and need to convert it as a mql4 EA. The system is based on swing highs and lows. If you interested please knock me, Thank you
I want an Indicator that : Draws vertical lines at the opening of candles on a time frames selected.( I want to be able change the candle timeframe the line will be drawn. Eg. I can slelect 1H, 4H etc from the settings, and the vertical line will be drawn at the opening). Draw a horizontal line at the opening of the candles in the selected timeframe. Calculate the average range of the candles on a selected timeframe
Debug of Indicator
30+ USD
Hello, I need to optimize my indicator so that it works in several time frames. and then convert it to mq5 The task will be carried out remotely by ANYDESK
Button plus minus on chart mql4
30+ USD
I would need an indicator which makes averages on chart (like the one existing already on mt4 where you can choose between EMA, SMA, ...) but what i need is on chart a button plus and minus which i could press in order to change the average visually on chart( so i dont have to come back in the settings of the indicator each time to introduce a new average number) And average in mt4 is limited basically at 4000 but
I am looking for an experienced MQL5 developer to convert a TradingView indicator into an Expert Advisor (EA) for MetaTrader 5 (MT5). The TradingView indicator uses specific conditions to trigger buy and sell signals, and I would like these conditions to be replicated in the MQL5 EA. Stop Loss in points Take Profit in points Trailing Stop activation level in points Trailing Stop distance in points Maximum number of
Bot name: Blues🚀ProFx The bot should work with the 5mins time frame and it must move with the market price bar when it moves up 5pips and above let 10 trades be opened in the up direction and each having a stop loss of 20pips. After every 5mins if a new candle forms in the same direction let another 10 trades be opened in the same manner. Then when the market trend changes and a bearish candle starts to form and
Project information
Budget
30 - 50 USD
For the developer
27
- 45
USD
Deadline
from 1 to 14 day(s)