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
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.
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
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.
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.
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
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
I agree, STRATEGYPROFIT could be a far better and easier solution!
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.
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
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
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).
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.