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
(42)
Projects
88
14%
Arbitration
30
30% / 53%
Overdue
36
41%
Working
3
Developer 3
Rating
(256)
Projects
415
38%
Arbitration
86
44% / 19%
Overdue
70
17%
Busy
Similar orders
Hi everyone I have a question, is there anyone who can rewrite the code from tradinvivew pineditor to mql5 meta trader? It is about 150 line. My strategy has 50% success rate with RR 2,6. Tested for last one year, strategy works only in bull market. This is trading on gold, unfortunately I am not in the best financial position, in return I would send you the code, if you don't like it I understand that you will stop
Hello I have an indicator here which is based on the crosses...if two lines crossing for buy it must change all candles on the main chart to be green, If two lines crossing for sell it must change all candles to red...Main Chart candles to change color(s) must be controlled by the cross indicator
I need help on my project. Retrieve US30 asset price data from Ctrader Convert it to YM futures data Display the converted data on TradingView The reason why I need to convert US30 cfd prices from Ctrader into YM future prices is because all of my trading signals are from ctrader, and i need to trade on tradingview. Thanks
CTRADER 30+ USD
can you help me with this project? Retrieve US30 asset price data from Ctrader Convert it to YM futures data Display the converted data on TradingView The reason why I need to convert US30 cfd prices from Ctrader into YM future prices is because all of my trading signals are from ctrader, and i need to trade on tradingview. Thanks
I need help with a small project. Basically I need to convert us30 asset price on Ctrader platform into YM futures on tradingview. Can you do it? It should be quite straight forward this is an example of what my trade signals look like
Skarito98 30 - 100 USD
Always stay winning and survive....we all want a better life now this is a chance someone can take,to change their lives for the better.No one is supposed to suffer in this world,we create and invert new things and come up with ideas to solve situations we come across especially when it comes to finance. We all need better things in life and God want good things for us
hello i need a professional to convert a fully functioning buy and sell signal strategy on tradingview to EA mt4 , the signals trigger when the bar closed match all conditions , it has a specific calculation for strength of each pair
Attached is a ThinkScript Strategy. I would like to convert it into an Expert Advisor for MQL4. Here is a link of a PineScript code for a similar indicator. This is just to give you additional info about the indicator, hence helping you to convert it from Thinkscript to MQL4
Only with feedbacks 30 - 100 USD
PINESCRIPT->MQL4 i need a exactly conversion of the file attached to mql4 with source code (i need the source code), obviously as indicator for mt4 let me know your bid and timeline
C onversion from Ninjatrader to Tradingview. This includes thorough testing and debugging to guarantee that the script functions as intended on Tradingview...If you are in for this job kindly bid

Project information

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