Convert TradingView Pine Script Multi Time Frame Heiken Ashi Stategy To MQL5

MQL5 Converting

Specification

I am looking for an experienced MQL5 developer to convert a multi-timeframe Heiken Ashi trading strategy, currently written in Pine Script, into MQL5 for use in MetaTrader 5. The strategy involves multiple conditions across different timeframes and includes entry/exit signals, position tracking, and stop loss management.

I will be using this primarily for 15 minute charts on multiple different pairs. Also, as you are working on the conversion, if you see something that will cause the strategy to not preform as intended, you would fix it so it is performing correctly. I'm happy to have a quick video call to walk through the strategy as needed to make sure everything is working properly.

Details of the Pine Script Strategy:

  1. Strategy Overview: The strategy utilizes Heiken Ashi candles across seven different timeframes (15m, 30m, 1h, 2h, 4h, 12h, and 1D) to determine the market trend and make trade decisions. A long position is taken when all Heiken Ashi bars are green, and a short position is taken when all are red.

  2. Position Management: The script includes logic to avoid re-entries while in a position and switches between long and short positions based on the trend change. For example, when all of the Candle Timeframes turn green, it will close out of a short position and take a long position that is roughly 2% of the overall account size. It will then close out that position and take a short position when they all turn red. These orders will take place on the opening of the next candle after changing trend direction to make sure it doesn't get affected by repainted candles during that time frame.

  3. Stop Loss: The strategy employs a stop loss mechanism set at 50% of the entry price for long positions and 150% for short positions.

  4. Trade Visualization: The Pine Script plots shapes on the chart to indicate entry and exit points, which is a feature I would like to retain in the MQL5 conversion but isn't a strict requirement.

  5. Alert System: The current script uses custom alert messages for trade entries and exits. The converted MQL5 code should include similar alert functionality that can be linked to MetaTrader's native alert system.

Specific Requirements:

  1. Multi-Timeframe Analysis: The MQL5 script must accurately perform Heiken Ashi calculations across the specified timeframes and use these for trend determination (I believe there are already indicators that have been programmed that can be used just like TradingView).

  2. Trade Execution: The script should execute buy and sell orders according to the strategy logic, with appropriate checks to prevent duplicate entries.

  3. Stop Loss Management: The converted script should include a stop loss mechanism that triggers an exit at 50% below the entry price for long positions and 50% above the entry price for short positions.

  1. Graphical Elements: Plot arrows or other graphical objects on the chart to visualize entry and exit points.

  2. Notifications: Implement notifications within the MQL5 script that correspond to the strategy's trading actions. These should be configurable to send alerts within MT5

  3. The script must be fully functional and tested in MetaTrader 5 for both backtesting and live trading.

  4. The final product must adhere to best coding practices and performance optimization standards of MQL5.

Deliverables:

  1. A fully functional MQL5 script that replicates the provided Pine Script strategy.
  2. Documentation/commentary within the code explaining the function of each segment.

Optional:

  1. A brief user manual explaining how to apply the strategy in MetaTrader 5, including any necessary setup steps or parameters that need to be configured by the user.
  2. A test report showing the strategy being run in the MetaTrader 5 Strategy Tester, including any relevant performance metrics.
  3. A short video demonstration of the strategy being applied and running in a live environment.

Here is the Pine Script code for reference:

//@version=4
strategy("Multi Time Frame Heiken Ashi Strategy", overlay=true)

// Function to check if Heiken Ashi bar is green on a given timeframe
isGreen(tf) =>
ha = heikinashi(syminfo.tickerid)
[haOpen, haClose] = security(ha, tf, [open, close], lookahead=barmerge.lookahead_on)
haClose > haOpen

// Function to check if Heiken Ashi bar is red on a given timeframe
isRed(tf) =>
ha = heikinashi(syminfo.tickerid)
[haOpen, haClose] = security(ha, tf, [open, close], lookahead=barmerge.lookahead_on)
haClose < haOpen

// Count the number of green Heiken Ashi bars across all timeframes
greenCount() =>
count = 0
count := count + (isGreen("15") ? 1 : 0)
count := count + (isGreen("30") ? 1 : 0)
count := count + (isGreen("60") ? 1 : 0)
count := count + (isGreen("120") ? 1 : 0)
count := count + (isGreen("240") ? 1 : 0)
count := count + (isGreen("720") ? 1 : 0)
count := count + (isGreen("D") ? 1 : 0)
count

// Generate buy and sell conditions for long and short positions
longCondition = greenCount() == 7
shortCondition = greenCount() == 0

// Initialize variables to track positions
var longPosition = false
var shortPosition = false

// Initialize variables for stop loss prices
var float longStopPrice = na
var float shortStopPrice = na

// Plot buy and sell signals for visualization
plotshape(series=longCondition and not longPosition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=shortCondition and not shortPosition, title="Short Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
plotshape(series=longCondition and shortPosition, title="Cover Short Signal", location=location.belowbar, color=color.blue, style=shape.xcross, size=size.small)

// Creating Alerts
longstring = "Input your custom alert message here. \n and put {{strategy.order.alert_message}} in Message box."
shortstring = "Input your custom alert message here. \n and put {{strategy.order.alert_message}} in Message box."

long=input(title="Long Alert Message", defval="Long", confirm=false, group="Alert Messages", tooltip=longstring)
short=input(title="Short Alert Message", defval="short", confirm=false, group="Alert Messages", tooltip=shortstring)

if (longCondition and not longPosition)
alert(long)

if (shortCondition and not shortPosition)
alert(short)

// Executing strategy for long and short positions
if (longCondition and not longPosition)
strategy.entry("Long", strategy.long)
longStopPrice := close * 0.50
longPosition := true
shortPosition := false

if (shortCondition and not shortPosition)
strategy.entry("Short", strategy.short)
shortStopPrice := close * 1.50
shortPosition := true
longPosition := false

if (longCondition and shortPosition)
strategy.close("Short")
shortPosition := false

// Managing the stop loss for long and short positions
if (longPosition)
strategy.exit("Long Stop Loss", "Long", stop=longStopPrice)

if (shortPosition)
strategy.exit("Short Stop Loss", "Short", stop=shortStopPrice)





































































































































































































Responded

1
Developer 1
Rating
(4)
Projects
4
0%
Arbitration
2
0% / 100%
Overdue
1
25%
Free
2
Developer 2
Rating
(43)
Projects
90
13%
Arbitration
34
26% / 56%
Overdue
37
41%
Working
3
Developer 3
Rating
(284)
Projects
458
39%
Arbitration
94
44% / 18%
Overdue
72
16%
Loaded
Published: 2 codes
Similar orders
Hello, I am looking for a programmer who can convert from pine script to mql5. You will receive 11 different trading view indicators to convert to Mql5. You may find them simple and straightforward or not. I repeat this could turn out to be very painstaking and strenuous if you are not well versed in pine script to Mql5 conversion. However, you will add unified alert system to simplify things on mql5 and to alert
I have attached trading view indicator, I want to convert it into mq4 version, attached indicator is for single current time frame, but converted indicator must work on multi time frame like 1 min, 5 min, 15 min, 30 min etc. Trading view indicator does not repaint hence Converted mt4 indicator mtf version should not repaint Please only experience coders reply, I have already mt4 mtf file of this indicator but it is
I’m looking for an experienced MetaTrader 5 (MT5) programmer to code a custom indicator based on my trading strategy. The strategy involves specific entry and exit conditions, and I need a clean, efficient, and reliable MT5 indicator that can reflect those conditions accurately on the chart
tengo un asesor esperto que fue crepado para ser usado en mt5 pero ahora lo quiero utilizar en la pltaforma CQG necesito alguien que bien lo modifique o lo hga desde el comienzo
I'm looking for a highly skilled and professional MQL4/MQL5 developer to perform the project below 1.Convert one MT4 EA to MT5 *I will provide the MQL4 source code *The EA trading is martingale EA *Need to work exactly like MT4 *Will perform test run for 1month after done conversion *Payment will be make after test run
Hello, I am looking for a programmer who can convert from pine script to mql5. You will receive 11 different trading view indicators to convert to Mql5. They are simple and straightforward. You will use a unified alert system in the conversion, to alert whenever there is a buy or sell instance on the main chart for each indicator. Only 1 of the indicators will require some extra command which I will give to you later
Need an Indicator to be converted from MT4 to MT5 and make an EA to open trades based on the signals from the indicator. EA Settings Lot Size : Trail On : True / False Trail Start : Trail Step : Close on opposite : True / False Close Profit : ( Points to calculate profit ) Close all if profit reached inclusive of swap commission all charges Net ( No: of Lots x Close profit value ) as desired profit. Requirements

Project information

Budget
30 - 100 USD
For the developer
27 - 90 USD