Is this performance chart of this strategy look good?

Viewing 15 posts - 31 through 45 (of 55 total)
  • Author
    Posts
  • #239744 quote
    Marco
    Participant
    New

    If I interpret it correctly, it is possible a kind of Martingale system where you increase your position after a loss?

    Yes, WingYip can hopefully confirm that he buys extra after a loss – I read that too but it could be a typo.

    Btw, this is not necessarily Martingale as I just typed a post for this thread (not posted) where I kind of see and show the similarities with what I do myself, and this includes increasing after a loss – and NOT after a win. And this is not a Martingale system at all.

    So WingYip – curious ! 🙂

    To me the only reason to buy extra when loss is only to find the best reason to reinvest the reasonable little to make the system can carry on reinvest, nothing special, it could add the extra when you win, but in my case, if add extra when win then the system will fail very quickly because it will adding too many or say reinvest too many without blance, so it is just to find the best excuse to reinvest when the system earn, that’s all. Example it can be anything such as when xyz happen then add %. etc. Otherwise just use the none MM vision.

    PeterSt thanked this post
    #239745 quote
    Marco
    Participant
    New

    May be one important thing I didn’t make it clear is this system would only trade one at a time

    If nolongommatket then

    #239747 quote
    JS
    Participant
    Senior

    Thank you for the explanation…

    #239748 quote
    PeterSt
    Participant
    Master

    To me the only reason to buy extra when loss is only to find the best reason to reinvest the reasonable little to make the system can carry on reinvest, nothing special, it could add the extra when you win, but in my case, if add extra when win then the system will fail very quickly because it will adding too many or say reinvest too many without blance,

    Exactly that.
    (I am reluctant to post my posting because I don’t want to distract from your great stuff)
    And thank you for being and sharing a great mind.

    #239840 quote
    Marco
    Participant
    New

    as long as the core system is a overall winner, the money management is a bonus, you can add this code to make sure the system never invest more than your capital, so the system would never stop just because of not enough fund, but again it only base on the core system is a overall “winner”. the leverage 20 is only for IG/ NASDAQ,  you need to use the correct leverage for others.
    not a great help compere to all others in here.

    once capital = 88888
    // Update capital after each trade based on last trade performance
    if strategyprofit <> strategyprofit[1] then
    capital = capital + (positionperf(1) * positionsize)
    endif
    
    // Calculate the maximum allowable position size based on capital, close price, and leverage
    maxPositionSize = capital / (close / 20)  // Correctly applying leverage
    
    // Ensure position size does not exceed available capital
    if positionsize > maxPositionSize then
    positionsize = maxPositionSize * 0.99   // Limit position size to 99% of maximum allowable size
    ENDIF
    GraHal thanked this post
    #239841 quote
    JS
    Participant
    Senior

    Hi @WingYip

    “PositionPerf(n)” is a ratio between the return of the position and its purchase cost. To convert “PositionPerf(n)” into a cash value, you need to multiply it by the purchase price (PositionPrice[n])…

    When you further multiply by “PositionSize,” keep in mind that this calculation refers to a closed position. Currently, “PositionSize” is either zero (Not OnMarket) or corresponds to a newly opened position, but it is never equal to the previous (closed) position size…

    #239842 quote
    Marco
    Participant
    New

    Thank you for your comment, I could be incorrect that PositionPrice(n) is used to track profit or loss in absolute terms based on the specific entry price. However, if you only need the result in percentage terms and already have PositionPerf(n), then PositionPrice(n) is unnecessary, as you can simply use PositionPerf(n) * PositionSize to get the cash value.
    PositionSize would be whatever is in your code you set up + any money management to increases it. and this code is only for money management, therefore the PositionSize would never happen in zero (well, at less in my case), otherwise without money management, this code is unnecessary.

    #239843 quote
    JS
    Participant
    Senior

    A PositionPerf(n) * PositionSize does not give a “cash” value…
    PositionPerf(n) is a ratio, for example, in the form of 0.001…

    #239844 quote
    JS
    Participant
    Senior

    A leverage of 20 is not only for the Nasdaq but for most major indices (Nasdaq, Dow Jones, S&P500, DAX, …)
    IG usually refers to a “Margin of 5%”  (1/20 leverage = 5% margin)…

    #239845 quote
    Marco
    Participant
    New

    for my understanding is that, let say the last trade open at 19876 and it close at 20123

    To calculate PositionPerf(1) based on this example, let’s determine the performance of the position as a ratio.

    1. Determine the Profit or Loss:
      • Open Price: 19876
      • Close Price: 20123
      • Profit: Close Price – Open Price

    2. Calculate the PositionPerf(1):
      • PositionPerf(1) is typically calculated as the profit (or loss) divided by the open price.

      PositionPerf(1)=Profit​/Open Price=247/19876=0.01242

      • In percentage terms, this would be approximately 1.24%.

    Summary:

    • PositionPerf(1) for this trade would be about 0.01242, or 1.24%. This value reflects the return on the investment based on the opening price of the trade.
    • If multiply this by the PositionSize, you’ll get the cash amount earned from that trade.

    So, in my code, using PositionPerf(1) * PositionSize should yield the correct cash value based on this performance ratio.

    #239846 quote
    JS
    Participant
    Senior

    Suppose your “PositionSize” is equal to 3 contracts; according to your calculation, you get a “cash” value of: 0.01242 * 3 = 0.03726, and you’re going to add this amount to your “Capital”…?

    #239847 quote
    Marco
    Participant
    New

    think your positionPrice comment is correct

    JS thanked this post
    #239864 quote
    robertogozzi
    Moderator
    Master

    JS is right, PositionPerf is just a multiplier of PositionPrice (to get the % you need to multiply it by 100). Multiply the result by PipValue to get the money gained/lost.

    PositionPerf  = (Close / PositionPrice) – 1, i.e. 1000 / 1010 gives 0.0990100 (i.e. 9.901%), then you have to multiply it by PipValue, because Close / PositionPrice is the same multiplier, say, for Dax €1, Dax €5 and Dax €25, what makes a difference is PipValue (the value of each Pip: 1, 5 or 25 euros).

    #239872 quote
    Marco
    Participant
    New

    this should work

     

    once capital=8888
    if strategyprofit <> strategyprofit[1] then
    capital = capital + (strategyprofit - strategyprofit[1])
    endif
    // Calculate the maximum allowable position size based on capital, close price, and leverage
    maxPositionSize = capital / (close / 20) // Correctly applying leverage
    // Ensure position size does not exceed available capital
    if positionsize >= maxPositionSize then
    positionsize = maxPositionSize * 0.99 // Limit position size to 99% of maximum allowable size
    ENDIF
    #239874 quote
    JS
    Participant
    Senior

    StrategyProfit[1] is equal to the StrategyProfit of the previous BAR… (not the profit or loss of the previous closed position).

    robertogozzi thanked this post
Viewing 15 posts - 31 through 45 (of 55 total)
  • You must be logged in to reply to this topic.

Is this performance chart of this strategy look good?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marco @wingyip Participant
Summary

This topic contains 54 replies,
has 11 voices, and was last updated by coincatcha
11 months, 4 weeks ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/28/2024
Status: Active
Attachments: 27 files
Logo Logo
Loading...