Increase position size x % after winning trade

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #132718 quote
    clemnet
    Participant
    New

    Hi all newbie looking for some help as am learning the ProOrder ropes.

    I have read the manual and have some very simple code tested and working  –

    // Conditions to enter long positions
    c1 = (RSIind < 30)//RSI upward momentum
    
    // Conditions to enter long positions
    IF NOT LongOnMarket AND c1 THEN
    BUY 1 CONTRACTS AT MARKET
    Set target pprofit TP
    SET STOP pLOSS SL
    ENDIF
    
    TP =30
    SL =100

    I am trying to work out how to increase the position size but only after a winning trade – I want to increase it by 20% i.e x 1.2

    So if trade at 1 pp hits profit target and closes, the next position is at 1.2 pp, then 1.44, then 1.73 and so on. Position size to stay the same after a losing trade has closed.

    I had a look at martingales etc and tried to reverse that, but cannot work it out. Any ideas?!

    Thanks

    #132724 quote
    clemnet
    Participant
    New

    I have been thinking about this a bit more and think I can explain it better, by removing IF NOT LongOnMarket – i.e I want the position to open whether I am long or not.

    I want to open the position size 1 when RSI < 30. If next candle is still <33 another position opens sized 1, and again sized 1 etc until either RSI > 30 or target profit hit (+30), or stop hit (-100).

    So if three candles are RSI < 30 I will have a total position size of for example 3 @ 98, but entry point might be 1 @ 99, 1 @ 98, 1 @ 97.

    What I am trying to achieve is

    • have the target and stop + 30 & – 100 from 98, rather than 99, 98 and 97.
    • If RSI rises above 30, and positions are open and then RSI reaches < 30 I want the new positions to open at the same size the sequence started – i.e in this case 1
    • If positions are closed in winning trade, next open position I want to be 20% higher = i.e 1.2, and that sequence to continue.
    • If positions are closed in losing trade, next open position I want to be the same size as the the start of the sequence that was the losing trade.

    Does that make sense, and if so is it possible?

    Thanks!

    #132733 quote
    robertogozzi
    Moderator
    Master

    Code from your first post:

    ONCE LotSize  = 1
    ONCE PereCent = 1.2
    ONCE TP       = 30
    ONCE SL       = 100
    IF StrategyProfit > StrategyProfit[1] THEN
       LotSize = LotSize * PerCent
    ENDIF
    // Conditions to enter long positions
    c1 = (RSIind < 30)       //RSI upward momentum
    // Conditions to enter long positions
    IF NOT LongOnMarket AND c1 THEN
       BUY LotSize CONTRACTS AT MARKET
       Set target pprofit TP
       SET STOP   pLOSS   SL
    ENDIF
    clemnet thanked this post
    #132743 quote
    clemnet
    Participant
    New

    Hi thanks, but could not get that to work. Noticed the ‘perecent’ typo, and corrected it. Code is accepted but when I test it, it seems like it opens a position but never shuts it. Results re trades are N/A

    Strategy profit pointer is helpful thanks, I will have a closer look at the manual re that.

    #132745 quote
    clemnet
    Participant
    New

    I think Strategy Profit only the profit of the system overall? I am trying to increase position size if previous trade was profitable.

    #132746 quote
    GraHal
    Participant
    Master

    I am trying to increase position size if previous trade was profitable.

    You need to use PositionPerf(n) where n = 0 if no current open positions or n = 1 if there is a position open and you want the performance of the previous trade.

    clemnet thanked this post
    #132768 quote
    robertogozzi
    Moderator
    Master

    It never exits until you tell it to properly. This would be fine on Dax, Sp500 or the like, where pips are 1:1 with price, it’ll not work on fx pairs where that ratio is 10000:1.

    Aleays use PipSize to multiply values at lines 3-4.

    STRATEGYPROFIT is what you need, it returns the whole strategy report, when a trade is closed, comparing the current value against the previous one will tell you if any trade has been closed and if it was profitable or not.

    POSITIONPERF only returns, in percentage, not money, the status of a current position, which can be profitable at times but could be losing in the end.

    #132773 quote
    clemnet
    Participant
    New

    Apologies, should have specified I am testing with Spot Gold.

    #155178 quote
    s00071609
    Participant
    Senior
    Once TradeON = 1
    Once count1   = 0
    If IntraDayBarIndex = 0 then
    TradeON = 1
    Count1   = 0
    Endif
    If StrategyProfit < StrategyProfit[1] then
    Count1 = Count1 + 1
    positionsize=positionsize * 0.5
    Elsif StrategyProfit > StrategyProfit[1] then
    positionsize=positionsize*1.25
    Count1 = 0
    Endif
    If Count1 >= 5 then
    TradeON = 0
    Endif
    
    
    
    
    
    
    IF  NOT SHORTONMARKET And Entry and tradeon and (gobuy or (gobuy[1] ))  THEN
    
    BUY Positionsize CONTRACT AT MARKET
    set stop Loss sl
    //set target $profit 50
    
    ENDIF

    I was trying to limit trading for the day once 5 consequetive losses are hit. Also trying to reduce position size if previous trade lost and increase it when previous trade won. This code does not seem to be doing anything. My cumulative order is true. Any help would be great

    #155179 quote
    robertogozzi
    Moderator
    Master

    I am not able to test it now, but code seems logically correct.

    What does “This code does not seem to be doing anything” mean? Doesn’t it open any trade? Doesn’t it increase/decrease position size?  Doesn’t it stop trading after 5 consecutive losses?

    #155180 quote
    Vonasi
    Moderator
    Master

    You don’t declare the starting value of positionsize so it is buying zero contracts.

    #155183 quote
    s00071609
    Participant
    Senior
    equity = Capital + StrategyProfit
    maxrisk = round(equity*Risk)
    PositionSize = abs(((maxrisk/SL)/PointValue)*pipsize)
    
    if tradeprice(1+n)>0 then
    n=n+1
    endif

    The above code is calculating the positionsize.

    Its not doing anything means, with or without code the result is same. Its neither increasing or decreasing size . The TradeOn part to not trade after few losses does not do anything as well

    #155215 quote
    robertogozzi
    Moderator
    Master

    The issue is at line 9, as you halve PositionSize, it will become less than the minimum size required, change it to:

    positionsize=max(0.5,positionsize * 0.5)  //Min. size=0.5 or greater
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

Increase position size x % after winning trade


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
clemnet @clemnet Participant
Summary

This topic contains 12 replies,
has 5 voices, and was last updated by robertogozzi
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/21/2020
Status: Active
Attachments: No files
Logo Logo
Loading...