TRYING TO MAKE POSITIONSIZE DEPENDING OF STRATEGYPROFIT

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #72452 quote
    TempusFugit
    Participant
    Veteran

    Hi,

    I want to make the positionsize depending of the strategyprofit over/under its average. With something like this:

    IF STRATEGYPROFIT>AVERAGE[5000](STRATEGYPROFIT) THEN
    POSITIONSIZE = 2
    ELSE
    POSITIONSIZE = 1
    ENDIF

    It doesn´t work. Trying different ways and nothing, I am getting a little crazy about it. Anybody knows why?

    #72453 quote
    Vonasi
    Moderator
    Master

    Could it be that when you start strategy profit = zero and you then comparing that to an average of zero?

    TempusFugit thanked this post
    #72455 quote
    TempusFugit
    Participant
    Veteran

    Maybe you are right but in that case shouldn´t it affect only the first 5000 candles (the periods of the avegarage)

    Anyway I will try to take that in consideration and will see

    Thanks Vonasi

    #72459 quote
    Vonasi
    Moderator
    Master
    #72460 quote
    robertogozzi
    Moderator
    Master

    Try adding

    graph strategyprofit
    graph average[5000](strategyprofit)

    to your strategy, provided you have PreLoaded enough bars.

    I tried and it always shows the same value, so I guess it is not allowed, though syntax is correct!

    #72463 quote
    Vonasi
    Moderator
    Master

    I put this in a code and it gave me graph lines.

    sp = strategyprofit
    spave = Average[5000](sp)
    Graph sp
    graph spave
    #72464 quote
    TempusFugit
    Participant
    Veteran

    Yes, I saw it before asking and I didn´t find nothing to help me. But I see now in the replays a couple of people comment that it doens´t seem to work, Nicholas says it will take it to the PRT people. This is more than two years ago, I guess it doesn´t work yet, it´s a shame it really looked like a nice way to avoid big losses with systems go bust

    I found this topic that contains other ways to get the same idea, just seemed more complicated, I liked the simplicity of the strategyprofit average 🙁

    Position Size Management – Performance based increases

    #72467 quote
    Vonasi
    Moderator
    Master

    Try my code in post #72463. It appears the issue is having StrategyProfit in the average calculation. If it is a variable it works.

    #72468 quote
    Vonasi
    Moderator
    Master

    So your code should be:

    sp = strategyprofit 
    spave = Average[5000](sp)
    
    IF STRATEGYPROFIT > spave THEN
    POSITIONSIZE = 2
    ELSE
    POSITIONSIZE = 1
    ENDIF

    Not tested yet.

    TempusFugit thanked this post
    #72469 quote
    Vonasi
    Moderator
    Master

    You should be aware that StrategyProfit is only updated when positions are closed so if you have an accumulating positions strategy then if it starts with the equity curve above the average and then you keep adding to a losing position it will add positionsizes of 2 continually as it will not be aware that your floating equity curve is below the average of the equity curve.

    #72470 quote
    TempusFugit
    Participant
    Veteran

    I had the same idea about the variables and was trying… I had to do it a couple of times because I thought I did something wrong… no operations at all!!! It seems something is really wrong with this thing of the average/strategyprofit

    #72471 quote
    TempusFugit
    Participant
    Veteran

    No accumulated positions in this system

    #72472 quote
    Vonasi
    Moderator
    Master

    That is strange because I just threw it into a rubbish strategy and it works for me. Graphed line is positionsize.

    Screenshot_2-1.png Screenshot_2-1.png
    #72475 quote
    Vonasi
    Moderator
    Master

    …and the strategyprofit and strategyprofit average

    Screenshot_3.png Screenshot_3.png
    #72478 quote
    TempusFugit
    Participant
    Veteran

    Yes, Vonasi, you are right, using your code it seems to work.

    I think I have nailed where is the key, is using a variable in the subject of the average so…

    Average[5000](strategyprofit) --> NO work
    
    Average[5000](sp) --> YES work

    so we don´t need the average variable, just this seems to work…

    sp = StrategyProfit
    
    IF strategyprofit > Average[5000](sp) THEN
    POSITIONSIZE = 2
    ELSE
    POSITIONSIZE = 1
    ENDIF

    Strange but the important thing is that the problem is solved

    Thank you

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

TRYING TO MAKE POSITIONSIZE DEPENDING OF STRATEGYPROFIT


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 16 replies,
has 4 voices, and was last updated by GraHal
7 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/06/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...