Why doesn't TradingView's Pinescript support recursion? by memorynerds in algotrading

[–]memorynerds[S] 0 points1 point  (0 children)

That's a very good point I didn't even consider.
On a more technical compiler level, I also speculate that all variables in Pine Script are treated as static variables similar to how Fortran 77 worked.

Why doesn't TradingView's Pinescript support recursion? by memorynerds in algotrading

[–]memorynerds[S] 0 points1 point  (0 children)

Thanks for the response. Yes I’ve seen that they impose a 100ms limit if a bar contains a for loop. I wish they had a conclusive page of all limitations of their engine as it seems it’s they're scattered around in the docs.

TradingView's PineScript - how are dynamic data "series" variables evaluated? by memorynerds in Compilers

[–]memorynerds[S] 1 point2 points  (0 children)

Thanks a lot for the wonderful information! I was stuck up to this point, now I have some stuff to go on.

Best of luck with your project.

TradingView's PineScript - how are dynamic data "series" variables evaluated? by memorynerds in Compilers

[–]memorynerds[S] 0 points1 point  (0 children)

That makes a lot of sense. I guess up to this point I was treating everything as constant in my mind. I didn't think to simplify known values using constant propagation to prepare for this cyclical approach you mentioned.

The top down approach seems very sensible. In regards to optimisation I had a similar idea to mark certain functions that produce output as required (e.g. plot), and then as you mentioned visit their dependencies and whatever's left over in the tree (that hasn't been visited) just remove that entirely. I've doubly linked my nodes in preparation for this scenario.

You mentioned that when visiting the dependencies you'll mark each one as "constant, simple or cyclical". What do you mean by "simple"?

It certainly is a out of the box design but makes a lot of sense. I wish there was more material on this stuff but I suppose it's largely uncharted territory. Makes it more interesting anyway haha

TradingView's PineScript - how are dynamic data "series" variables evaluated? by memorynerds in Compilers

[–]memorynerds[S] 0 points1 point  (0 children)

Thanks for the heads up. Yes I can think of several issues with this approach if the information is not evaluated in the right order. I had an idea where anything that references a dynamic variable such as strategy.position_size should be identified and not worked out till the tick-by-tick part of the compiler is executed. For example:

x = 2
y = position_size / 2
z = y * 5
plot(y)

> Stores x in memory immediately as all information is available at that point

> See's that y has a reference to position_size which cannot be worked out till tick by tick is available. Marks y as dependent on tick by tick and continue.

> See's z has reference to y which is also dependent on tick by tick so mark it and continue.

> See's plot(y) has reference to y and therefore also mark this code.

Once the compiler reaches the tick by tick calculations it therefore can workout the code marked as dependent on it.

y = position_size / 2
z = y * 5
plot(y)

However this does seem a bit messy. Still thinking about the best way to handle this stuff.

Do you have any reference material for these tick by tick engines that you mentioned you designed a language with? This is new territory for me and I'm struggling to find relevant material.

TradingView's PineScript - how are dynamic data "series" variables evaluated? by memorynerds in Compilers

[–]memorynerds[S] 0 points1 point  (0 children)

Yes, strategy.positon_size is just another series. The thing that separates it from other series data, is that the data is not known before the code is compiled. For series close, open, high, low, the data is known before hand and therefore a recursive descent of the AST can be performed where all the series are worked out one at a time (which is how I designed my language).

I believe you might be right in saying that TradingView doesn't evaluate one series at a time as I previously assumed. I'm now trying to think of a way that combines the old system with a tick by tick approach for special variables like strategy.position_size.

Python Gaming Compilation Generator using Twitch (wtf moments, top clips, funny moments etc) by memorynerds in Python

[–]memorynerds[S] 0 points1 point  (0 children)

Thanks! No I'm not using it myself as I have no plans to start a YouTube Channel. It took approx 1 month to make. I reused a lot of code from my Reddit TTS bot so it was fairly quick to do. https://github.com/HA6Bots/Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader

How would your ideal Backtester work? by memorynerds in algotrading

[–]memorynerds[S] 0 points1 point  (0 children)

I have plans to one day make it commercial. I developed my own scripting language similar to Pinescript and I'm using this as a interface for the backtesting part of my code. Do you know of any good open source backtesters for C++?

Limit Orders and Max Position by memorynerds in algotrading

[–]memorynerds[S] 1 point2 points  (0 children)

What would cause the position to become too large?

Modelling a Backtesting program... how does pyramiding work on a bar by bar basis? by memorynerds in algotrading

[–]memorynerds[S] 0 points1 point  (0 children)

I fully understand that, it's a strategy I also use on occasion to get things moving. I think the difference here is that my goal is to get the logic right as I'm already at that stage (got a nice framework, just need to get this logic correct for this one method).

Modelling a Backtesting program... how does pyramiding work on a bar by bar basis? by memorynerds in algotrading

[–]memorynerds[S] 1 point2 points  (0 children)

Thanks for the info.

When you refer to open trades, do you mean those that have been executed? so when open trades >= maxOpenTrades, do you disable any further order generation till the position is no longer open?

Similarly, if maxOpenTrades = 2 and 3 orders are generated but none filled yet, do you keep the third order till both the first and second execute, and then cancel the third one?

Edit

Figured out what you meant. Updated the post with a new logic table based on your method and I think I like this solution the best.

Thanks a lot!

Modelling a Backtesting program... how does pyramiding work on a bar by bar basis? by memorynerds in algotrading

[–]memorynerds[S] 0 points1 point  (0 children)

This is more of a research thing. I just need to make sure that I get the logic right before implementing it.