JoshuaMcGowan

Strategy Test - Cancel Limit Order and Position Sizing

While working thru another project had the need to troubleshoot the canceling of a limit order syntax/process as well as work thru the code and logic to automagically set the position sizing based off two user inputs (Amount to Risk in USD and Leverage to Use) and the potential entry and stop levels for an inside bar candle pattern in this scenario. Once we find the distance between the entry and stop level we can figure out the stop percentage amount which matches up with what a user would see manually drawing using the long or short tool in tradingview. Once we have the user inputs and levels we can get an amount to be used in later qty= type of places in zeeee pine script....
Release Notes:
The previous code didn't meet my specific trade setup requirements but left that information commented out in case it applies and is helpful to someone else down the road. Will be testing this new approach and see how it ends up going. This is by no means a finished product but the various code snippets should be of help to others looking for ways to approach this risk management question.

All the best. #PMAFTW

Learn: www.therationalinvestor.com/?discount=Fok7MHYJDi5JHvZD6A4MHej
Connect: www.linkedin.com/in/thejoshuamcg/
Support via BTC: 38fNVWomAePgeoMCBfeJmdivbdk14LZQNx
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?