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:
TimeCondition = Time >= 080000 AND Time <= 170000
IF Time =075500 THEN
LastStrategyProfit = StrategyProfit
ENDIF
IF TimeCondition AND DayOfWeek = 1 THEN
DayProfit = StrategyProfit - LastStrategyProfit
if DayProfit < 0 then
MondayLosses = DayProfit
endif
ENDIF
I feel that if I have gains during the day then my loss calculation is wrong
Best Reguards,
ZeroCafeine
If PositionPerf < PositionPerf[1] then
// Count your losses. :-)
endif
tks 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 ?
Once PostionPerfYesterday = 0 // We have to start somewhere ... Very 1st time will be incorrect.
If LastBarOfDay then // Determine LastBarOfDay yourself. FirstBarOfDay is fine too.
PositionPerfYesterday = PositionPerf
endif
PostionPerfToday = 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.
Thanks 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
Yes, 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.
It 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 😊
PositionPerf 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) :
ONCE LosingTrades = 0
ONCE TotalLoss = 0
IF IntraDayBarIndex = 0 THEN
LosingTrades = 0
TotalLoss = 0
ENDIF
IF StrategyProfit < StrategyProfit[1] THEN
LosingTrades = LosingTrades + 1
TotalLoss = TotalLoss + (StrategyProfit[1] - StrategyProfit)
ENDIF
IF close CROSSES OVER average[10,0](close) AND Not OnMarket THEN
BUY AT MARKET
SET TARGET pPROFIT 50
SET STOP pLOSS 20
ENDIF
//graph LosingTrades
//graph TotalLoss
@robertogozzi
And once again the alien has come through with a few lines of magic code, Merci
I 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
IF MoreMath = 0 THEN
DayProfitJPY = StrategyProfit - LastStrategyProfit // Unit : JPY
ENDIF
IF MoreMath = 1 AND Flag = 0 THEN
DayProfitJPY = StrategyProfit - TodayStrategyProfit + DiffEntreeSortieJPY // Unit : JPY
ENDIF
tks again for all 😊