1

hi i was trying to test if stochastic crosses over 80, buy if stochastic crosses under 20 sell

for some reason, the order doesn't get executed properly(i mean it doens't get executed at all) any thoughts on why this is happening?

//@version = 2
strategy("buy signal entry")
signal = stoch(close,high,low,14)
//plot stochastics
plot(signal,color = white)
//buy when signal crossover 80 and sell when it crossunder 20
buysignal = crossover(signal,80)
sellsignal = crossunder(signal,20)
if(buysignal)
    strategy.entry("buy", strategy.long)
if(sellsignal)
    strategy.exit("exit", "buy")
PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
이종연
  • 129
  • 1
  • 9

1 Answers1

0

You need to use strategy.exit instead of strategy.close, according docs about strategy.close:

To use market order to exit, the command strategy.close or strategy.close_all should be used.

kuznet1
  • 54
  • 1
  • 7