0

im practising pine script, and im doing a simple strategy. but i got this error, can anyone help me? thanks !

//@version=5 strategy("Mi semaforo", overlay=true, margin_long=100, margin_short=100) mm_g = ta.sma(close, 5) mm_y= ta.sma(close, 10) mm_r = ta.sma(close, 20) alcista = (mm_g > mm_y) and (mm_y > mm_r) // bajista = (mm_g < mm_y) and (mm_y < mm_r) comprado = strategy.position_size > 0 if (not comprado and alcista) cantidad = math.round(strategy.equity, close) strategy.entry("Compra", strategy.long, cantidad) if (comprado and not alcista) strategy.close("Compra", comment="Venta") 

LINE OF ERROR = cantidad = math.round(strategy.equity, close)

ERROR = line 17: Cannot call 'math.round' with argument 'precision'='close'. An argument of 'series float' type was used but a 'simple int' is expected; line 17: Variable 'cantidad' is not found in scope '#global_#0', cannot register side effect

1 Answer 1

0

The precision argument is to round the decimal places.

If the precision parameter is used, returns a float value rounded to that amount of decimal places.

For example math.round(3.1234, 2) would return 3.12.

When in doubt, please refer to the reference manual.

Sign up to request clarification or add additional context in comments.

3 Comments

I have a bad parameter, thank you for your help sr !!!!
You cannot use close as precision argument as the error message tells you. It does not make any sense. What are you trying to do?
it was = cantidad = math.round(strategy.equity / close) , im sorry :) im learning

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.