Open pv0192 opened 5 years ago
PR for fix is up. Very simply replace the last four lines with:
strategy.entry("long", strategy.long, 1, when = (((profit_take_buy_ or long_ or buy_signal_) and strategy.position_size == 0) or (stop_and_reverse_buy_ and strategy.position_size < 0)))
strategy.entry("short", strategy.short, 1, when = (((profit_take_sell_ or short_ or sell_signal_) and strategy.position_size == 0) or (stop_and_reverse_sell_ and strategy.position_size > 0)))
strategy.exit("stop_long", "long", when = (stop_and_reverse_sell_ or stop_sell_))
strategy.exit("stop_short", "short", when = (stop_and_reverse_buy_ or stop_buy_))
Note that doesn't fix the warnings on strategy.exit (no stops etc) or the fact that this buys/sells 1 BTC, independent of starting capital.
To fix those, try strategy.close instead of strategy.exit, and replace the quantity "1" in the entry with "na", which uses "however much cash you have / market price". Top of the strategy shows you the assumed starting capital.
If the PR for the syntax issues gets accepted, I may do another one for those two changes.
1) cargo build 2) cargo run 3) Add generated sawcruhteez-strategy.pine to scripts, add to chart leads to the following error
My version of sawcruhteez-strategy.pine