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
344
71%
Arbitration
12
42%
/
25%
Overdue
12
3%
Working
Published: 14 codes
2
Rating
Projects
455
26%
Arbitration
134
21%
/
58%
Overdue
99
22%
Free
3
Rating
Projects
459
39%
Arbitration
94
44%
/
18%
Overdue
73
16%
Loaded
Published: 2 codes
Similar orders
Convert Advanced SMC Pine Script Strategy to MQL5 EA / Autotrade option Job Description: We are seeking an experienced MQL5 developer to accurately convert a sophisticated Smart Money Concepts (SMC) strategy from TradingView Pine Script into a robust, professional-grade MetaTrader 5 Expert Advisor (EA). The original code is complex and includes advanced logic for pivot detection, dynamic position sizing, and visual
Job Description: · I am looking for an experienced MQL4 developer to create a high-speed scalping EA for US30 and DE40. The EA must be optimized for ultra-fast execution and should not rely on any indicators—only price action and pending orders (Buy Stop & Sell Stop). · I have written a complete and detailed documentation outlining the logic, execution flow, risk management, and required settings
Mthizo trades
30 - 200 USD
- *Currency Pairs*: Major pairs such as EUR/USD, XAU/USD and GBP/USD - *Funding Currency*: South African Rand (ZAR) - *Initial Deposit*: R100 (may require additional deposit for live trading) - *Risk Management*: Basic risk management features, such as stop loss and take profit - *Strategy*: Pre-defined strategy based on Smart Money Concept principles - *Cost*: Approximately R100-R200 (one-time cost or
Robot (metatrader5)
30 - 200 USD
I need an Expert Advisor (EA) for MetaTrader 5 that trades only XAUUSD (Gold). The strategy should include: • EMA (50) on M15 timeframe • RSI (14) with overbought = 70 and oversold = 30 • ATR (14) for Stop Loss and Take Profit calculation • Higher timeframe EMA (200 on H1) as trend filter • Lot size calculation based on risk percentage (% of balance) • Magic number for trade identification • Trading hours: 07:00 –
Job Description: I need a professional TradingView developer to build a custom TradingView indicator that replicates the logic of a TradingView indicator I use. The indicator should identify market structure, breaks of structure (BOS), and fair value gaps (FVGs) while displaying both current and higher timeframe data on the chart. ⸻ Key Features & Logic 1. Zones & Market Structure • Zone 1 = Market Structure (base
I need an Expert advisor based on AOX signal . it must have check and handing of trade operation..errors. The main criterin for opening and dosing a position : moving average direction the price is higher than the previous bar Trade lots is input parameter bar
Here's a detailed description of a Trend Following and Mean Reversion strategy-based Expert Advisor (EA): Strategy Overview The EA will implement a hybrid strategy combining trend following and mean reversion techniques. It will identify trending markets, ride the trend, and also capitalize on mean reversion opportunities
Overview Create a MetaTrader 5 (MT5) indicator that: Pulls live sentiment data from multiple broker APIs. Calculates Net Sentiment (Long% – Short%) and plots each broker as a moving average line on the chart. Displays a weighted average line when ≥2 feeds are active. Saves all data to CSV files per broker for efficient historical loading and performance. Supported Brokers Broker Abbr. Color OandaFX
We are seeking a highly skilled MQL4 developer to complete a very complex EA project. Requirements & Conditions: Strict Timeline: 5 days delivery + 3 days rectification (non-negotiable) Must be free from other jobs and have strong history in complex EA development EA covers advanced features such as: Candle & HMA-based trade restrictions Multi-level breakeven, profit protection & profit trail Standard & Step trailing
Safe Monthly Profit Strategy
30 - 60 USD
Manage my live forex account with a disciplined, low-risk approach that produces steady monthly income. My priority is capital protection, so each trade must be sized conservatively, anchored by firm stop-loss orders, and designed to keep drawdown minimal. High-risk tactics such as martingale, grid systems, or excessive leverage are off the table; a measured, rules-based strategy is essential. I will connect the
Project information
Budget
30 - 50 USD
For the developer
27
- 45
USD
Deadline
from 1 to 14 day(s)