How to calculate only losing trades
Forums › ProRealTime English forum › ProOrder support › How to calculate only losing trades
- This topic has 8 replies, 3 voices, and was last updated 1 year ago by ZeroCafeine.
-
-
05/08/2023 at 2:17 PM #214292
Hi
How to calculate only the losing trades of a day without taking into account the gains of the winning trades of the same day:
12345678910111213TimeCondition = Time >= 080000 AND Time <= 170000IF Time =075500 THENLastStrategyProfit = StrategyProfitENDIFIF TimeCondition AND DayOfWeek = 1 THENDayProfit = StrategyProfit - LastStrategyProfitif DayProfit < 0 thenMondayLosses = DayProfitendifENDIFI feel that if I have gains during the day then my loss calculation is wrong
Best Reguards,
ZeroCafeine05/08/2023 at 2:21 PM #214293123If PositionPerf < PositionPerf[1] then// Count your losses. :-)endif1 user thanked author for this post.
05/08/2023 at 2:30 PM #214297tks you I will try it and post result,
and what this solution works if I am already in position before Monday, So I don’t want to include the gains and losses of the day before ?
05/08/2023 at 2:53 PM #21430012345678910Once PostionPerfYesterday = 0 // We have to start somewhere ... Very 1st time will be incorrect.If LastBarOfDay then // Determine LastBarOfDay yourself. FirstBarOfDay is fine too.PositionPerfYesterday = PositionPerfendifPostionPerfToday = PositionPerf - PositionPerfYesterday // Will be actual throughout the day.PositonPerfYesterday = 0// From here on use PositionPerfToday instead of PositionPerf.I think this could work. Not tested of course.
It it does not work you can make it work.1 user thanked author for this post.
05/09/2023 at 4:27 AM #214332Thanks for all your answers but I’m having a bit of trouble, how do I get the value of positionperf once the position is closed
05/09/2023 at 7:03 AM #214335Yes, I now see that I changed my example from something like PositionPerfToday = PositionPerfToday + xxxx into what I presented.
You can combine it with StrategyProfit.
I think that with these hints you can work it out yourself ? sure you can. You can write code so you can solve this. Maybe it takes a few hours, but you will learn from it again.
1 user thanked author for this post.
05/09/2023 at 8:04 AM #214337It took me several days to find a solution, and I have more or less found it, but I still have conflicts, so I’m asking again for another method
tks again 😊
05/09/2023 at 10:48 AM #214353PositionPerf returns the temp performance each bar, while on market. To tally the real loss you must wait for STRATEGYPROFIT to be updated (which occurs when a trade is closed).
To both count losing daily trades and their total loss (cleared every day) :
1234567891011121314151617ONCE LosingTrades = 0ONCE TotalLoss = 0IF IntraDayBarIndex = 0 THENLosingTrades = 0TotalLoss = 0ENDIFIF StrategyProfit < StrategyProfit[1] THENLosingTrades = LosingTrades + 1TotalLoss = TotalLoss + (StrategyProfit[1] - StrategyProfit)ENDIFIF close CROSSES OVER average[10,0](close) AND Not OnMarket THENBUY AT MARKETSET TARGET pPROFIT 50SET STOP pLOSS 20ENDIF//graph LosingTrades//graph TotalLoss1 user thanked author for this post.
05/09/2023 at 11:26 AM #214360@robertogozzi
And once again the alien has come through with a few lines of magic code, MerciI did almost a similar solution but a bit more complicated with more code (More complicated as a beginner), here is an excerpt, your solution seems much simpler and I had not thought to compare the StrategyProfit with StrategyProfit[1]
I’ll test this out in my head and come back to this post
1234567IF MoreMath = 0 THENDayProfitJPY = StrategyProfit - LastStrategyProfit // Unit : JPYENDIFIF MoreMath = 1 AND Flag = 0 THENDayProfitJPY = StrategyProfit - TodayStrategyProfit + DiffEntreeSortieJPY // Unit : JPYENDIFtks again for all 😊
-
AuthorPosts
Find exclusive trading pro-tools on