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
等级
(58)
项目
66
6%
仲裁
28
18% / 36%
逾期
4
6%
繁忙
3
开发者 3
等级
(1)
项目
4
0%
仲裁
1
0% / 0%
逾期
1
25%
工作中
4
开发者 4
等级
(203)
项目
207
28%
仲裁
0
逾期
3
1%
空闲
5
开发者 5
等级
(6)
项目
10
0%
仲裁
0
逾期
1
10%
繁忙
6
开发者 6
等级
(206)
项目
334
16%
仲裁
23
39% / 30%
逾期
17
5%
繁忙
7
开发者 7
等级
(3)
项目
5
0%
仲裁
1
0% / 100%
逾期
0
空闲
8
开发者 8
等级
(62)
项目
192
73%
仲裁
4
100% / 0%
逾期
1
1%
空闲
9
开发者 9
等级
(259)
项目
421
38%
仲裁
86
44% / 19%
逾期
70
17%
繁忙
10
开发者 10
等级
(42)
项目
88
14%
仲裁
30
30% / 57%
逾期
36
41%
工作中
11
开发者 11
等级
项目
0
0%
仲裁
0
逾期
0
空闲
12
开发者 12
等级
(13)
项目
13
100%
仲裁
0
逾期
0
空闲
相似订单
Trading tool buttons 100 - 300 USD
The trading tool's (2X) button names are the 'TSS Buy/TSS Sell,' which will be positioned on the chart with all the MT5 attributes, i.e., Show quick trading buttons, Show trade levels, and Show trade history... Here are the requirements: a. A click on the TSS Buy button followed by a click on the price bar triggers: BUY b. A click on the TSS Sell button followed by a click on the price bar triggers: SELL TSS Buy/TSS
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
Hi I need MT5 Indicator with these features (all in one); details will be sent later. Short Explanation for all features : 1. Gap notification : show and alert when theres gap between two closed candlestick 2. Candle Body : show and alert specific candle body size 3. Candle Upper Wick : show and alert specific candle upper wick size 4. Candle Lower Wick : show and alert specific candle lower wick size 5. Consecutive
Dear coder, I need an MT5 expert advisor with parameters detailed as : https://drive.google.com/drive/folders/18LBhYTb8bYz3pM2Szyyq4-RoTmBtaWIw?usp=sharing 1)Need the EA code to be optimisation friendly and hence able to be optimise with the shortest time possible especially when using Fast Genetic : Complex criterion using open price or OHLC 2)Able to provide sourcecode 3)Able to resolve ongoing bug if any . 4)Able
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
Hi developers, would like an EA developed that I can use for backtesting and possibly as a Trading Robot if I have enough confidence in it. Here are the rules: EA is for forex, indicies, commodities etc. 5 minute timeframe (can add more timeframes depending on development cost) Price at 9pm is "noted" Then the price at the following 7am is "noted". Once a candle closes above/below the 7am price in the direction of
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

项目信息

预算
30 - 100 USD
开发人员
27 - 90 USD