I have been trying to research how I can trigger LONG and EXIT from both crossover and price above security in my backtesting logic without luck and ask now for assistance with my backtesting pine editor code.
I will include some parts of my code so you see what I trying to do.
// add trading pair outside chart data
btc_price = security("BINANCE:BTCUSDT", "D", close)
// compute the indicators ( main chart ETH/USDT )
smaInput = input(title="SMA", type=input.integer, defval=1)
indicator1 = sma(close,smaInput)
// compute the indicators BTC
btcsmaInput = input(title="SMABTC", type=input.integer, defval=1)
indicatorbtc = sma(btc_price,btcsmaInput)
// plot the indicators
plot(indicator1, title="Indicator1", color=color.red, linewidth=2)
plot(indicatorbtc, title="Indicator1", color=color.blue, linewidth=2)
What I trying to achieve in pseudo-code: Go Long IF close IS ABOVE indicator1(ETH/USDT) and BTC/USDT price IS ABOVE indicatorbtc Go Exit IF close IS BELOW indicator1(ETH/USDT) or BTC/USDT price close IS BELOW indicatorbtc
Here is my code that I need help with, the code below does not work as I describe it above in the pseudo-code.
// Backtesting Logic
EnterLong = crossover(close,indicator1) and crossover(btc_price, indicatorbtc)//
ExitLong = crossunder(close,indicator1) or crossunder(btc_price, indicatorbtc) //
Please advice.