Closing all positions at once pips or profit

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #114089 quote
    marcuscn
    Participant
    Junior

    Hello..

     

    I would like my system to close all my open positions at the same time once the total is = X pips or X USD ..

    so for example my algo opens up at position then another at after -15 pips then another one at -30 pips = 3 open positions.

    When the total of these 3 are equal to X amount of pips profit // or USD i want them to close.  How do i code this?

     

    Thanks

    #114136 quote
    Juan Salas
    Participant
    Master

    Hi Marcus,

    I use a piece of code that will close all my positions (long or short) when the price is above the average (positionprice):

    For example, if you have 4 LONG positions open, and the average price is becoming positive, then you can close them at market. The extrapip is the amount of pips you want to be positive (x number of contracts). If you want a conservative approach, you can set extrapip=0

    extrapip=10
    
    IF LONGONMARKET AND countoflongshares=4 AND close>(positionprice+extrapips*pipsize) THEN
    SELL AT MARKET
    ENDIF

    This only works with EITHER long or short. As you know PRT doesn’t allow you to open long and short (hedging) positions at the same time, in the same strategy

    Regards,

    Nicolas thanked this post
    #114138 quote
    Vonasi
    Moderator
    Master

    Topic moved to ProOrder forum as it is auto strategy related. Please try to post in the correct forum with future posts.

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

Closing all positions at once pips or profit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
marcuscn @marcuscn Participant
Summary

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

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