I have a code in tradingview Pinescript and need it converting to mql4

MQL5 変換

仕事が完了した

実行時間225 日

指定

here is the script its small

//@version=5
strategy("US500 Trading Strategy", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=1000)

// Input parameters
sma14 = ta.sma(close, 14)
sma50 = ta.sma(close, 50)
sma100 = ta.sma(close, 100)

// Function to check if SMA100 is in a distinct trend
isDistinctTrend(len) =>
    uptrend = true
    downtrend = true
    for i = 0 to len - 1
        if sma100[i] <= sma100[i+1]
            uptrend := false
        if sma100[i] >= sma100[i+1]
            downtrend :=//@version=5
 false
    [uptrend, downtrend]

[distinctUptrend, distinctDowntrend] = isDistinctTrend(10)

// Fibonacci levels
high_12h = ta.highest(high, 720)
low_12h = ta.lowest(low, 720)
fib_range = high_12h - low_12h
upper_15_percent = high_12h - fib_range * 0.15
lower_15_percent = low_12h + fib_range * 0.15

// Check if price is within top or bottom 15% of Fibonacci range
inFibZone = close > upper_15_percent or close < lower_15_percent

// New high/low condition
newHigh = ta.highest(high, 60) == high
newLow = ta.lowest(low, 60) == low
retraceAfterHigh = newHigh and high - low < 4
retraceAfterLow = newLow and high - low < 4

// Flat range condition
flatRange = math.abs(sma100 - sma50) < 4 and math.abs(ta.change(sma100)) < 0.1 and math.abs(ta.change(sma50)) < 0.1

// Entry conditions
longCondition = ta.crossover(sma14, sma50) and distinctUptrend and not inFibZone and not retraceAfterHigh and not flatRange
shortCondition = ta.crossunder(sma14, sma50) and distinctDowntrend and not inFibZone and not retraceAfterLow and not flatRange

// Override condition
longOverride = flatRange and close > sma100 and close > sma14
shortOverride = flatRange and close < sma100 and close < sma14

// Calculate position size
position_size = math.round(strategy.equity * 0.01)

// PineConnector Inputs
PC_ID = input.string("7531755372757", title = "ID Pineconnector",  group="PineConnector")
inputsym = input.string("US500", title = "Ticker", group="PineConnector")
PC_RISK = input.float(1, "Risk Contracts/Equity", group="PineConnector")
PC_LIMIT = input.bool(true, "Use Market Order", group="PineConnector")
PC_LIMIT_PIPS = input.float(5, "Lots Limit Order Distance", group="PineConnector")

// Execute trades
if longCondition or longOverride
    strategy.entry("Long", strategy.long, qty=position_size, alert_message = str.tostring(PC_ID)+',buy,'+inputsym+ ',risk='+str.tostring(PC_RISK))

if shortCondition or shortOverride
    strategy.entry("Short", strategy.short, qty=position_size,alert_message = str.tostring(PC_ID)+',sell,'+inputsym+ ',risk='+str.tostring(PC_RISK))

// Stop loss and take profit management
strategy.exit("Long SL/TP", "Long", stop=strategy.position_avg_price * 0.9825, trail_points=100, trail_offset=35, alert_message =str.tostring(PC_ID)+',closelong,'+inputsym)
strategy.exit("Short SL/TP", "Short", stop=strategy.position_avg_price * 1.0175, trail_points=100, trail_offset=35, alert_message = str.tostring(PC_ID)+',closeshort,'+inputsym)

// Plot SMAs
plot(sma14, color=color.blue, title="SMA 14")
plot(sma50, color=color.red, title="SMA 50")
plot(sma100, color=color.green, title="SMA 100")


応答済み

1
開発者 1
評価
(102)
プロジェクト
105
60%
仲裁
0
期限切れ
0
2
開発者 2
評価
(20)
プロジェクト
32
9%
仲裁
0
期限切れ
0
3
開発者 3
評価
(77)
プロジェクト
240
73%
仲裁
7
100% / 0%
期限切れ
1
0%
4
開発者 4
評価
(183)
プロジェクト
314
24%
仲裁
23
35% / 13%
期限切れ
24
8%
パブリッシュした人: 3 codes
5
開発者 5
評価
(104)
プロジェクト
134
43%
仲裁
0
期限切れ
3
2%
仕事中
6
開発者 6
評価
(132)
プロジェクト
178
39%
仲裁
4
25% / 50%
期限切れ
14
8%
7
開発者 7
評価
(2)
プロジェクト
3
0%
仲裁
8
13% / 88%
期限切れ
1
33%
8
開発者 8
評価
(10)
プロジェクト
6
33%
仲裁
6
0% / 67%
期限切れ
1
17%
仕事中

プロジェクト情報

予算
40+ USD
締め切り
最高 1 日