Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Strategy.exit: What are "points" in this context? V5

Example from manual:

strategy.exit("exit", "long", profit = 10, loss = 5) // generate full exit bracket (profit 10 points, loss 5 points per contract) from entry with name "long"

Are these points percents? So if this position was worth $100 (when opened) then profit = 10 point is 10% = $10 so we sold the position for $110?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Those are pips.

A pip is the smallest price move that an exchange rate can make based
on forex market convention.

If you want to do a percentage based exit, you should use the limit and stop arguments.

in_long_tp_per = input.float(2.0, "Take profit %") * 0.01
in_long_sl_per = input.float(1.0, "Stop loss %") * 0.01

long_tp_price = strategy.position_avg_price * (1 + in_long_tp_per)
long_sl_price = strategy.position_avg_price * (1 - in_long_sl_per)

if (strategy.position_size > 0)
    strategy.exit("exit", "long", limit = long_tp_price, stop = long_sl_price)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading