Pinescript Discussion

I got it already, thanks same way.

1 Like

Hi Filip, all,
hope you are well.

I was testing the simple MA strategy and I get this error:
Add to Chart operation failed, reason: Script could not be translated from: null

The script is:
strategy(title=MAstrategy")
m=sma(close, 10)
buy=close > m
sell=close < m
strategy.entry(“buy”, true, 1, when=buy)
strategy.close(“buy”, when=sell)

Can you, please, help?
Thanks

1 Like

I found the error, forgot " before “title”.
Thanks

1 Like

Does anyone know of there is a platform, in which you can program trades using Pine Script or equal. It would be great to find a site so that I can copy backtested programs from Tradingview Pine Script into say CFi . Is it possible? Any thoughts? Any platforms?

1 Like

Hi everyone, I am just getting started with pinescript, I do have a bit of programming knowledge in other languages, but totally new to pinescript
I have 2 question,

is it possible to read values from data generated with Java script?
Can pinescript get values from a python script?

I searched through the official references but didn’t find anything.

1 Like

Hey @Ahmer_Malik, hope you are great.

If there is nothing related on the pinescript documentation nor internet, probably it is because there is no way, what it comes to my mind is an API that you can develop to bridge python code and pinescript, if pinescript have methods to work with APIs, if not, through javascript probably.

i did not understand quite well this question, i mean it is possible to read any value generated through a function on JS, you just have to send it through the console for example.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

i try to use your code and i get : Add to Chart operation failed, reason: Script could not be translated from: null

what indicator is this that makes a thick bar under the candles and where can i get it? thanks bro

Probably some conflict or variable problem. I am not 100% sure how all parameters can/must be declared.

Question:

i followed yiur instructions 1:1 but when i try to add it to the chart it says:

“Add to Chart operation failed, reason: Script could nt be translated from: )|E| /B/ buy=close > m”

Whats up with that??
Thanks for your help!! @filip

its ok i got it!!! i accidently had a" , " after (close, 10)… haha

1 Like

Hi @filip @thecil :slight_smile:
First of all thanks for the interesting course.

I just watched the “Building a Simple Strategy” lesson and wonder isn’t it a mistake in buying above MA and selling below it?
This way it seems like buying at higher price and selling at lower, what leads to losses, doesn’t it?

1 Like

I can’t assure you that, depends too much on the strategy, some times buying/selling below or above an MA values could be part of the strategy, so any case i advice to run some tests over your theory and check if the results are positives (gains) or negative (loses).

Carlos Z

Hi can someone please help me with backtesting the strategy of an existing indicator in TradingView?
It keeps giving me errors.

I want to backtest this strategy:

https://www.tradingview.com/script/DfKqRsJb/

I tried different combinations of strategy.long inputs. Latest being:

strategy.entry(“Long”, strategy.long, 1000, when=long_final, comment=“Long”)
strategy.close(“Long” , when = short_final, comment=“Sell”)

@filip

doing the same exmaple strategy as you did, as today, it gives a maximum drawdown of 3%.

Ho is this possible since you had about 22%?
From what I understand if once the drawdown has been 22% in the future it has to be at least the same (or lower if a new DD occurs).

thanks

1 Like

Different prices on different times, its completely normal :nerd_face:.

Market conditions change all the time, so is there is no a perfect strategy that works long term (unless you improve it over years).

Carlos Z

Hi @filip

In your strategy example, is it more complex if you would want to add leverage into the back test script?

That is onchain data. It is the BSI indicator that Filip has created that can be purchased from Ivanontech.

Hello sir @filip are we still using tradingview for building and testing strategies? I’m just making sure before making a subscription on their site.

Dropping a comment because I would love to know as well.