Trading strategy

명시

//@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)")


파일:

응답함

1
개발자 1
등급
(132)
프로젝트
176
39%
중재
4
25% / 50%
기한 초과
14
8%
무료
2
개발자 2
등급
(13)
프로젝트
29
28%
중재
3
0% / 0%
기한 초과
1
3%
로드됨
3
개발자 3
등급
(1)
프로젝트
1
0%
중재
0
기한 초과
0
무료
4
개발자 4
등급
(495)
프로젝트
566
33%
중재
27
44% / 44%
기한 초과
9
2%
로드됨
5
개발자 5
등급
(15)
프로젝트
27
67%
중재
0
기한 초과
0
무료
6
개발자 6
등급
(64)
프로젝트
198
72%
중재
4
100% / 0%
기한 초과
1
1%
작업중
7
개발자 7
등급
(9)
프로젝트
15
7%
중재
0
기한 초과
2
13%
작업중
8
개발자 8
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
9
개발자 9
등급
(48)
프로젝트
74
43%
중재
3
0% / 100%
기한 초과
1
1%
작업중
10
개발자 10
등급
(814)
프로젝트
1392
72%
중재
114
29% / 47%
기한 초과
345
25%
작업중
11
개발자 11
등급
(67)
프로젝트
144
34%
중재
10
10% / 60%
기한 초과
26
18%
무료
비슷한 주문
The Moving Average Cross needs debugging for live chart . [Condition 1] Personalized Omega Trailing Stop Loss ( Details of how it works will be provided , If still necessary the expert where it works just fine will be provided . ) Couple of Input parameters that needs to be removed (previous dev just added ) [ He can be contacted if necessary ]. Following are the implementations required by my expert : 1. Auto Lot
Hello, I’m looking for a TradingView indicator that fits my forex trading needs. If you can create or customize one for me, please reach out. I'd appreciate your help! Best regards
Hello, I’m looking for a TradingView indicator that fits my forex trading needs. If you can create or customize one for me, please reach out. I'd appreciate your help! Best regards ridynaty
Create a Backtesting stimulator similar to ------ https://www.mql5.com/en/market/product/101346?source=External but showing BALANCE AND EQUITY on screen including open trades.. Must have experience with Backtesting softwares or can offer a solution to what am looking to fix.. IF you can develop I can go a bit above my budget
need EA for basic MT4 breakout and trapping bot with a few other requirements. After we confirm the job, we will talk over more specifics. This offer can be negotiated. You can quote me the final offer after I give you all the facts.Thank you
This is a project for a binary trading platform called binomo. I have solid strategy and want to convert into a automatic robot which will trade for me according to my strategy on binomo platform. If you are familiar with binomo platform and this types of works. Please apply here
All details will be sent I need a trade manage with complex designs and active news designs. If you are ready to take it I will send a sample from MQL5 to make explain straight forward
Hedge robot 30+ USD
I want to make a robot. Functions that will be inside the robot: 1) Determine the trading hour. (For example, if I have selected 11.00, if it closes with an increase candle at 11 o'clock, buy, if it closes with a decrease candle, it will open a sell trade). 2) I can choose the time of the chart (For example, H1, H4, M15, M1) 3) Hedge distance 4) TP function 5) Average profit (For example, if $5, $10 is averaged
Hello Great developer can you Create a NinjaTrader strategy for me 1. Identify yesterday’s range (high and low) between 13:30 and 16:00. Call this the NY PM Range. 2. Wait until price trades above the NY PM Range High or below the NY PM Range Low in Regular Trading Hours (9:30 to 16:00) 3. If price trades above the NY PM Range High, Set a Stop Market Order Short at low of the previous candle. Continuously adjust the
Simple RSI EA 30 - 100 USD
I accept ideas please without any problem my budget is 100 dollars when you apply please be so kind if you know about news filters I paid 200 dollars previously and the programmer left me the work incomplete because he did not know about news filters I need a basic Rsi bot that buys and sells when it reaches the levels. I don't want anything else. I want it to have a news filter option -NEWS FILTER- Activation

프로젝트 정보

예산
100 - 200 USD
기한
에서 1  100 일

고객

넣은 주문1
중재 수0