-1

I'm working on a score strategy, based on several indicators. The script has no error, but when i add the score sistem i got "Study error: internal server study error"

score = 0
plot(score)

if ma_buy
    score := score + 1
if st_buy
    score := score + 1
if hs_buy
    score := score + 1
if vortex_buy
    score := score + 1
if vo_buy
    score := score + 1

if ma_sell 
    score := score - 1
if st_sell
    score := score - 1
if hs_sell
    score := score - 1
if vortex_sell
    score := score - 1
if vo_sell
    score := score - 1
    
    
if score > 0
    strategy.entry("Long", strategy.long)
    
if score < 0
    strategy.entry("Short", strategy.short)

2 Answers2

2

The problem was putting a plot before the calculations...

1

Although you already found a solution, I want to tell you, that your code can be written better by removing repetitive code:

score = 0
if ma_buy or st_buy or hs_buy or vortex_buy or vo_buy or cm_buy or vfi_buy or qqe_buy
   score += 1

if ma_sell or st_sell or hs_sell or vortex_sell or vo_sell or cm_sell or vfi_sell or qqe_sell
   score -= 1
kyu23
  • 61
  • 5