Close all open Orders
Forums › ProRealTime English forum › ProOrder support › Close all open Orders
- This topic has 12 replies, 4 voices, and was last updated 1 year ago by GraHal.
-
-
02/01/2023 at 8:33 AM #20889002/01/2023 at 9:26 AM #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.
02/01/2023 at 10:01 AM #208901If 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.
ORDERS BASKET STOPLOSS12345//long positionsif longonmarket then//set the stoploss at mean opened price - 20 points, limiting the loss to "only" 20 pointsset stop price positionprice - 20*pointsizeendif1 user thanked author for this post.
02/01/2023 at 10:24 AM #20890402/02/2023 at 6:36 AM #208922Hello 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 allI am on holiday at the moment and only have the iPad with me, so I can’t post a code.
Greetings from New Zealand
02/07/2023 at 12:01 PM #209294Hello,
I am back from holiday and can now also post the code.
I have tried the following code but something does not fit.12345678910111213DEFPARAM CumulateOrders = trueONCE maxLOSS = 400 //EuroIF LONGONMARKET THENIF ((tradeprice(0)-close)*POINTVALUE)>= maxLoss THENSELL AT MarketENDIFENDIFIF SHORTONMARKET THENIF ((close-tradeprice(0))*POINTVALUE)>= maxLoss THENEXITSHORT AT MARKETENDIFENDIF02/07/2023 at 12:12 PM #20929502/07/2023 at 2:45 PM #209306Hello,
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
Suffi02/07/2023 at 3:01 PM #209308Try below and let us know?
ONCE maxLOSS = 400*countofposition //Euro
02/07/2023 at 5:03 PM #209312Hi,
I hope thats right.
1234567If LongOnMarket THENset stop price POSITIONPRICE - (maxloss / (COUNTOFLONGSHARES * pointsize))ENDIFIf ShortOnMarket THENset stop price POSITIONPRICE + (maxloss / (COUNTOFSHORTSHARES * pointsize))ENDIF02/07/2023 at 7:27 PM #209321Isn’t below what it should be?
Try yours and mine on Live data on Demo Account.Let us know how it goes.
1234567If LongOnMarket THENset stop price POSITIONPRICE - (maxloss * pointsize))ENDIFIf ShortOnMarket THENset stop price POSITIONPRICE + (maxloss* pointsize))ENDIF02/08/2023 at 9:05 AM #209338hello,
this is the result of the code below, it should be correct.maxloss=300 //€
1234567If LongOnMarket THENset stop price POSITIONPRICE - (maxloss / (COUNTOFLONGSHARES * pointsize))ENDIFIf ShortOnMarket THENset stop price POSITIONPRICE + (maxloss / (COUNTOFSHORTSHARES * pointsize))ENDIF02/08/2023 at 10:51 AM #209343As 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?
-
AuthorPosts
Find exclusive trading pro-tools on