Rewrite code of the STD (of symbol) in the indicator and EA for the spread formula with the STD of returns instead
Input parameters
Symbol A
Symbol B
Sign of beta (1 for positive value and
-1 for negative value)
Enter positions threshold
Exit positions threshold
Symbol A Lots
Symbol B Lots
Maximum loss in account currency
Maximum profit in account currency
Period for returns
Period of STD
Stoploss A (in pips)
Stoploss B (in pips)
The algorithm
Making a
Robot on JForex which can take positions on several pairs trading at a time or
one robot per pairs trading.
All calculations and trades take place
at bar opening (when the first tick of new bar occurs at any symbol) and only
close prices are used in calculations.
1. Calculate the returns of both symbols:
Return = (P – Pt) / Pt
P – close price of previous bar,
Pt – close price Period for returns bars ago.
2. Calculate standard deviations of “Close” prices for Period
of STD bars for both symbols.
3. Calculate the spread using the following formula:
Spread = Return(Symbol A) / STD(Return(Symbol A)) -
Return(Symbol B) / STD(Return(Symbol B))
4. Trading.
If the beta is positive:
If the spread amount at previous
bar reaches Enter positions threshold (positive), send SELL
market order for Symbol A and BUY market order for Symbol B.
If the spread amount at previous
bar reaches minus Enter positions threshold (negative), send BUY
market order for Symbol A and SELL market order for Symbol B.
If the beta is negative:
If the spread amount at previous
bar reaches Enter positions
threshold (positive), send BUY
market order for Symbol A and BUY market order for Symbol B.
If the spread amount at previous
bar reaches minus Enter
positions threshold (negative),
send SELL market order for Symbol A and SELL market order for Symbol B.
5. The EA should close both positions in one of the following
cases:
- total result of the positions reaches Maximum loss in account currency;
- total result of the positions reaches Maximum profit in account currency;
- the spread value at previous bar decreases
to Exit positions threshold (in absolute value).
6. Open a position for each crossing of a
threshold, even if a position was opened before.
7. The
EA will have to find all open positions, sort them by pairs, check whether a
position in each pair is closed by stop-loss or not, if so - close another
position of the pair...
8. Calculating the profit
or loss for a pairs trading position independently for each position. If the
trading account don't have enough marging, don't take the position, and put a
message on the message box on the trading platform.
Benzer siparişler
Hello, I am looking for a professional trading system including: 1- Trading Bot (Expert Advisor): - Good profit performance - High security and strong risk management - Works efficiently during high market volatility (news and strong movements) - Works on all pairs (Forex + Gold) 2- Signal Indicator: - Provides clear Buy and Sell signals - Includes Take Profit and Stop Loss - No repaint (signals must not change or
Hi, I’m looking for a top-tier, profit-optimized EA that has the potential to scale trading returns significantly. My goal is to maximize growth over time. Can you help develop a bespoke EA that could potentially scale to high six or seven figures
max amount grid step for magic number do keep deleting .only when it is in negative floating .but when it is profit allow to go over the max and replays to grid step
Apply with a screen of your work . Symbol Specific Logic . Live Chart Optimization Check the Core logic . [back tests as well] Change points to pips . Create buffer for the zone
I will pay 3000+ USD (negotiable) for an EA for existing MT5 that generates a minimum of 15-20% or higher a month consistently (provide source code after final deal) Looking for a highly profitable EA Please send demo version directly subject (Buying profitable EA Budget up to $ 3000 USD), past results and optimal settings so I can test, if it performs in a strategy tester i will also need option to forward test it
Hello, I need an already developed EA similar to the one trading XAUUSD, with consistent entries and good risk management. Before we proceed, I would like to verify its performance. Please provide a live or demo account login along with the investor (read-only) password so I can monitor the trading results. I am looking for stable performance, controlled drawdown, and consistent profit on gold (XAUUSD). Once I
The strategy records the highest and lowest prices within a specified duration (default 15 minutes) after the New York market opens, forming the opening range. Post-Formation Breakout: When the price breaks above or below the opening range after its formation, it may indicate the direction of the day’s price movement. Trend Confirmation: The strategy uses two EMAs (default 20-period and 50-period) as trend filters to
Tengo una estrategia basada en divergencia para el oro sobre todo en tf m1 Basado en divergencia con stoch .. confirmando la entrada con ciertos parameteos de entrada Es mejor conversarlo para dar mejor los detalles Cuando entrar, porque o todas las divergencias se debe tomar para entrar en compras o ventas He adjuntado un ejemplo La confrmacion más exacta es el cruce de esos parámetros de stoch edebajo de level de
BUY ALERT 1. Supertrend turns Bullish 2. On this candle , or during the last time Supertrend was Bearish, price was < or = MA1 3. On this candle , or during the last time Supertrend was Bearish , BBStops is Bearish 4. STEP MA1 and STEP MA 2 are both Bullish SELL ALERT 1. Supertrend turns Bearish 2. On this candle , or during the last time Supertrend was Bullish, price was