How to buy 1/4 of Position when indicator is less than X ?
Author: kelvinyip
Creation Date: 11/7/2020 12:54 PM
profile picture

kelvinyip

#1
I always set the buy for the entire amount set in the position sizing GUI for this one symbol say SPY. Now I want to buy 1/4 of the value I set in position sizing GUI if say (today's close is greater than yesterday) and keep doing it until my total size is all used up. When I sell, I want to be able to sell 1/4 position each time another indicator value is below X (say close today is lower than yesterday) or sell the entire amount in one shot..

Can you please give some sample code ?
profile picture

Eugene

#2
Simply issue BuyAt* orders until your counter is less than 4.
profile picture

kelvinyip

#3
oh , didn't think of that... counter at outerloop
profile picture

kelvinyip

#4
If I don't want even sized positions, BuyAt* doesn't quite let me play with the amount... I want 1st buy to be 10% of 100k, 2nd buy to be 20%..
profile picture

Eugene

#5
Your options are:

1.
CODE:
Please log in to see this code.

2. Pyramiding PosSizer
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).