Close position when new candle
Forums › ProRealTime English forum › ProBuilder support › Close position when new candle
- This topic has 9 replies, 3 voices, and was last updated 4 years ago by robertogozzi.
-
-
10/20/2020 at 1:28 PM #14790210/20/2020 at 1:40 PM #147907
Simply add these lines at the beginning of your code, just after DEFPARAM’s:
12Sell at MarketExitshort at Marketwhen you are not OnMarket they are ignored, otherwise they will close any trade opened the previous candle.
1 user thanked author for this post.
10/20/2020 at 2:02 PM #14791010/20/2020 at 2:17 PM #147913You can only count bars, read https://www.prorealcode.com/topic/define-a-time-stop/#post-147903.
If you are using a minute or second TF, yes it’s possible.
10/20/2020 at 2:29 PM #14791610/20/2020 at 2:38 PM #14791810/20/2020 at 2:56 PM #14792110/20/2020 at 3:14 PM #147922But if I am in a 1 minute TF I cant define it too stop after x secs?
Yes, you can do it
1 user thanked author for this post.
10/20/2020 at 3:27 PM #14792310/20/2020 at 4:39 PM #147936There you go (run it from a 1-second TF):
12345678910TIMEFRAME(1 minute,UpdateOnClose)IF MyLongConditions THENBUY 1 Contract at MarketENDIFTIMEFRAME(1 second,UpdateOnclose)MySecond = opentime - (round((opentime / 100) - 0.5) * 100)TIMEFRAME(default)IF MySecond >= 50 AND LongOnMarket THENSELL at MarketENDIFline 8 checks for MySecond being 50 or greater, since it may happen not to have that candle on such a small TF.
Searching this forum for the words MTF and Multi Time Frame will return many links to examples, documentations, blogs and many topics.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on