Hi colleagues,
Is there any way to measure the daily strategy profit of one code?? I would like to limit the daily operations to a certain strategy profit per day.
I thought that including a daily reseting paragraph would do it:
// STRATEGYPROFIT per day. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
stratprofit = 0
ENDIF
Is that even possible?? Any coding suggestions or links will be welcome
Thanks in advance
Juan
I would suggest:
// STRATEGYPROFIT per day. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
stratprofit = STRATEGYPROFIT //save the previous day Profit
ENDIF
IF (STRATEGYPROFIT - stratprofit) >= .... THEN //This will tell you current day's profit/loss
.
.
.
ENDIF
Hi Roberto,
It seems a very good solution. Many thanks for your help and your prompt response.
Juan
Hi Roberto,
This is part of the code where I have translated the info you gave me. I want to trade daily until either I get the daily profit of 20 pips or daily loss of 20 pips. After one of these two are achieved, I would like to stop operations until next day. DEFPARAM Flatbefore and Flatafter are set for 060000 and 200000.
I don’t know if you can measure strategy profit in pips or have to due in currency.
Thanks again,
// ONE TRADE PER DAY. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
nomoretrade = 0
ENDIF
// STRATEGYPROFIT per day. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
stratprofit = STRATEGYPROFIT //save the previous day Profit
ENDIF
// LONG Positions-Opening
// Alcistas
IF NOT LONGONMARKET AND cambiotendenciaalza AND nomoretrade = 0 THEN
BUY positionsize CONTRACT AT MARKET
SET TARGET pPROFIT profit3
ENDIF
// SHORT Positions-Opening
// Bajistas
IF NOT SHORTONMARKET AND vela10bajista AND nomoretrade = 0 THEN
SELLSHORT positionsize CONTRACT AT MARKET
SET TARGET pPROFIT profit1
ENDIF
// Finishing DAILY operations when reaching target profit/loss
IF (STRATEGYPROFIT-stratprofit)>=20*pipsize THEN //current day's profit
SELL AT MARKET
EXITSHORT AT MARKET
nomoretrade = 1
ENDIF
IF (STRATEGYPROFIT-stratprofit)<=-20*pipsize THEN //current day's loss
SELL AT MARKET
EXITSHORT AT MARKET
nomoretrade = 1
ENDIF
STRATEGYPROFIT only deals with money (https://www.prorealcode.com/topic/strategyprofit/#post-51298).
I think lines 27 and 33 are wrong, since the expression
20*pipsize
will convert Pips to price, i.e. DAX will be converted to 20 (unchanged due to the fact that Dax is over 10000 and has no decimal digits), EurUsd to 0.0020. Both of them have nothing to do with profit/loss.
With DAX it’s pretty easy to convert Euros into Pips, since each Pip is 25 euros (or 1 for mini contracts), so if you have Euro 750 profit it equals 30 pips. AS for currency pairs and other instruments it could not be as straightforward!
I have no knowledge of a way to work it out easily.
Hi Roberto,
Thanks. I got it. I like to monitor and control daily results and this piece of code is going to be very useful for my future coding.
Grazie mille,
Juan