Trading strategy

Termos de Referência

//@version=5  
strategy("Operator Psychology Trading Strategy with Heikin-Ashi (Auto Risk-Reward)", overlay=true, pyramiding=2, default_qty_type=strategy.fixed, default_qty_value=1)

// Check for the 3-minute timeframe
if (not (timeframe.isintraday and timeframe.period == "3"))
    runtime.error("This strategy can only be run on the 3-minute timeframe.")

// Parameters for ATR, Stop-Loss, Risk Percentage, and Sideways Market Threshold
atrLength = input.int(3, title="ATR Length")  // ATR length set to 3
riskMultiplier = input.float(3, title="Risk Multiplier for Stop-Loss")  // Updated Risk Multiplier to 3
capitalRiskPercent = input.float(2, title="Capital Risk Percentage per Trade", minval=0.1, maxval=100)  // Capital Risk set to 2%
sidewaysThreshold = input.float(1.6, title="Sideways ATR Threshold", minval=0.1)  // Updated Sideways ATR Threshold to 1.6

// Moving Average for Trend Detection
maLength = input.int(6, title="Moving Average Length")  // Updated Moving Average length to 6
ma = ta.sma(close, maLength)

// Heikin-Ashi Candle Calculation
haClose = (open + high + low + close) / 4
var haOpen = (open + close) / 2
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))

// Calculate ATR based on Heikin-Ashi candles
atrValue = ta.atr(atrLength)

// Define the previous and current Heikin-Ashi candle values
prevHaClose = haClose[1]
prevHaHigh = haHigh[1]
prevHaLow = haLow[1]
prevHaOpen = haOpen[1]
currHaClose = haClose
currHaHigh = haHigh
currHaLow = haLow
currHaOpen = haOpen

// Calculate buy and sell volumes using Heikin-Ashi candles
prevBuyVolume = prevHaClose > prevHaOpen ? volume : 0
currBuyVolume = currHaClose > currHaOpen ? volume : 0
prevSellVolume = prevHaClose < prevHaOpen ? volume : 0
currSellVolume = currHaClose < currHaOpen ? volume : 0

// Sideways Market Condition: Check if ATR is below threshold (low volatility)
sidewaysMarket = atrValue < sidewaysThreshold

// Define Buy Signal conditions based on operator psychology using Heikin-Ashi candles and trend confirmation
buyCondition1 = currHaClose > prevHaHigh              // Heikin-Ashi close breaks previous Heikin-Ashi high
buyCondition2 = currBuyVolume > prevBuyVolume         // Current buying volume exceeds previous
buyCondition3 = prevHaClose < currHaOpen              // Previous Heikin-Ashi candle closes lower than current open
buyCondition4 = haClose > ma                          // Close price is above moving average (trend confirmation)
buySignal = buyCondition1 and buyCondition2 and buyCondition3 and buyCondition4 and not sidewaysMarket  // Avoid sideways zones

// Define Sell Signal conditions based on operator psychology using Heikin-Ashi candles and trend confirmation
sellCondition1 = currHaClose < prevHaLow               // Heikin-Ashi close breaks previous Heikin-Ashi low
sellCondition2 = currSellVolume > prevSellVolume       // Current selling volume exceeds previous
sellCondition3 = prevHaClose > currHaOpen              // Previous Heikin-Ashi candle closes higher than current open
sellCondition4 = haClose < ma                          // Close price is below moving average (trend confirmation)
sellSignal = sellCondition1 and sellCondition2 and sellCondition3 and sellCondition4 and not sidewaysMarket  // Avoid sideways zones

// Calculate Stop-Loss and Target Levels for Long and Short Positions
longStopLoss = currHaClose - (atrValue * riskMultiplier)  // Stop-loss for long position
shortStopLoss = currHaClose + (atrValue * riskMultiplier)  // Stop-loss for short position

// **Auto Risk-Reward Ratio**: The Reward (Target) is dynamically calculated based on the risk
rewardRatio = input.float(6, title="Default Risk-Reward Ratio")  // Updated Risk-Reward Ratio to 6
longTarget = currHaClose + (currHaClose - longStopLoss) * rewardRatio  // Target for long position
shortTarget = currHaClose - (shortStopLoss - currHaClose) * rewardRatio  // Target for short position

// Calculate position size based on capital risk and set to auto trade 0.01 lot for XAUUSD
capital = strategy.equity
riskPerTrade = capitalRiskPercent / 100 * capital
longPositionSize = math.max(riskPerTrade / (currHaClose - longStopLoss), 0.01)  // Minimum 0.01 lot for long position
shortPositionSize = math.max(riskPerTrade / (shortStopLoss - currHaClose), 0.01)  // Minimum 0.01 lot for short position

// Strategy Execution: Long Trades
if (buySignal)
    strategy.entry("Long", strategy.long, qty=longPositionSize)
    strategy.exit("Take Profit", "Long", limit=longTarget, stop=longStopLoss)

// Strategy Execution: Short Trades
if (sellSignal)
    strategy.entry("Short", strategy.short, qty=shortPositionSize)
    strategy.exit("Take Profit", "Short", limit=shortTarget, stop=shortStopLoss)

// Plot shapes for buy and sell signals
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.blue, style=shape.labelup, text="LONG")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SHORT")

// Alert conditions for buy and sell signals
alertcondition(buySignal, title="Buy Alert", message="Buy Signal Triggered!")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal Triggered!")

// Plot the Heikin-Ashi Close price for reference
plot(haClose, color=color.gray, linewidth=1, title="Heikin-Ashi Close")

// Plot moving average for trend reference
plot(ma, color=color.orange, linewidth=1, title="Moving Average (Trend Filter)")


Arquivos anexados:

Respondido

1
Desenvolvedor 1
Classificação
(132)
Projetos
178
39%
Arbitragem
4
25% / 50%
Expirado
14
8%
Livre
2
Desenvolvedor 2
Classificação
(15)
Projetos
34
24%
Arbitragem
4
0% / 50%
Expirado
2
6%
Trabalhando
3
Desenvolvedor 3
Classificação
(5)
Projetos
5
0%
Arbitragem
5
0% / 40%
Expirado
0
Livre
4
Desenvolvedor 4
Classificação
(539)
Projetos
618
33%
Arbitragem
35
37% / 49%
Expirado
10
2%
Ocupado
5
Desenvolvedor 5
Classificação
(31)
Projetos
44
61%
Arbitragem
0
Expirado
0
Livre
6
Desenvolvedor 6
Classificação
(77)
Projetos
240
73%
Arbitragem
7
100% / 0%
Expirado
1
0%
Livre
7
Desenvolvedor 7
Classificação
(27)
Projetos
37
24%
Arbitragem
14
0% / 93%
Expirado
4
11%
Livre
8
Desenvolvedor 8
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
9
Desenvolvedor 9
Classificação
(56)
Projetos
88
42%
Arbitragem
4
0% / 100%
Expirado
3
3%
Trabalhando
10
Desenvolvedor 10
Classificação
(844)
Projetos
1445
72%
Arbitragem
119
29% / 47%
Expirado
355
25%
Trabalhando
Publicou: 3 artigos
11
Desenvolvedor 11
Classificação
(69)
Projetos
146
34%
Arbitragem
13
8% / 62%
Expirado
26
18%
Livre
Publicou: 6 códigos
Pedidos semelhantes
Greetings, I'm seeking a price quote for the following EA description. 1) Short positions are opened after trades that have closed below the open of the trade. 2) Long positions are opened after trades that have closed above the open of the trade. 3) The base lot size plus the spread is applied for every trade that opens after the take profit has been reached. 4) Double the lot size of the previous trade plus
I have an issue with my ninja script and i would like you to help me straighten things I wanted to create an indicator and i have the source code already but i am getting compiling errors on my NinjaTrader And i tried fixing the error it still same I sent 3 images here for you to understand the errors and i would like to ask if you can help me fix it so i can go ahead and compile my source code. Thanks
Good day, I would like to build an automated trading system for Ninjatrader using 2 MACD, a Supertrend, and a moving average indicator. I want the option to adjust the indicator settings, the ability to trade at three different times, and the option to receive alerts. I want to get an idea of what that will cost me. It will enter trades on all blue take one contract out at a fixed point, move the stop to break even
I need an MQL5 indicator that identifies reversals without repainting or placing signals with an offset. The goal is to minimize lag and reduce whipsaw trades. Desired results are similar to the attached image. Requirements: - No repainting - No signal offset - Emphasis on reducing lag - MQL5 compatible - Clear, concise code If you have the expertise to create a reliable, high-performance indicator, let's discuss
I'm looking for a skilled trader/developer to share a proven scalping strategy on M1-M5 timeframes without using Martingale, Grid trading, or Hedge. Requirements: - Minimum trade duration: 2 minutes - Lot size: <20 - Proof of skill: Provide MT4/MT5 trade history report (PDF/HTML) - No High Frequency Trades - GMT+1 timezone, flexible hours - Price negotiable, performance-based compensation possible If you're a
MT5 30 - 50 USD
I'm looking for an experienced MQL5 developer to help with backtesting, optimization, and VPS setup for a prop firm EA on XAUUSD (Gold). Scope of work - Backtest and optimize using high-quality tick data from Dukascopy or Polygon (2020–2025) - Perform Monte Carlo and Walk-Forward testing to optimize parameters like ATR multipliers and risk % - VPS installation and configuration for continuous MT5 operation - Apply
Good day, I would like to build an automated trading system for Ninjatrader using 2 MACD, a Supertrend, and a moving average indicator. I want the option to adjust the indicator settings, the ability to trade at three different times, and the option to receive alerts. I want to get an idea of what that will cost me. It will enter trades on all blue take one contract out at a fixed point, move the stop to break even
I have an indicator i need automated i use it manually and it plots arrows. Can you automate it for my Ninjatrader8? Do you need to see file? Expert Ninjatrader Developer can Bid for this project
I want to create an SMC bot base on ICT and Market structure,the bot must be able to keep adding on more positions while started.The bot must have a perfect risk management
Hi, im not looking into developing a new EA. I am looking into purchasing an existing EA that can deliver such results like: mq5 source, 4‑year backtest (2022‑2025) report, equity curve, trade list, strategy description, and 1‑month demo access. Please without concrete prove of experience functioning existing EA working perfectly and as contained on my description, then we can't strike a deal. Thank you

Informações sobre o projeto

Orçamento
100 - 200 USD
Prazo
de 1 para 100 dias