// === Input Parameters ===
tp1 = 20 // Take Profit for first exit
sl1 = 40 // Stop Loss for first exit
tp2 = 40 // Take Profit for second exit
sl2 = 20 // Stop Loss for second exit
// === Indicators ===
avg1 = average[10](close) // Fast moving average
avg2 = average[50](close) // Slow moving average
lmax = highest[15](high)
// === Entry Logic ===
IF NOT longonmarket AND avg1 CROSSES OVER avg2 THEN
type = 1
BUY 1 CONTRACT AT MARKET
SET STOP PLOSS sl1
SET target Pprofit tp1
elsif not longonmarket AND close crosses over lmax[1] THEN
type = 2
BUY 1 CONTRACT AT MARKET
SET STOP PLOSS sl2
SET target Pprofit tp2
elsif not onmarket then
type = 0
ENDIF
// === Plotting indicators and levels on chart ===
graphonprice avg1 coloured("red")
graphonprice avg2 coloured("blue")
graphonprice lmax coloured("green")
graph type