Close all open Orders

Forums ProRealTime English forum ProOrder support Close all open Orders

Viewing 13 posts - 1 through 13 (of 13 total)
  • #208890

    Hello all,
    I need your help.
    in a strategy several orders are opened, sometimes more sometimes less.
    Now I want to limit the total loss and close all open positions without the “Quit” command.

    Greets

    Suffi

    #208892

    There are so many possible answers, I’ll start with one …

    Are you using below as the 1st line of your code?

    Defparam cumulateorders = false

    Above will mean – unless code states (?) – you won’t open more than 1.

    If you want to post your code then we may be able to help you a lot easier for us and quicker for you.

     

     

     

    #208901

    If you are accumulating orders and you want to limit the loss of the orders basket, you can set an exit stop level at a certain price, by using POSITIONPRICE (which is the mean of all orders opening price):

    set the stoploss at mean opened price – 20 points, limiting the loss to “only” 20 points.

     

    1 user thanked author for this post.
    #208904

    That’s all. Unless I misinterpret the situation.

    #208922

    Hello all,
    Thanks for the answers.
    I can understand Nicolas approach.
    I had thought of determining the maxloss in euros.
    E.g. if loss< -500€ then close all

    I am on holiday at the moment and only have the iPad with me, so I can’t post a code.

    Greetings from New Zealand

    #209294

    Hello,
    I am back from holiday and can now also post the code.
    I have tried the following code but something does not fit.

    #209295

    Your version will check for exit conditions at the end of each bar.

    Nicolas version sets a pending order which can trigger during a bar.

    #209306

    Hello,
    I can’t get my head around this and I’m trying to explain it again.

    Ex.
    Position value 1€/point
    maxloss: 500 €
    1st pos. buy at 10.000 € results in a distance of 500 points for the SL.
    2nd pos. buy at 10.100 € results in a buy price of 10.050.
    Now I have 2 positions. The SL changes to 250 points, but to the new purchase price of 10.050€.
    As more positions I have, the tighter the stoploss becomes from the changing purchase price.
    I can’t get the code to work.

    Greetings
    Suffi

    #209308

    Try below and let us know?

    ONCE maxLOSS      = 400*countofposition //Euro

    https://www.prorealcode.com/documentation/countofposition/

    #209312

    Hi,

    I hope thats right.

    #209321

    Isn’t below what it should be?
    Try yours and mine on Live data on Demo Account.

    Let us know how it goes.

     

    #209338

    hello,
    this is the result of the code below, it should be correct.

    maxloss=300 //€

     

    #209343

    As more positions I have, the tighter the stoploss becomes from the changing purchase price.

    If you not want stop price to reduce with more positions then why are you using maxloss / COUNTOFSHARES  in your code above?

    If you are happy with the result you show in your screenshot then all is good? 

     

     

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login