Partial close with porcentage

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #167933 quote
    Link
    Participant
    Senior

    My question is…

    How to close, for example, 10% if the position when you win 10% if the target profit.

    Thanks

    #167934 quote
    nonetheless
    Participant
    Master

    This sells 10% after a 10% increase. You can alter the PerCentGain if you want it to be 10% of your target.

    Check the minimum lot size for the instrument:

    ONCE partialclose = 1
    ONCE PerCent     = 0.1              //10% of position to close
    ONCE PerCentGain = 0.1            //10%  increase
    ONCE MinLotSize  = 0.5              //0.5  lots minimum
    ExitQuantity     = abs(CountOfPosition) * PerCent
    LeftQty          = max(MinLotSize,abs(CountOfPosition) - ExitQuantity)
    CloseQuantity    = abs(CountOfPosition) - LeftQty
     
    IF Not OnMarket THEN
    Flag = 1 
    ENDIF
     
    IF partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flag THEN
    SELL CloseQuantity Contracts AT Market
    Flag = 0
    endif
    
    
    icharttop thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Partial close with porcentage


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Link @tony-manero Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by nonetheless
4 years, 10 months ago.

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