Strategyprofit on fixed tp

Viewing 2 posts - 31 through 32 (of 32 total)
  • Author
    Posts
  • #211394 quote
    robertogozzi
    Moderator
    Master

    It’s not tricky to make calculations. Starting from 1 lot, which is the default lotsize, you simply have to decrement (or increment) it so that, the first time or when Capital < Capital[1] a new LotSize is used to get 1.01 Capital (Capital + 1%)  when a 1.5% TP is reached, which is repeated until Capital > Capital[1] and LotSize is restored to the default size.

    It’s tricky to spot any 1.5% increase in a single trade, before the Daily closing at 213000.

    Anyway this is a modified version with new calculations:

    // late lunch trade with money management system
     
    defparam cumulateorders = false
    //defparam flatafter      = 213000
     
    once Capital    = 10000
    once FirstCap   = Capital
    once Equity     = Capital
    once OrderSize  = 1
    once LotSize    = ordersize
    ONCE TP         = 1.5              //1.5%    Take Profit
    ONCE Mult       = 1                //1%      Capital Multiplier
    ONCE Dec        = 2                //1       number of decimal digits when rounding LotSize calculations
    //
    ONCE First      = 1
     
    td = opendayofweek >= 1 and opendayofweek <= 5
    tt = time = 133000
    c  = close > exponentialaverage[6](close)
    
    NewTrade = (LongOnMarket AND ShortOnMarket[1]) OR (LongOnMarket[1] AND ShortOnMarket) OR (OnMarket AND Not OnMarket[1])
    IF NewTrade THEN
    PriceX = TradePrice
    PC     = 0
    Diff   = 0
    First  = 0
    ENDIF
    
    IF StrategyProfit <> StrategyProfit[1] THEN
    Capital= FirstCap + StrategyProfit
    ENDIF
    
    IF StrategyProfit > StrategyProfit[1] THEN
    IF Capital > Equity THEN
    Equity  = Capital
    LotSize = 1
    First   = 0
    ELSE
    First   = 1
    ENDIF
    ELSIF StrategyProfit < StrategyProfit[1] THEN
    First = 1
    ENDIF
     
    If td and tt and c then
    IF First = 1 THEN
    LotSize = floor((Equity + (Equity * Mult / 100)) / (Equity + (close * TP / 100 * PipValue)),Dec)
    ENDIF
    buy lotsize contract at market
    endif
     
    set target %profit TP
    JohnScher thanked this post
    #212094 quote
    JohnScher
    Participant
    Veteran

    Thank you Roberto, thank you very much.

    I just got around to looking at your code today, but unfortunately it doesn’t do what it’s supposed to.
    It’s up to me to make it understandable to you what the code is supposed to do.
    So I’ll try it one more time, one last time, to bring in calm.

    The code should check after a trade if the capital is higher or lower than the ever reached maximum level of the capital.

    If so,
    we set the now reached (new) maximum level of the Capital as the new ever reached maximum level of the Capital (as a basis for calculation) and
    we continue the trade with lot size = 1

    If no,
    we calculate the lot size in such a way that when the take profit of the trade is reached, the ever reached maximum level of the capital increases by 1%. Because of the timestop, we will rarely reach the takeprofit of the trade, no problem. But if it is, all previous losses will be compensated and the capital will increase to 101%.

    Screenshot_1-2.jpg Screenshot_1-2.jpg
Viewing 2 posts - 31 through 32 (of 32 total)
  • You must be logged in to reply to this topic.

Strategyprofit on fixed tp


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
JohnScher @johnscher Participant
Summary

This topic contains 31 replies,
has 4 voices, and was last updated by JohnScher
2 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/07/2023
Status: Active
Attachments: 8 files
Logo Logo
Loading...