Average MFE/MAE snippet

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #166439 quote
    zilliq
    Participant
    Master

    Hi Guys,

    Does someone of you have an average MAE/MFE snippet as indicated on the backtests results ?

    Thanks and have a nice day

    #166456 quote
    nonetheless
    Participant
    Master

    no idea how you would code that, but you can always drag the results into Excel if you just want to know the averages.

    Or do you want to use that data as part of your strategy?

    #166457 quote
    Nicolas
    Keymaster
    Master

    Some examples about MAE/MFE calculation:

    MAE MFE code/indicator

    MAE and MFE calculator.

    MAE maximisation

    nonetheless thanked this post
    #166463 quote
    zilliq
    Participant
    Master

    Thanks @Nicolas

    But

    Link1 : Doesn’t work

    Link2 : It’s an indicator not in proorder

    Link3 : I will try

     

    @nonetheless

    Yes I want to try a filter based on

    Have a nice day Guys

    #166464 quote
    zilliq
    Participant
    Master

    The link3 with your code @Nicolas seems not to work

    Any ideas ?

    2021-04-08_09h35_54.jpg 2021-04-08_09h35_54.jpg
    #166467 quote
    Nicolas
    Keymaster
    Master

    It is a calculation in points, not in currency, I do not understand the comparison?

    #166475 quote
    zilliq
    Participant
    Master

    It’s in EUR/USD so 1 pip=10 USD easier to calculate and verify

    The problem seems to be when PRT calculate MFE

    As you see on the picture

    The abs perf (In this strategy) is 300 USD (Stop loss) and as you see on the strategyprofit curve its never higher of 300 USD (on this trade)

    But in the backtest result we have a MFE of 336 USD ???

    2021-04-08_10h21_20.jpg 2021-04-08_10h21_20.jpg
    #166480 quote
    zilliq
    Participant
    Master

    @Nicolas

    To try use a strategy on EUR/USD, put a stop/target at 300 USD

    Add

    graph (((high-positionprice)*pointvalue)*countofposition)/pipsize

    You will have a “band” between -300/+300 but a MFE higher ??

    Don’t understand why, or it’s a bug

    #166483 quote
    Nicolas
    Keymaster
    Master

    So

     (((high-positionprice)*pointvalue)*countofposition)/pipsize

    was the calculation you were looking for to compute the MFE for a long order, right?

    For the 336USD MFE, please share the code so I can replicate and find out why, thanks.

    #166516 quote
    zilliq
    Participant
    Master

    I will send you, but first, very often on a backtest MFE is a Zero

    A bug I see very often

    2021-04-08_12h40_05.jpg 2021-04-08_12h40_05.jpg
    #166519 quote
    zilliq
    Participant
    Master

    Try with this simple code for example:

    defparam cumulateorders=false
     
    //dummy strategy
    if rsi[14] crosses over 50 then
    buy 100000 contracts at market
     
    endif
     
    set stop ploss 25
    SET TARGET PPROFIT tg
    
     
    //increase the array index
    if not longonmarket and longonmarket[1] then
    index=index+1
    endif
     
    //compute the MFE
    if longonmarket then
    mfe = max(mfe,high-tradeprice)
    $mfeArray[index] = mfe
    endif
     
    //at least 10 orders to allow the average calculation
    if isset($mfeArray[2]) then
    sum=0
    for i = 0 to index do
    sum=sum+$mfeArray[i]
    next
    avg = sum/index
    endif
     
    graph avg
    

    On backtest results MFe and MAE  are generally Zero

    And when you have MFE it’s over the Target …

    Seems to have different bugs

    2021-04-08_13h00_04.jpg 2021-04-08_13h00_04.jpg
    #166526 quote
    zilliq
    Participant
    Master

    Another, problem, with the same code above

    With tg=41 for example

    If we add all MFE and divide py 8=number of trades, the results (Average MFE is 287.5)

    BUT if you see teh backtests results it gives 258.75 …

    2021-04-08_14h12_19.jpg 2021-04-08_14h12_19.jpg 2021-04-08_14h13_31.jpg 2021-04-08_14h13_31.jpg
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Average MFE/MAE snippet


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
zilliq @zilliq Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by zilliq
4 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/07/2021
Status: Active
Attachments: 6 files
Logo Logo
Loading...