code for limiting the number of cumulative orders

Forums ProRealTime English forum ProOrder support code for limiting the number of cumulative orders

Viewing 15 posts - 16 through 30 (of 30 total)
  • #147223

    but if the positionsize were 0.8 and it had cumulated 7 orders then countofposition would be 5.6 … so round(CountOfPosition/positionsize) = 6 and no more positions would be allowed.

    I would prefer if it could always max at 8 x positionsize, but less is better than more.

     

    #147235

    You’re right, it creates a conflict between positionsize and maxallowedorders. Illustrated in attached pic where I put startpositionsize at 0.2 and maxallowedorders at 1. It stops accumulating orders when positionsize reaches 1.

    Moderators, is it possible to get around this?

    #147238

    for me the fifi743 solution works well enough:

    I posted a new version of the NAS Hull-SAR with this change, tested with MM – seems ok, you can check it out. Haven’t tried changing the DJ version yet.

    #147309

    Hi nonetheless,
    Yes, I’m fine and you?
    I use COUNTOFLONGSHARES and COUNTOFSHORTSHARES .

    #147324

    hi Fifi, yes all good thanks. Haven’t died of Covid … yet.

    Unfortunately, as for this code, I just realised that your solution only works when the positionsize is close to 1

    In the above example, where MaxPositionsAllowed = 8, if positionsize = .4 then round(CountOfPosition/positionsize) <= MaxPositionsAllowed will allow 20 x .4 orders

    With positionsize = 2.5 it would only allow 3 orders.

    What I want is a max of 8 orders regardless of the size – something like MaxPositionsAllowed = (positionsize x 8) but i can’t have that.

    Any other ideas?

     

    #147330

    You could add a new variable to your code, starting it at zero, incrementing it by +1 at each new order (regardless of how much positionsize is), checking it’s not more than 7 in the “if” statement before each order (to reach 8 max), and reseting it equal to zero when not on market?

    1 user thanked author for this post.
    #147331

    You can only count trades anytime BUY or SELLSHORT is executed and stop when you reach your limit.

    Reset the count to zero when not on market or when it changes from long to short and viceversa in case of stop & reverse.

    1 user thanked author for this post.
    #147357

    If maxpositionsallowed is the total number of  operations (the name is confusing , position usually refers to the total amount of contracts or money opened, not number of operations) why dont you try this:

     

    1 user thanked author for this post.
    #147365
    J.

    If you want no more than 8 positions and your position size is 0.8 then the calculation should be

     

    CountOfPosition gives you the number of total contracts open. If you want to count short positions this becomes a negative number.

    You could also use COUNTOFSHORTSHARES and COUNTOFLONGSHARES for this though.

     

    1 user thanked author for this post.
    #147373

    Hi nonetheless,
    I’m on the DJI in 0.2 contract.
    Look at the attached pictures.

    #147389

    Thanks @J. – yes that is the obvious solution and it’s the first thing I tried but for some reason it went completely peculiar. Now it seems fine though, so apparently I had made some other error that was in conflict. I’ll have to watch it in forward testing to make sure it’s doing what i want.

    1 user thanked author for this post.
    #147395

    Look at the attached pictures.

    yes, in theory it looks like it should work but in practice, running Maxpositionsallowed =5 and positionsize .4 it opened 12 separate orders. I think MaxPositionsAllowed = n * positionsize could be the better way to go.

    1 user thanked author for this post.
    #147891

    Hola, ¿has conseguido limitar los pedidos? Ver el sistema de comercio HULL-SAR sigue haciendo más entradas

    Hello, have you managed to limit orders? See the HULL-SAR trading system keeps making more entries

    #147897

    @josef1604

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.

    Thank you 🙂

    #147917

    Hello, have you managed to limit orders?

    Yes, if you see the most recent version posted there it controls the number of entries.

    1 user thanked author for this post.
Viewing 15 posts - 16 through 30 (of 30 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login