Increasing a position size

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #213831 quote
    KumoNoJuzza
    Participant
    New

    Hi,

    I would need help on this one.

    I am testing a strategy with a trailing stop. When the trailing stop is active I want to increase the position size by buying one more contract.

    I am using the following code but backtests results are exactly the same whether I add it or not:

    //Increase position size
    IF LONGONMARKET and trailingstart >0 THEN
     BUY 1 CONTRACT AT MARKET
    ENDIF

    I am using this version of trailing stop:

    //trailing stop function
    trailingstart = 20 //trailing will start @trailingstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
     newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
     IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
      newSL = tradeprice(1)+trailingstep*pipsize
     ENDIF
    //next moves
     IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
      newSL = newSL+trailingstep*pipsize
     ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
     IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
      newSL = tradeprice(1)-trailingstep*pipsize
     ENDIF
    //next moves
     IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
      newSL = newSL-trailingstep*pipsize
     ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
     SELL AT newSL STOP
     EXITSHORT AT newSL STOP
    ENDIF

    Any idea on how to increasing the size of position while already on market?

    Thanks

    #213832 quote
    GraHal
    Participant
    Master

    Try …

    //Increase position size
    IF LONGONMARKET and NewSL >  0 THEN
     BUY 1 CONTRACT AT MARKET
    ENDIF
    #213833 quote
    KumoNoJuzza
    Participant
    New

    It still does not work.

    By the way I apologise as I used your suggestion in first place. I wrote my post too fast.

    I am wondering if it is possible to increase the size of the position when already on market.

    #213834 quote
    GraHal
    Participant
    Master

    if it is possible to increase the size of the position when already on market.

    Yes as long as in the same direction as the existing position.
    I can’t see how my suggestion cannot work, but maybe we will both learn something when somebody tells us!? 😀

    #213835 quote
    KumoNoJuzza
    Participant
    New

    Thanks.

    I am sure I am screwing something obvious up but I cannot find out what.

    #213836 quote
    GraHal
    Participant
    Master

    Which of these are you using …

    Defparam Cumulate Orders = True
    OR
    Defparam Cumulate Orders = False
    KumoNoJuzza thanked this post
    #213837 quote
    KumoNoJuzza
    Participant
    New

    False…

    I thought when set to true it only prevented concurrent orders, I did not know about this requirement to increase a position size.

    Time to sleep I guess.

    #213839 quote
    GraHal
    Participant
    Master

    So it’s working now as you want (as we expected) now you are using True?

    #213845 quote
    KumoNoJuzza
    Participant
    New

    Results are better but I need further investigation to ensure this is the expected outcome. I keep you posted.

    GraHal thanked this post
    #213953 quote
    ZeroCafeine
    Participant
    Senior

    don’t forget if you want to increasing the size of position while already on market, you have to use PricePosition and not use TradePrice like on your code, you can see on this link a good example with explanation or Roberto

    KumoNoJuzza thanked this post
    #214116 quote
    KumoNoJuzza
    Participant
    New

    Thanks, I will have a look.

    I also need to check the work you are doing on that Yen Strategy, it seems interesting. This Pro Builder/Order platform is so exciting, I cannot find enough time to explore all the gems available in the forum.

    ZeroCafeine thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Increasing a position size


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by KumoNoJuzza
2 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/28/2023
Status: Active
Attachments: No files
Logo Logo
Loading...