Sliding Window Winrate

Forums ProRealTime English forum ProOrder support Sliding Window Winrate

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

    Hello altogether,

    for my strategy I want to reward the position size if the current winrate is above a certain value and punish otherwise.

    I have found the code to implement it over all trades that have been done so far with this:

    IF STRATEGYPROFIT> STRATEGYPROFIT[1] THEN
    WinningTrades = WinningTrades + 1
    ENDIF

    However, there are some bad “times” in the strategy which go unheard due to the bigger amount of positive trades. This is why I wanted to implement the sliding window approach.

     

    IF AllTrades > SlidingWindowWinRate THEN
    FOR runner = 1 TO SlidingWindowWinRate DO
    IF STRATEGYPROFIT[runner] < STRATEGYPROFIT[1 + runner] THEN
    WinningTradesSlidingWindow = WinningTradesSlidingWindow + 1
    ENDIF
    NEXT
    ENDIF

    So far I have learned that looping over STRATEGYPROFIT does not work due to obvious reasons ;). Has someone done that so far?

    Thanks in advance,

    Daniel

    #218576

    For others who want to achieve the same :

     

     

    #218581

    looping over STRATEGYPROFIT does not work due to obvious reasons

    You can loop over STRATEGYPROFIT values, just like a price consant or any other variables, but since it updates only when it has changes, the offset in brackets correspond to the bars offset from now, so there is no way to know how to get the last 10 changes just by making a loop “FOR I = 1 TO 10”

     

    1 user thanked author for this post.
    #218610

    Turns out that with my solution that I posted above,  I receive the following error if I want to run it in production/demo (not in backtest).

    … exceeds the limit of 1,000,000 in an array

    So I guess I start at square 1.

    How to either fix the broken array?

    How to calculate the sliding window winrate otherwise?

    Regards

    #218613
    JS

    Hi,

    You can try to start the code with resetting the array…

    UnSet($SlidingWindowTrades)

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