NAS 2m HULL-SAR trading system
Forums › ProRealTime English forum › ProOrder support › NAS 2m HULL-SAR trading system
- This topic has 343 replies, 42 voices, and was last updated 1 year ago by bege.
-
-
03/29/2021 at 6:44 PM #165666
I’ve been experimenting with a different way to control the cumulation of orders.
What I want is after it makes 2 entries, it can’t buy any more unless it averages down, ie can only buy below the existing positionprice, to a max of 5 in total.
This seemed to work, but today I had a situation where one position hit its target and closed, leaving 2 positions open. Then it opened 2 more positions (total of 4) even though it was well above the positionprice.
This is the code:
12345678910111213MaxPos = 2*positionsizeMaxPos2 = 5*positionsizeIF not longonmarket and CB THENBUY positionsize CONTRACT AT MARKETelsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos thenBUY positionsize CONTRACT AT MARKETelsif longonmarket and CB2 and close <positionprice and COUNTOFLONGSHARES < MaxPos2 thenBUY positionsize CONTRACT AT MARKETSET STOP %LOSS slSET TARGET %PROFIT tpENDIFENDIFShould line 8 be
1elsif longonmarket and CB2 and tradeprice <positionprice and COUNTOFLONGSHARES < MaxPos2 thenor is there a better way to do it ???
1 user thanked author for this post.
03/29/2021 at 7:31 PM #165670Shouldnt it be =< maxpos ?
< maxpos if maxpos is 2 has to be 1 right? Im probably missing something
03/29/2021 at 7:37 PM #165672If it opens 1 position, then that is still < 2, so it buys another. If it were <= then it would buy a 3rd position.
That part seems to be ok, it’s the maxpos2 (only buy if averaging down) that isn’t doing what it should.
03/29/2021 at 7:43 PM #165673I realised my mistake above, please ignore.
Also why not use positionperf instead of positionprice, maybe it works differently in cumulating orders
1elsif longonmarket and CB2 and positionperf < 0 and COUNTOFLONGSHARES < MaxPos2 then1 user thanked author for this post.
03/29/2021 at 7:47 PM #165675Yeah that could work – def worth trying.
03/29/2021 at 8:03 PM #165676Hmm, actually in backtest it makes no difference – exactly the same result as “close <positionprice” – also continues to open new positions above the the existing positionprice
03/29/2021 at 8:18 PM #165678Sorry I would test myself but im using work laptop.
Another idea is –
1elsif longonmarket and CB2 and (close<positionprice[1] or close<positionprice[2]) and COUNTOFLONGSHARES < MaxPos2 thenIm thinking once first position closes, the position price resets.
Im really interested in the solution too. Hope someone helps
03/29/2021 at 8:50 PM #165679Nice idea, but that also gives exactly the same result 🤔
Maybe has to be done using a Flag … ?
03/30/2021 at 7:32 PM #165771This seems to work, for anyone who’s interested:
123456789101112131415161718192021222324252627282930MaxPos = 2*positionsizeMaxPos2 = 5*positionsizeIF Not OnMarket THENFlag = 1Flag1 = 1Flag2 = 1Flag3 = 1ENDIF// Conditions to enter long positionsif tradetype=1 or tradetype=2 thenIF not longonmarket and CB and Flag THENBUY positionsize CONTRACT AT MARKETelsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos and Flag thenBUY positionsize CONTRACT AT MARKETFlag = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag1 thenBUY positionsize CONTRACT AT MARKETFlag1 = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag2 thenBUY positionsize CONTRACT AT MARKETFlag2 = 0elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag3 thenBUY positionsize CONTRACT AT MARKETFlag3 = 0SET STOP %LOSS slSET TARGET %PROFIT tpENDIFENDIF2 users thanked author for this post.
03/30/2021 at 8:23 PM #16577403/30/2021 at 8:56 PM #165776@Maik2404
Only post in the language of the forumthat you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.03/30/2021 at 9:24 PM #16577703/31/2021 at 8:59 AM #165796Here’s the itf
7 users thanked author for this post.
04/01/2021 at 7:41 AM #165905Thank you very much for your effort @nonetheless, this robot is actually amazing. By the way, I’ve been testing it on demo and real accounts since version 5.3 and yesterday the robot entered 5 long positions. Usually, when the price reaches the trailing SL triggering point, the positions are covered and the trailing starts to work. Nevertheless, yesterday after the entry of the 5 long positions, the price reached the SL triggering point but it did not trigger neither in real acc nor in demo acc, so I decided to close the positions manually before night for security as long as they were not covered by the trailing SL. Did somebody have the same problem?
In the backtests the positions opened yesterday seem to be still open, so it would be interesting if other users that have this robot working could check if the positions opened yesterday are properly covered by the trailing SL.
04/01/2021 at 7:49 AM #165906Which version are you referring to?
-
AuthorPosts
Find exclusive trading pro-tools on