USD/JPY Automated Trading Strategy

명시

Essa estratégia de trading automatizada foi desenvolvida para operar no par USD/JPY, utilizando médias móveis, RSI, e uma gestão de risco avançada com stop loss, take profit, trailing stop, e um sistema de análise de run-ups lucrativos. Vou explicar cada parte em detalhes:

### 1. **Identificação de Tendência:**
   - **Média Móvel Simples (SMA 200):** 
     - A estratégia usa uma média móvel simples de 200 períodos (`sma200`) para determinar a tendência do mercado.
     - **Tendência de alta:** O preço atual (`close`) está acima da SMA 200.
     - **Tendência de baixa:** O preço atual está abaixo da SMA 200.

### 2. **Sinal de Compra e Venda (RSI):**
   - **Índice de Força Relativa (RSI 14):**
     - A estratégia utiliza o RSI de 14 períodos para identificar condições de sobrecompra e sobrevenda.
     - **Compra:** O RSI precisa ter cruzado para cima o nível 70 e, em seguida, caído para 50. Quando ele cruza novamente para cima de 50 em uma tendência de alta, é gerado um sinal de compra.
     - **Venda:** O RSI precisa ter cruzado para baixo o nível 30 e, em seguida, subido para 50. Quando ele cruza novamente para baixo de 50 em uma tendência de baixa, é gerado um sinal de venda.

### 3. **Execução de Ordens:**
   - **Entrada na Operação:**
     - Quando um sinal de compra ou venda é gerado, a estratégia entra automaticamente em uma posição longa (compra) ou curta (venda).
   - **Stop Loss e Take Profit:**
     - O stop loss e o take profit são definidos com base em uma quantidade de pips configurável pelo usuário. Por exemplo, o take profit pode ser definido em 300 pips e o stop loss em 100 pips.
   - **Trailing Stop:**
     - O trailing stop também é configurável e segue a operação, movendo o stop loss conforme o preço se move a favor da posição, protegendo os lucros à medida que a operação avança.

### 4. **Gestão de Run-Ups Positivos:**
   - **Run-Up:** 
     - Refere-se ao ganho máximo que uma operação atinge antes de recuar.
   - **Média dos Últimos Run-Ups Positivos:** 
     - A estratégia calcula a média dos últimos run-ups positivos (aqueles que resultaram em lucro). Essa média é usada como uma referência adicional para fechar as operações.
   - **Fechamento Baseado na Média dos Run-Ups:**
     - Se o preço se mover a favor da posição até a média dos run-ups positivos e, em seguida, recuar, a estratégia fechará a posição para proteger os ganhos.

### 5. **Personalização:**
   - **Parâmetros Ajustáveis:**
     - O usuário pode ajustar os valores de take profit, stop loss, trailing stop, e o número de run-ups analisados.
   - **Flexibilidade:** 
     - A estratégia permite ajustes que podem adaptar-se a diferentes condições de mercado e estilos de trading.

### 6. **Plotagem:**
   - **Indicadores no Gráfico:**
     - A SMA 200 e os níveis do RSI (30, 50, 70) são plotados no gráfico para visualização das condições de mercado e sinais gerados.

### Resumo:

Essa estratégia combina análise técnica com uma gestão de risco sofisticada para operar de forma automatizada no par USD/JPY. Utiliza a tendência do mercado para filtrar operações, o RSI para gerar sinais de entrada, e mecanismos de stop loss, take profit e trailing stop para proteger os lucros. A análise dos run-ups positivos permite que as operações sejam fechadas de forma eficiente, garantindo que os ganhos sejam capturados antes de qualquer reversão significativa.


CODIGO EM PINE SCRIPT:

Quero ele na versão do MQL5/MT5

//@version=5

strategy("USD/JPY Automated Trading Strategy", overlay=true)


// Inputs configuráveis

takeProfitPips = input.float(300.0, title="Take Profit (pips)")

stopLossPips = input.float(100.0, title="Stop Loss (pips)")

trailingStopPips = input.float(100.0, title="Trailing Stop (pips)")

runUpLength = input.int(10, title="Quantidade de Run-Ups Analisados")


// Converter pips para o valor apropriado para o par USD/JPY (1 pip = 0.01)

takeProfit = takeProfitPips * 0.01

stopLoss = stopLossPips * 0.01

trailingStop = trailingStopPips * 0.01


// Configuração das médias móveis e RSI

sma200 = ta.sma(close, 200)

rsi = ta.rsi(close, 14)


// Variáveis de tendência

isUptrend = close > sma200

isDowntrend = close < sma200


// Variáveis de compra e venda

var buySignal = false

var sellSignal = false


// Extração da chamada `ta.valuewhen` para fora do bloco condicional

rsi70crossed = ta.valuewhen(rsi > 70, rsi, 0)

rsi30crossed = ta.valuewhen(rsi < 30, rsi, 0)


// Verifica se o RSI atinge 70 e depois volta para 50 para compra

if (isUptrend and ta.crossover(rsi, 50))

    if (rsi70crossed > 70)

        buySignal := true


// Verifica se o RSI atinge 30 e depois volta para 50 para venda

if (isDowntrend and ta.crossunder(rsi, 50))

    if (rsi30crossed < 30)

        sellSignal := true


// Arrays para armazenar os run-ups positivos

var float[] runUps = array.new_float(0)


// Função para calcular o run-up atual

calcRunUp(entryPrice) =>

    var float runUp = na

    if (strategy.opentrades > 0)

        runUp := high - entryPrice

    runUp


// Função para calcular a média dos últimos N run-ups

calcAverageRunUp(length) =>

    var float sumRunUp = 0.0

    count = math.min(length, array.size(runUps))

    if (count > 0)  // Verifica se o array tem elementos antes de calcular

        for i = 0 to count - 1

            sumRunUp := sumRunUp + array.get(runUps, i)

        sumRunUp / count


// Atualiza o array de run-ups apenas se o run-up for positivo (lucrativo)

if (strategy.closedtrades > 0)

    lastTrade = strategy.closedtrades.entry_price(strategy.closedtrades - 1)

    lastRunUp = calcRunUp(lastTrade)

    if (lastRunUp > 0)

        array.unshift(runUps, lastRunUp)

        if (array.size(runUps) > runUpLength)

            array.pop(runUps)


// Ações de compra

if (buySignal)

    strategy.entry("Buy", strategy.long)

    // Stop Loss e Take Profit

    strategy.exit("Take Profit/Stop Loss", "Buy", limit=close + takeProfit, stop=close - stopLoss)

    // Trailing Stop

    strategy.exit("Trailing Stop", "Buy", trail_offset=trailingStop, trail_points=trailingStop)

    buySignal := false

    if (rsi <= 30)

        strategy.entry("Add Buy", strategy.long)

        // Stop Loss e Take Profit para a segunda entrada

        strategy.exit("Add Take Profit/Stop Loss", "Add Buy", limit=close + takeProfit, stop=close - stopLoss)

        // Trailing Stop para a segunda entrada

        strategy.exit("Add Trailing Stop", "Add Buy", trail_offset=trailingStop, trail_points=trailingStop)


// Ações de venda

if (sellSignal)

    strategy.entry("Sell", strategy.short)

    // Stop Loss e Take Profit

    strategy.exit("Take Profit/Stop Loss", "Sell", limit=close - takeProfit, stop=close + stopLoss)

    // Trailing Stop

    strategy.exit("Trailing Stop", "Sell", trail_offset=trailingStop, trail_points=trailingStop)

    sellSignal := false

    if (rsi >= 70)

        strategy.entry("Add Sell", strategy.short)

        // Stop Loss e Take Profit para a segunda entrada

        strategy.exit("Add Take Profit/Stop Loss", "Add Sell", limit=close - takeProfit, stop=close + stopLoss)

        // Trailing Stop para a segunda entrada

        strategy.exit("Add Trailing Stop", "Add Sell", trail_offset=trailingStop, trail_points=trailingStop)


// Fechar posições baseadas na média dos últimos N run-ups positivos

averageRunUp = calcAverageRunUp(runUpLength)

if averageRunUp and close >= strategy.position_avg_price + averageRunUp

    strategy.close("Buy")

if averageRunUp and close <= strategy.position_avg_price - averageRunUp

    strategy.close("Sell")


// Plotar indicadores no gráfico

plot(sma200, color=color.blue, title="SMA 200")

hline(50, "RSI 50", color=color.gray)

hline(70, "RSI 70", color=color.red)

hline(30, "RSI 30", color=color.green)

plot(rsi, title="RSI", color=color.purple)



응답함

1
개발자 1
등급
(21)
프로젝트
20
10%
중재
2
50% / 50%
기한 초과
0
작업중
2
개발자 2
등급
(59)
프로젝트
67
6%
중재
28
18% / 36%
기한 초과
5
7%
바쁜
3
개발자 3
등급
(2)
프로젝트
5
0%
중재
1
0% / 0%
기한 초과
1
20%
작업중
4
개발자 4
등급
(204)
프로젝트
209
28%
중재
0
기한 초과
3
1%
무료
5
개발자 5
등급
(9)
프로젝트
15
7%
중재
0
기한 초과
2
13%
작업중
6
개발자 6
등급
(222)
프로젝트
355
17%
중재
21
43% / 33%
기한 초과
18
5%
바쁜
7
개발자 7
등급
(9)
프로젝트
12
17%
중재
1
0% / 100%
기한 초과
0
작업중
8
개발자 8
등급
(63)
프로젝트
197
73%
중재
4
100% / 0%
기한 초과
1
1%
작업중
9
개발자 9
등급
(261)
프로젝트
426
38%
중재
86
44% / 19%
기한 초과
71
17%
로드됨
10
개발자 10
등급
(42)
프로젝트
88
14%
중재
31
29% / 55%
기한 초과
36
41%
작업중
11
개발자 11
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
12
개발자 12
등급
(13)
프로젝트
13
100%
중재
0
기한 초과
0
무료
비슷한 주문
Looking for someone to edit/optimize and existing NN (neural network) in my EA so it is more compatible/profitable with the multiple strategies. The expert advisor is a portfolio expert advisor consisting of 33 separate advisors/strategies compiled into one. A NN has been added to the EA but it does not compliment or help the EA's performance. I've attached the original EA (without NN) as well as the EA with the NN
am looking for great developer that can help me on this project, I have an Indicator on Tradingview and want to convert that to an EA for Metatrader 4. Can you help me? peace be unto you
Good programmer need to use 1 indicator convert to expert advisor. kennel Kennel indicator-- upper channel signal = Sell Kennel indicator-- Lower channel signal = Buy Entry on New candle or Bar after close of Signal candle lot size-- Take profit--- Stoploss--- Trail start--- Trail step--- Max spread = 200 Hedge of signal = true/false multiplier = percentage Risk = percentage. magic-- CHECK OUT THE LINK
CORREÇÃO NOTIFICAÇÕES Ø O indicador muda a cor dos candles e da MA200 quando ocorre as entradas e é somente nesse momento que ele deve enviar notificação de entrada porem está enviando em outros momentos que não atende as condições conforme imagem abaixo. Ø Sempre que abro o MT5, mudo o time frame ou a plataforma perde conexão o indicador me envia notificações de entradas passadas, o indicador deve enviar
Hello, I'm seeking for an experienced developer that can convert a simple MQL4 EA (which is about 1000 lines of code, but with simple logic) to MQL5. Furthermore I need him to optimize the EA for better performance and faster backtest speed (all optional backtest features to speed up the process must be enabled optionally with input parameters, like Enter/Exit on new bar only for example). Finaly, I want to add an
Seb’s EA 2024/25 200 - 500 USD
Primary Agreement Description Details: This EA Strategy is to run on MT4. It has parameters for 2 MA's and 3 momentum indicators along with 22 "variable / constant rules & settings" on 1 time-frame (5 Min). There are 3 versions required to cater for 3 different Instruments (3 US Indexes). The only differences will be the position sizes, Stop levels & Macd bands. There are 3 entry conditions with 3 exit conditions
I need help with this, Hi i want a bot that will send orders to efood delivery app If you have experience about message to get started immediately pls i need it urgent
Fellow devs, I need help converting a futures trading bot from python into MQL5. Code base for the bot already exists, backtests in python look good, however I need to be able to backtest it on tick data with MT5. Would appreciate someone who has experience with futures bots specifically, and even better if you have experience with AMP brokers, and can provide guidance and improvement criteria. A point you note, I
I am a professional advisor managing and trading stocks in a portfolio of about Euro 10 million for a private investor. I want to establish Algo/FX trading on MetaTrader 5 (MT5) and seek a skilled and experienced trader to professionally manage and optimize these MT5 accounts. I am currently using “QUANTUM EMPEROR” and “Gallileo FX”, and initially seek help to make these systems profitable. On top of a paid job. How
This project involves converting the a TradingView Pine Script strategy, into a fully functional MT4 Expert Advisor (EA) using MQL5. The strategy includes multiple technical indicators, entry/exit conditions, stop loss (SL), take profit (TP), and custom entry price offsets. The EA should be designed for backtesting and live trading in MT4

프로젝트 정보

예산
30 - 100 USD
개발자에게
27 - 90 USD