You are on page 1of 1

https://www.tradingview.com/pine-script-docs/en/v5/concepts/Strategies.

html#a-simple-
strategy-example

https://www.tradingview.com/script/3qCORhdT-MACD-Crossover-trend-strategy-Long-and-
Short/

https://algotrading101.com/learn/pine-script-tradingview-guide/

strategy("MACD - long", initial_capital = 10000, overlay=false, margin_long=100, default_qty_value = 100,


default_qty_type = strategy.percent_of_equity)

//MACD input
Linia = 0
fast = 12
slow = 26
fastMA = ta.ema(close, fast)
slowMA = ta.ema(close, slow)
MACD = fastMA - slowMA
signal = ta.ema(MACD, 9)

//PLOT
plot(MACD, color = color.blue)
plot(signal, color = color.orange)
plot(Linia, color = color.green)

//Warunki
Notintrade = strategy.position_size <= 0
GoLongCondition1 = ta.crossunder(signal, MACD) and signal<Linia
CloseLongCondition1 = ta.crossover(signal, Linia)
ExitLongCondition = (close<(close[1]*0.90))
ExitLongCondition1 = (close>(close[1]*1.15))

//entry/exit - działa long, dodać do close stoploss i takeprofit, napisać short?


if GoLongCondition1 and Notintrade
strategy.entry('long', strategy.long)
if (CloseLongCondition1 or ExitLongCondition or ExitLongCondition1)
strategy.close('long')

You might also like