Task: Create a Spread Trading Bot Using Two Correlated Pairs (e.g., EURJPY and USDJPY)
I would like to request help with building a bot that trades the spread between two correlated forex pairs, such as EURJPY and USDJPY.
Requirements:
Constants:
Symbol_1: First symbol (e.g., EURJPY).
Symbol_2: Second symbol (e.g., USDJPY).
LotSize: The lot size for trades.
MovingAveragePeriod: Period for the moving average (e.g., 100).
Variables:
Spread: The spread between Symbol_1 and Symbol_2, calculated as Symbol_1 price - Symbol_2 price.
AvgSpread: The moving average of the spread over the last MovingAveragePeriod (e.g., 100 closing prices).
Entry Conditions:
Buy Symbol_1 / Sell Symbol_2: When the spread (Symbol_1 price - Symbol_2 price) is greater than the average spread (AvgSpread) over the last 100 periods.
Close Existing Positions and Reverse: If the spread between Symbol_1 and Symbol_2 drops below the average spread (AvgSpread), close the existing positions and Sell Symbol_1 / Buy Symbol_2.
Example:
If EURJPY - USDJPY (spread) is greater than the moving average of the spread over the last 100 periods, the bot should:
Buy EURJPY and Sell USDJPY.
If the spread falls below the moving average, the bot should:
Close the current positions and Sell EURJPY and Buy USDJPY.
Customizable Inputs:
Ability to change Symbol_1, Symbol_2, Lot Size, and Moving Average Period in the constants section.
Would anyone be able to help me with setting this up in FXDreema or MetaTrader 5?
Thanks in advance!