Wanted: small code snippet for reinvestment

Forums ProRealTime English forum ProOrder support Wanted: small code snippet for reinvestment

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

    Can you put the much more better version in the library post?

    #57173

    and before try with TP 2.4% maybe

    #57182

    A quick optimization seems to show that holding out for more profit is better than cutting it down to 2.4%. Around 3.75% has been the optimum over the test period that I am able to test on. Less trades obviously but far more profitable and hit rate very similar.

    I’ll post it in the library post for you with that setting.

     

    #57228

    Position opened by this strategy on my demo account this morning. Seems to be going well but then again so are all my DAX long strategies in this new year start rally!

    #57255

    The code I’m using for reinvestment in DAX is the following :

    It also considers the gain or loss of currently open positions, whereas strategyprofit alone only considers closed positions.

    n is the number of contracts you are going to buy or sellshort.

    Thus, when “gain” is set to 500, the system will open one additional contract for every 500 Euros earned.

    #57256

    The last three lines limit the maximum number of contracts. When this limit is reached, growth will stop, as you cannot trade, e.g. 20.000 DAX mini contracts in one lot.

    The code is to be used with care, as it is very easy to become rich quickly on paper using an optimized backtest, but reality will look very different.

    #57258

    I think you may have typed an error in the code

     

    1 user thanked author for this post.
    #57261

    True. I deleted one bracket too much from a more complex code, sorry.

    The correct code for this line is :

     

    number= 1 + ((SP + pp * pprice * ABS(cp)) / gain)

    So, once again, the complete snippet :

    I hope there are no more errors.

     

    #57269

    Thanks for sharing that (now corrected!) code verdi55. I think I still prefer the gradual increasing of position size as profits are actually banked rather than increasing  position size based on a profit that could just as easily disappear and leave us with too small a real bank to cope with all the big bets that we opened based on money that we didn’t actually have. I’m sure your money management strategy would lead to bigger profits but unfortunately bigger profits from bigger risk. Nothing in life is free.

    At the end of the day StrategyProfit is a fantasy number anyway as it fails to take into account fees – so it is best to stop a strategy every now and then and reset the starting capital number to bring everything back into the real world.

    #57282

    Vonasi, when you switch a long to a short position in the same bar, for example, you may want to take the gain of the currently open position into account. Strategyprofit, in this case, only calculates with the previous closed position, but not with the currently open long position that is to be switched to short ! When the long position is closed, the gain is fixed and in your account in this moment. But in strategyprofit, the gain appears  only at the end of the next bar, not in this one, when the position is to be closed and the next short position with a new position size is to be opened !

    Also, strategyprofit takes into account all fees (spread and brokerage), with the exception of overnight fees, as far as I see it.

    #57283

    I had not thought of that but then again I don’t have any strategies running at the moment that would immediately close a position and enter in the opposite direction – but I’ll certainly bear it in mind now if I ever do.

    With the DFB spread betting that I do the the overnight fees (and it was these fees that I was meaning) can make quite some difference between StrategyProfit and the real world. We also have to consider the addition and deduction of dividend payments on indices.

    #57284

    Deduction of dividend payments is an interesting issue. For DAX, as it is a performance index, I think there are no such adaptations. I know that the Nikkei at IG markets is regularly corrected for dividends. But how about other indices ? DOW, NASDAQ 100, S&P 500 ? Dow Jones and NASDQ 100 are price indices, but S&P 500 is a performance index. So, is there no correction for dividends in S&P 500, but in the two others, there is one ?

    #57285
    #57290

    Not read those links yet but a quick check back through my account shows dividend adjustments on US500, Wall Street, Spain 35,Techmark, EU Stocks50 and FTSE100. I’ve not traded every index overnight though! Then there are the many commodity overnight base adjustments that need to be considered too.

    #57291

    Just checked your links and that reminded me that I receive a weekly ‘The week ahead’ email from IG and in it there is a link that takes you to a page with the attached image in it.

    https://www.ig.com/uk/week-ahead

Viewing 15 posts - 16 through 30 (of 69 total)

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