Menu

The Translator Got Better: One Fix, One Script That Used to Fail, Before and After
πŸ“°

The Translator Got Better: One Fix, One Script That Used to Fail, Before and After

DEV Community: pythonΒ·Lei ChenΒ·2 days ago
#59SRJ6PY
#devtopython#devto#dev#strategy#entry
Reading 0:00
15s threshold

The Translator Got Better: One Fix, One Script That Used to Fail, Before and After

Your Pine strategy uses strategy.entry(..., when=...) . The converter passes when= through verbatim. The output compiles clean β€” and dies on the first bar with TypeError: entry() got an unexpected keyword argument 'when' . The fix is four lines of if . This post measures the before and the after, trade for trade.

This is the eighth post in a series where I convert Pine strategies to Python line by line. The last post was about 366 scripts that draw and never plot. This one is about a fix: one family of calls, one script that used to fail, and the check that proves the fixed version means the same thing as the Pine.

The short version.

Before: the converter passed when= through to PyneCore, which has no when parameter on any strategy.* function. The output compiled clean and died on the first bar: TypeError: entry() got an unexpected keyword argument 'when' .

After: the same script converts with zero diagnostics .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.