JS, Thank you. That might be it. Could you advise what the code would be so it can be used as an indicator please as that’s what I was looking for. The full code supplied was
DEFPARAM CumulateOrders = False
MyMACD = MACDline[12,26,9](close)
MySLine = MACDSignal[12,26,9](close)
MyHis = MACD[12,26,9](close)
EMA200 = ExponentialAverage[200](close)
C1 = MyMACD Crosses Over MySLine AND MyMACD < 0 AND MySLine < 0
C2 = Close > EMA200
BuyCondition = C1 AND C2
IF BuyCondition THEN
Buy 1 Shares AT Market
SwingLow = lowest[10](low) // Assuming a 10-bar lookback for swing low
NearestLevel = Min(SwingLow, EMA200) // Selecting the nearest level to the current price
slosslevel = Tradeprice – NearestLevel
set stop ploss slosslevel
set stop %trailing 0.5
ENDIF
C3 = MyMACD Crosses Under MySLine AND MyMACD > 0 AND MySLine > 0
C4 = Close < EMA200
SellCondition = C3 AND C4
IF SellCondition THEN
Sellshort 1 Shares AT Market
SwingHigh = highest[10](high) // Assuming a 10-bar lookback for swing high
NearestLevel = Max(SwingHigh, EMA200) // Selecting the nearest level to the current price
slosslevel = Tradeprice – NearestLevel
set stop ploss slosslevel
set stop %trailing 0.5
ENDIF
// Take Profit options
Option1RiskReward = 2 // Adjustable Risk/Reward ratio (e.g., 2 means 2:1)
Option2TrailStopPercent = 0.5 // Adjustable Trailing Stop loss percentage (e.g., 0.5%)
NearestStopLoss = 10 // minimum stop distance
TakeProfitOption1 = NearestLevel + (NearestLevel – NearestStopLoss) * Option1RiskReward
if (open < TakeProfitOption1 and close > TakeProfitOption1) or (open > TakeProfitOption1 and close < TakeProfitOption1) then
sell at market
exitshort at market
endif
Thanks for your help.