Partial closure, please.

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

    I need code to close, for example, 0.25% of the position at 12 hours. And close another 0.25% of the position at 18 hours.

    #198988 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ONCE LotSize  = 4
    ONCE  MinSize = 1
    ONCE ExitLots = max(LotSize * 0.25, MinSize)
     .
     .
    If OnMarket then
       If Time = 120000 OR Time = 180000 then
          Sell ExitLots contracts at Market
          Exitshort ExitLots contracts at Market
       Endif
    Endif
    Midlanddave thanked this post
    #198994 quote
    Link
    Participant
    Senior

    Thanks

    #199019 quote
    Link
    Participant
    Senior

    and code for 2 or 3 partial position closures?

    #199026 quote
    robertogozzi
    Moderator
    Master

    You can add as many different times as needed:

    If Time = 120000 OR Time = 140000 OR Time = 170000 then
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Partial closure, please.


ProOrder: Automated Strategies & Backtesting

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

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/12/2022
Status: Active
Attachments: No files
Logo Logo
Loading...