USD/JPY Automated Trading Strategy

Spezifikation

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)



Bewerbungen

1
Entwickler 1
Bewertung
(21)
Projekte
20
10%
Schlichtung
2
50% / 50%
Frist nicht eingehalten
0
Frei
2
Entwickler 2
Bewertung
(58)
Projekte
66
6%
Schlichtung
28
18% / 36%
Frist nicht eingehalten
4
6%
Überlastet
3
Entwickler 3
Bewertung
(1)
Projekte
4
0%
Schlichtung
1
0% / 0%
Frist nicht eingehalten
1
25%
Arbeitet
4
Entwickler 4
Bewertung
(203)
Projekte
207
28%
Schlichtung
0
Frist nicht eingehalten
3
1%
Frei
5
Entwickler 5
Bewertung
(6)
Projekte
10
0%
Schlichtung
0
Frist nicht eingehalten
1
10%
Überlastet
6
Entwickler 6
Bewertung
(206)
Projekte
334
16%
Schlichtung
23
39% / 30%
Frist nicht eingehalten
17
5%
Überlastet
7
Entwickler 7
Bewertung
(3)
Projekte
5
0%
Schlichtung
1
0% / 100%
Frist nicht eingehalten
0
Frei
8
Entwickler 8
Bewertung
(62)
Projekte
192
73%
Schlichtung
4
100% / 0%
Frist nicht eingehalten
1
1%
Frei
9
Entwickler 9
Bewertung
(259)
Projekte
421
38%
Schlichtung
86
44% / 19%
Frist nicht eingehalten
70
17%
Überlastet
10
Entwickler 10
Bewertung
(42)
Projekte
88
14%
Schlichtung
30
30% / 57%
Frist nicht eingehalten
36
41%
Arbeitet
11
Entwickler 11
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
12
Entwickler 12
Bewertung
(13)
Projekte
13
100%
Schlichtung
0
Frist nicht eingehalten
0
Frei
Ähnliche Aufträge
Hi, Shall I get a auto ea forex trading bot for one percent profit per day? If so, I will pay once ea confirms one percent to me with multi currency and multi timeframe. You can use any method, idea, indicators rules and your wish. But, I need the one percent profit
Automate my trading 30 - 100 USD
Hi, I need a mql5 EA sellstop buystop for one minute time frame in all currency pair. That ea would be autotrade and close once profitable. I will pay once confirms the ea profit in each trade
I would to develop a trading bot with some confluences I use TradeLocker Settings must be adjustable…… the list of indicators are on TradingView, 1. Market Structure Break And Order block. By EmreKb 2. TMA - Divergence Indicator (V2) 3. Multiple MA (21,50,100) 4. SuperTrend
QuantumTrader 30 - 200 USD
Request for development of machine learning robots for MetaTrader 5 (MT5) **Description**: Willing to develop experience in programming trading robots using MQL5 language and can learn machine learning on MetaTrader 5 (MT5) platform. The robot should be able to implement a multidisciplinary strategy on a set of technical indicators and multiple rules. I need to develop the robots so that they can work in an
The goal is to develop a system that mirrors trade actions (Buy/Sell) from a CTrader demo account on Cronos Markets to multiple prop firm accounts on TradeLocker, ensuring accurate replication of trades while adjusting risk proportionally. I was wondering if you could help me with copy trading an EA’s action on Cronos markets (uses CTrader) into a prop firm account that I bought with TooOne Trader (uses TradeLocker
Hello, i have this EA (Blessing) attached and whenever i enter Multiplier: 1.5 Starting Lot: 1 on the config it opens a position of 1 Lot, next 2 lot, next 3 lot, next 5 lot but i need to have it open: 1 lot, 1,5 lot, 2.25 lot, 3.38 lot and so on. You need to modify the EA so it opens the correct values. Please test it with the set i have attached and let me know if you can do it. The ffcal is an indicator and need
Hey Greeting Am in need of Tradingview Developer that can combine existing Tradingview indicator to develop a strategy based on my conditions The Source code of those Indicator is available with me. Kindly bid and let proceed with the project Thanks
I am not a professional developer and I am trying to make an EA based on published examples, my personal additions, my limited general programming knowledge (html, php, databases, but not MQL5) and the help of the AI Assistant built into the MQL5 Meta Editor. I have made several small EAs and none of them work, although the code has no errors apparently and the examples I based them on all work. I have tested it in
Dear developer, I want a working code to close open and pending orders on IG.com through python. when applying send me a sample video of the code closing orders on IG.com should be delivered within 2 days (please let me know) Serious coders please
I would like to create an Expert Advisor (for MT5) for personal use to manage positions. The utilities will be inspired by the tool below: https://www.mql5.com/en/market/product/23415?source=Site+Market+MT5+Utility+Rating006#description I think the number of options will be smaller, but I am very interested in the following functionality: 1. The ability to read the last highest price (pick) for short positions –

Projektdetails

Budget
30 - 100 USD
Für die Entwickler
27 - 90 USD