DAILY Reseting postionperf to ZERO.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #56916 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi all,

    I am trying to find the way to reset the function positionperf(n) to one day. If one day I have two losing operations, positionperf(1)<0 and positionperf(2)<0, I want the next day this function to be reset it to (1) again.

    Verdi55 showed me one way playing with the bar index, but I don’t get it, and I wondered if there is another way to reach this.

    Thanks,

    Juan

    #56917 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I think POSITIONPERF cannot be reset, it can only be affected by trades.

    You should use a variable and reset it each day, and update it at each new trade that is closed. It should not be straightforward, though.

    Juan Salas thanked this post
    #56919 quote
    Juan SalasJuan Salas
    Participant
    Master

    Roberto,

    Many thanks. Verdi55 found this original way but I don’t have it very clear:

    diffTiBi = barindex - tradeindex
    diffTiBi1 = barindex - tradeindex(2)
    
     
    IF (positionperf(1)<0 and date[diffTiBi] = date and (not onmarket)) OR (positionperf(1)<0 and date[diffTiBi1] = date and onmarket) THEN
    positionsize=1
    ENDIF
    #56922 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Yes, that’s something I was thinking about.

    I will not be of any help for a few days, though and cannot test/write  any code.

    Try to study and test that code snippet.

    Let us know if you could find a solution worth while being shared.

    #56923 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Actually any solution is worth while being shared, if it’s good anyone can learn from it, if it’s a bad one the author could benefit from improvements and suggestions by members.

    #56926 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi Roberto,

    You are right. These days are to disconnect a bit from the codes 🙂

    I think I will take these days to work on this and will post the results.

    Many Thanks and Happy and prosperous 2018.

    Juan

    #56943 quote
    GraHalGraHal
    Participant
    Master

    Wouldn’t it be easier to use StrategyProfit?

    Record StrategyProfit and day / date then keep subtracting yesterdays StrategyProfit to start at zero again for each new day … or something similar? (My brain not woke up yet, coffee not got through! and I’ve not even been celebrating New Year! :))

    https://www.prorealcode.com/documentation/strategyprofit/

    GraHal

    #56951 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I agree, STRATEGYPROFIT could be a far better and easier  solution!

    #56959 quote
    GraHalGraHal
    Participant
    Master

    Hey Roberto, your words below are so good and true that you should add them under your Profile pic!? 🙂

    Any solution is worth sharing
    If good, we can all learn from it
    If bad, solution / author benefits from improvements and suggestions by members. 

    robertogozzi and MaoRai54 thanked this post
    #57082 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Juan Salas, I tried to implement GraHal‘suggestions, first you can write:

    ONCE MyProfit = 0
    IF IntraDayBarIndex = 0 THEN   //At each new day save current strategyprofit
      MyProfit  = StrategyProfit
    ENDIF

    At a later moment, when your, say, BUY conditions are met you can write:

    IF My_Conditions AND (StrategyProfit >= MyProfit) THEN //only BUY if no losses occurred
       BUY ....
    ENDIF
    Juan Salas thanked this post
    #57084 quote
    Juan SalasJuan Salas
    Participant
    Master

    Hi Roberto,

    I think your solution above is more directed to monitoring daily operations through their dailyprofit. I don’t know if that can apply to what I am trying to get.

    I am working with different types of Martingale, and although no filter may “soften” the unexpected and statistically proven drop of the Martingale, I am trying different approaches.

    Example: I have a system that operates 3-4 times a day. Lets say I have 4 losing operations that day, and I want to apply a DAILY martingale. It means positionsize=1, 2, 4 and 8. Next day I want to start in positionsize=1. RIGHT NOW, each day starts as a continuation of the past day, in this case it starts with positionsize= 16.

    It is tricky, since positionperf(n) doesn’t differentiate past performances by dates, so it doesn’t matter if the last and losing operation was three days ago, it still counts as positionperf(1)<0.

    My intention is contain the Martingales within certain periods of time to avoid escalation (days and even periods of three-four hours). Probably, it may not work, but I want to know how to do it.

    In any case, thanks so much for your approach.

    Juan

    #57257 quote
    verdi55verdi55
    Participant
    Veteran

    Try to count the number of positions that you have openend every day. For example, set a parameter np to 0 every day at 0:00. When you open a new position, increase np by 1.

    Then you can consider positionperf only for the number that np is currently showing.

    For example, when np is 2, and a position is open, you consider only positionperf and positionperf(1). When no position is open, you consider only positionperf(1) and positionperf(2).

    robertogozzi and Juan Salas thanked this post
    #57266 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Try to count the number of positions that you have openend every day. For example, set a parameter np to 0 every day at 0:00. When you open a new position, increase np by 1. Then you can consider positionperf only for the number that np is currently showing. For example, when np is 2, and a position is open, you consider only positionperf and positionperf(1). When no position is open, you consider only positionperf(1) and positionperf(2).

    Great idea, if NP = 0 you know positionperf(1) refers to previous days, if not then it reports today’s data. And you can easily reset it daily when IntrayDayBarIndex = 0.

    Juan Salas thanked this post
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

DAILY Reseting postionperf to ZERO.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 12 replies,
has 4 voices, and was last updated by robertogozzirobertogozzi
8 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/30/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...