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 - 1 through 15 (of 30 total)
  • #147183

    I’m using the following code to limit cumulative orders to a max of 8:

    but in practice (demo) the strategy is taking more than 8, see attached pic. Is there anything wrong with the above code?

    #147185

    I don’t know how your positionsize is calculated and how your countofposition usually evolves, but let’s say as an example you have abs(countposition)=7 ( is lower than 8) and positionsize is 3, the “if” statement will conclude that 7 being lower than 8 (and your other conditions being respected), it’s ok to add 3 to this, and 7+3=10…

    In other words, from quick read without the rest of the code, this piece of code is not preventing you from going above 8 at all, because you made your check before adding to the position, so I’d try with :    abs(countofposition)<maxpositionallowed-positionsize   to see there’s enough room left below the max before increasing the position

    1 user thanked author for this post.
    #147188

    I think line 3 could be written as:

     

     

    2 users thanked author for this post.
    #147189

    Thanks for that, but perhaps I am missing something. Surely countofposition and positionsize are 2 different things, no?

    In this case, positionsize is .4 on the DJ and I want to have a max of 8 different entries of .4 each. Would the MaxPositionsAllowed then need to be 3.2 ?

    #147190

    Yes, 3.2. I also had to think twice on DJI.

    #147193

    But how will that work with MM then? when the positionsize increases? Maybe

    ???

    #147194

    COUNTOFPOSITION is the number (negative for Short positions) of total positions accumulated so far, while PositionSize is the number of positions you want to trade at that very moment. After opening additional PositionSize contracts/shares, COUNTOFPOSITION will be increased by PositionSize units.

     

    #147206

    Sorry Roberto, if my positionsize = .4 and the strategy has cumulated 7 orders then the countofposition is 7  or 2.8 ?

    #147208

    2.8

     

    #147209

    Ok, so countofposition is actually the total number of contracts. In this case I would want that to max at 3.2 and if positionsize didn’t change then there’s no problem. But what happens when the MM  changes the positionsize? Is there no way of specifying the number of instances, rather than the number of contracts?

    #147211

    hi nonetheless

    Try this

     

    1 user thanked author for this post.
    #147212

    Hi Fifi, comment ca va?

    Do you mean

    #147217

    that is supposed to say

     

    #147220

    Why using ROUND()?

    MaxPositionsAllowed is a limit. If your current COUNTOFPOSITION is 7.4 and you wanna add 0.8 the code won’t allow that.

    Rounding that number will count it as 7, so you’ll be allow to add 0.8 PositionSize contracts, but doing this actually will raise COUNTOFPOSITION to 8.2, which is not what you asked with MaxPositionsAllowed.

     

    #147221

    Sorry, I just realized I misunderstood.

    You want MaxPositionsAllowed to set the number of times you open positions, no matter how large they are.

    In that case your code is correct.

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

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