NAS 2m HULL-SAR trading system

Viewing 15 posts - 211 through 225 (of 344 total)
  • Author
    Posts
  • #165666 quote
    nonetheless
    Participant
    Master

    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:

    MaxPos = 2*positionsize
    MaxPos2 = 5*positionsize
    
    IF not longonmarket and CB THEN
    BUY positionsize CONTRACT AT MARKET
    elsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos then
    BUY positionsize CONTRACT AT MARKET
    elsif longonmarket and CB2 and close <positionprice and COUNTOFLONGSHARES < MaxPos2 then
    BUY positionsize CONTRACT AT MARKET
    SET STOP %LOSS sl
    SET TARGET %PROFIT tp
    ENDIF
    ENDIF

    Should line 8 be

    elsif longonmarket and CB2 and tradeprice <positionprice and COUNTOFLONGSHARES < MaxPos2 then

    or is there a better way to do it ???

    Midlanddave thanked this post
    #165670 quote
    Monochrome
    Participant
    Senior

    Shouldnt it be =< maxpos ?

    < maxpos if maxpos is 2 has to be 1 right? Im probably missing something

    #165672 quote
    nonetheless
    Participant
    Master

    If 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.

    #165673 quote
    Monochrome
    Participant
    Senior

    I realised my mistake above, please ignore.

    Also why not use positionperf instead of positionprice, maybe it works differently in cumulating orders

    elsif longonmarket and CB2 and positionperf < 0 and COUNTOFLONGSHARES < MaxPos2 then
    nonetheless thanked this post
    #165675 quote
    nonetheless
    Participant
    Master

    Yeah that could work – def worth trying.

    #165676 quote
    nonetheless
    Participant
    Master

    Hmm, 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

    #165678 quote
    Monochrome
    Participant
    Senior

    Sorry I would test myself but im using work laptop.

    Another idea is –

    elsif longonmarket and CB2 and (close<positionprice[1] or close<positionprice[2]) and COUNTOFLONGSHARES < MaxPos2 then

    Im thinking once first position closes, the position price resets.

    Im really interested in the solution too. Hope someone helps

    #165679 quote
    nonetheless
    Participant
    Master

    Nice idea, but that also gives exactly the same result 🤔

    Maybe has to be done using a Flag … ?

    #165771 quote
    nonetheless
    Participant
    Master

    This seems to work, for anyone who’s interested:

    MaxPos = 2*positionsize
    MaxPos2 = 5*positionsize
    
    IF Not OnMarket THEN
    Flag = 1
    Flag1 = 1
    Flag2 = 1
    Flag3 = 1
    ENDIF
    
    // Conditions to enter long positions
    if tradetype=1 or tradetype=2 then
    IF not longonmarket and CB and Flag THEN
    BUY positionsize CONTRACT AT MARKET
    elsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos and Flag then
    BUY positionsize CONTRACT AT MARKET
    Flag = 0
    elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag1 then
    BUY positionsize CONTRACT AT MARKET
    Flag1 = 0
    elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag2 then
    BUY positionsize CONTRACT AT MARKET
    Flag2 = 0
    elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag3 then
    BUY positionsize CONTRACT AT MARKET
    Flag3 = 0
    SET STOP %LOSS sl
    SET TARGET %PROFIT tp
    ENDIF
    ENDIF
    Monochrome and Midlanddave thanked this post
    #165774 quote
    Maik2404
    Participant
    Veteran

    Wo muss ich den Eintrag in den Code einfügen bzw. gegen was ersetzen?Where do I have to insert the entry in the code or replace it with what?

    #165776 quote
    robertogozzi
    Moderator
    Master

    @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.

    #165777 quote
    Maik2404
    Participant
    Veteran

    Where do I have to add the entry in the code or replace it with something?

    #165796 quote
    nonetheless
    Participant
    Master

    Here’s the itf

    Ryugin, Fabien6658, GraHal and 4 others thanked this post
    #165905 quote
    Ryugin
    Participant
    Senior

    Thank 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.

    #165906 quote
    nonetheless
    Participant
    Master

    Which version are you referring to?

Viewing 15 posts - 211 through 225 (of 344 total)
  • You must be logged in to reply to this topic.

NAS 2m HULL-SAR trading system


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 343 replies,
has 42 voices, and was last updated by bege
3 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/09/2020
Status: Active
Attachments: 129 files
Logo Logo
Loading...