How to close a trade automatically?
Forums › ProRealTime English forum › ProRealTime platform support › How to close a trade automatically?
- This topic has 7 replies, 5 voices, and was last updated 4 years ago by Jack.
-
-
12/16/2019 at 10:13 PM #115012
Hi Team, I wonder if it is possible to close a trade automatically at a certain time, or after a certain time when the trade is openend after price hitting a stop order or is manualy opened?
If this is posible, can somebody teach me where to find this ordertype or how to code this?
Thank you
12/16/2019 at 10:57 PM #115013It is not possible to mix manual and auto trading. If a position is opened in an auto strategy then you can either close it manually or automatically. If a trade is opened manually then you can only close it manually.
If you want to open a trade in an auto strategy you can then check if price has dropped to or below a stop level and then set a flag so that you know it has done this. You can record the barindex or time when this occurs and then you then just need to count how much time has passed and/or check if a certain time is achieved and that the flag is set and then close the trade and reset the flag.
Something like this (not tested):
12345678910111213141516if (your long conditions) thenbuy 1 contract at marketstopprice = close - 100 //set initial stop levelendifif onmarket and not flagstopprice = positionprice - 100 //set more accurate stop levelif low < stopprice then //stop level hitflag = 1myindex = barindex //record bar that stop hitendifif flag and barindex = myindex + 24 thensell at marketflag = 0 //reset flagendif12/16/2019 at 11:12 PM #115014It is not possible fdor ProOrder to close trades opened/modified manually.
You can certainly close automatic trades opened at anytime, after N bars or at a specif TIME (and DATE, eventually) or when a price is hit.
Since all strategies are executed when a bar closes, you may need to use the MTF support to use a lower TF to be more accurate.
If your strategy runs on a 4-hour or Daily TF you can use a 1-minute TF to close/update that trade.
edit: Vonasi is superfast!!!
12/16/2019 at 11:37 PM #115015edit: Vonasi is superfast!!!
Marcel had to wait 44 minutes for my reply and 59 minutes for yours – I think we both need to up our game!
1 user thanked author for this post.
01/20/2020 at 7:58 AM #11728901/20/2020 at 8:24 AM #117292Can we do a stop loss or take profit on a portion of a position with the new prorelatime V11 ? (partial position closing)
Whether we can do this in live automatic trading or not is purely the decision of the broker. IG do not allow partial position closing at the moment and so we will all just have to wait until if and when they decide to allow it. The PRT platform is able to function already with partial position closing in back tests but if we put any strategy live it is not allowed as we are then trading both demo and live using the brokers server which does not allow it.
01/20/2020 at 11:16 AM #117302wait until if and when they (IG) decide to allow it.
Seems daft / not logical (not allowing) as we can do partial closures when manual trading with IG.
01/21/2020 at 10:05 AM #117364 -
AuthorPosts
Find exclusive trading pro-tools on