Exit of market in tradeprice
Forums › ProRealTime English forum › ProOrder support › Exit of market in tradeprice
- This topic has 11 replies, 3 voices, and was last updated 4 years ago by robertogozzi.
Tagged: loss, positionperf, POSITIONPRICE, tradeprice
-
-
09/27/2020 at 5:37 PM #14558209/27/2020 at 7:22 PM #145593
There you go:
123456789101112131415If Not OnMarket thenCount = 0ElseIf Hour <> Hour[1] Thenx = 1If Hour < Hour[1]x = ((Hour + 24) - Hour[1])EndifCount = Count + xIf Count >= 12 And PositionPerf < 0 ThenSell at MarketExitshort at MarketEndifEndifEndif09/28/2020 at 9:47 AM #145631Like doing the same thing but with 5-minute bars. Instead of 12 hours it would be 144 bars of 5 minutes.
The trade begins, if after 144 bars of 5 minutes the trade is lost, if the quote returns to the purchase price the trade is closed.
Thanks, and sorry.
09/28/2020 at 5:34 PM #145737I think your code does not work Roberto, also
I would need the code but with 5 minute bars.
Operation opens.
If after 144 bars the operation is in losses, if the price returns to the purchase point, the operation is closed.Thanks!
09/28/2020 at 6:50 PM #145751Yes, my fault, I exited at market.
Replace lines 11-12 with:
12Sell at PositionPrice LIMITExitshort at PositionPrice LIMITI’ll make the other code later.
Please do NOT use the “insert PRT code” button to enter common text. Use it only for code, instead.
09/28/2020 at 7:00 PM #14575709/28/2020 at 7:40 PM #14576109/28/2020 at 9:32 PM #145779Ok Roberto.
I always have problems with translators, sorry.
One more thing:
I want to do the same with%.
That is … I have a position, I want that if the position loses 1% and returns to the purchase price, the operation is closed.Thank you very much!
09/28/2020 at 11:49 PM #145787This is the code with the 3 different ways to exit when in loss:
12345678910111213141516171819202122232425262728293031323334353637//////////////////////////////////////////////////////////////////////////////// --- Exit at Entry Price if losing AFTER N hoursIf Not OnMarket thenCount = 0ElseIf Hour <> Hour[1] Thenx = 1If Hour < Hour[1] Thenx = ((Hour + 24) - Hour[1])EndifCount = Count + xIf Count >= 12 And PositionPerf < 0 Then //12 hoursSell at PositionPrice LIMITExitshort at PositionPrice LIMITEndifEndifEndif//////////////////////////////////////////////////////////////////////////////// --- Exit at Entry Price if losing AFTER N barsIf OnMarket thenIf (BarIndex - TradeIndex) >= 144 And PositionPerf < 0 Then //144 barsSell at PositionPrice LIMITExitshort at PositionPrice LIMITEndifEndif//////////////////////////////////////////////////////////////////////////////// --- Exit at Entry Price if losing 1%+If Not OnMarket thenExitFlag = 0ElseIf ((PosiTionPerf * 100) <= -1) OR ExitFlag THEN //1% lossExitFlag = 1Sell at PositionPrice LIMITExitshort at PositionPrice LIMITEndifEndif//////////////////////////////////////////////////////////////////////////////2 users thanked author for this post.
09/28/2020 at 11:50 PM #14578810/01/2020 at 6:58 AM #14603710/01/2020 at 8:25 AM #146047We cannot always tidy up your code!
Please use plain text without embedded formatting codes. Thank you 🙂
Use
12Sell at PositionPrice*1.005 LIMITExitshort at PositionPrice*0.995 LIMIT -
AuthorPosts
Find exclusive trading pro-tools on