Moving Average Cross with RSI – 1% risk

Forums ProRealTime English forum ProBuilder support Moving Average Cross with RSI – 1% risk

  • This topic has 4 replies, 2 voices, and was last updated 10 months ago by avatarJS.
Viewing 5 posts - 1 through 5 (of 5 total)
  • #215707

    Hi team,

    I am hoping you can help – I wondered if someone was willing to cast an eye over my code. Fairly simple moving average cross with some ‘noise cancelling’ elements.

    Can I get this to calculate 1% risk of the account balance? I’d like to periodically update the value once or twice weekly to allow for compounding.

    I have attempted to do this, but my maths and intelligence have failed me – it blows up my account.

    Possible for someone more intelligent to take a look?

    #215726
    JS

    Hi @Mitchy14

    I haven’t gone through your code all the way, but I see that you are using the ATR to calculate your “ChandelierStopLong” and “ChandelierStopShort” and that is fine, but you also use it to calculate your position size:

    BuyPositionSize = floor(RiskAmount / (Close – ChandelierStopLong))

    So, you are going to divide a sum of money (RiskAmount) by a number that can basically take all values… (depending on the volatility).

    For example, if (Close – ChandelierStopLong) = 70 then your BuyPositionSize is 1250/70=17 contracts and at a value of 4 your position size becomes 1250/4=312 contracts… (it will blow up your account)

    1 user thanked author for this post.
    #215745
    JS

    You can also divide your capital risk directly by the ATR (position size depending on the ATR/volatility) and set certain conditions for the maximum and minimum position size, for example:

    Once MinPositionSize=1

    Once MaxPositionSize=10

    PositonSize = Risk / ATR14

    If PositionSize >= MaxPositionSize then

    PositionSize = MaxPositionSize

    ElsIf PositionSize <= MinPositionSize then

    PositionSize = MinPositionSize

    EndIf

    1 user thanked author for this post.
    #215758

    Hi JS,

     

    Thanks so much for your suggestions. You’ll notice I have updated the code.

    It doesn’t seem to amend the qty from 10 contracts (no matter what variables I amend).  As you know, I’d like this number to change depending on the ATR value.

    Again, I am sure it is something fairly simple, but I don’t seem to see it.

    Any suggestions would be welcome!

    #215765
    JS

    Hi @Mitchy14

    The ATR (volatility) in the calculation of your position size is always difficult because the volatility can fluctuate so much…

    Alternatively, you can try a different money management system with an (automatic) reinvestment of your winnings:

    RiskAmount = AccountBalance * (RiskPercentage/100)
    Margin = 5 / 100 (margin percentage for the major US indices)
    PositionSize = (RiskAmount + StrategyProfit) / (Close*Margin)

    And below you can of course have the “Position sizing check” performed…

Viewing 5 posts - 1 through 5 (of 5 total)

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