USD/JPY Automated Trading Strategy

İş Gereklilikleri

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)



Yanıtlandı

1
Geliştirici 1
Derecelendirme
(20)
Projeler
19
11%
Arabuluculuk
2
50% / 50%
Süresi dolmuş
0
Çalışıyor
2
Geliştirici 2
Derecelendirme
(55)
Projeler
64
6%
Arabuluculuk
24
21% / 38%
Süresi dolmuş
4
6%
Çalışıyor
3
Geliştirici 3
Derecelendirme
(1)
Projeler
3
0%
Arabuluculuk
0
Süresi dolmuş
0
Çalışıyor
4
Geliştirici 4
Derecelendirme
(199)
Projeler
203
28%
Arabuluculuk
0
Süresi dolmuş
3
1%
Serbest
5
Geliştirici 5
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
6
Geliştirici 6
Derecelendirme
(195)
Projeler
316
15%
Arabuluculuk
20
40% / 35%
Süresi dolmuş
16
5%
Meşgul
7
Geliştirici 7
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Çalışıyor
8
Geliştirici 8
Derecelendirme
(60)
Projeler
183
72%
Arabuluculuk
4
100% / 0%
Süresi dolmuş
1
1%
Serbest
9
Geliştirici 9
Derecelendirme
(255)
Projeler
413
38%
Arabuluculuk
86
44% / 19%
Süresi dolmuş
70
17%
Meşgul
Benzer siparişler
i want a forex robot that will read chats and enter trades on its oown. i want it to be able to use all trading strategies and partterns. good risky manegmemt, i want it to forcuse on Gold and and all major forex pairs. i want it to use stop loses and take profits as the market might change direction anytime. i want to work on both mt5 and mt4
I need a developer to create a ea. This is based on candlestick pattern identification and execution. Developers who have experience in developing candle pattern identification ea are preferred. Details will be shared on request
I need you to check an expert advisor I bought and find the best settings, parameters to get low drawdown and high performance. configuration and optimization of sets to improve management
I want to make something automatic which EMA will automatically trade in my account. For this I want to make a simple robot I want to get this made automatically on a simple EMA
**Project Title:** Development of a Complex High-Performance EA for Step Index **Project Overview:** I need an advanced Expert Advisor (EA) for trading the Step Index on MetaTrader 5. The EA should use multiple indicators and advanced risk management techniques to enhance profitability and manage risks effectively. **Trading Strategy Details:** Indicators: - 50-period EMA - 200-period EMA - RSI with 14 periods - MACD
Below follows specifications and the pictures of how the indicator should be. I believe that during the development it is necessary some adjustments that I may have forgotten while writing the descriptions, please take this into account. If necessary I have the pdf file that may be easier to understand. Doubts I am at your disposal
Saya memerlukan Expert Advisor berdasarkan sinyal AOX. Itu harus memiliki pemeriksaan dan penanganan kesalahan operasi perdagangan. Kriteria utama pembukaan dan posisi penutupan: ■ arah rata-rata bergerak ■ harga lebih tinggi dari bar sebelumnya. Lot perdagangan adalah parameter masukan
I would like to develop a EA that is based on: Structure & Fractal Liquidity POI & Order Flow Trading Range & Range Type Quasimodo concept Information about the trading style will be provided in pdf (zip). EA setting are also provided in pdf (zip). Futher questions will be clarified to ensure progress in the project
Develop a custom Expert Advisor (EA) for MetaTrader 4 (MT4) that operates using two selectable time frames. The EA will be fully customizable, allowing you to choose any time frame and input specific parameters. This tailored solution aims to automate trading strategies, enhance trading efficiency, and provide robust performance across various market conditions
Hello I'm trying to fix a indicator that I have, It's a .ex4 file, Can I just code a new indicator because I only have a failed version of it in a ex4 file. Here are the three files. They are EX4 files. So i wanted to have a trade panel that can fill up the whole screen where it shows all the pair symbols. MTF_TMA_Harmonic ex4 file is exactly what I'm looking for however the ex4 file for some reason doesn't work

Proje bilgisi

Bütçe
30 - 100 USD

Müşteri

Verilmiş siparişler2
Arabuluculuk sayısı0