Hi everyone,
The idea is simple and here are the rules :
– Counting losses per day
– If my loss is more than 10 per day then I stop trading for the day
– If my loss is more than 40 per week then I stop trading for the week
IF IntraDayBarIndex = 0 THEN
LastStrategyProfit = StrategyProfit // Store last value of StrategyProfit
ENDIF
DayProfit = StrategyProfit - LastStrategyProfit
IF Day = 1 THEN
MondayProfit = DayProfit
ELSIF Day = 2 THEN
TuesdayProfit = DayProfit
ELSIF Day = 3 THEN
WednesdayProfit = DayProfit
ELSIF Day = 4 THEN
ThursdayProfit = DayProfit
ELSIF Day = 5 THEN
FridayProfit = DayProfit
ELSIF Day = 7 THEN
MondayProfit = 0
TuesdayProfit = 0
WednesdayProfit = 0
ThursdayProfit = 0
FridayProfit = 0
ENDIF
So you are calculating the loss in money and creating condition upon all these variables? Can you share an example for reference and for the benefit of other users please? 😉
The aim is to integrate the rules on this code, We will call this idea of Money management idea B, you can participate or propose another idea on this post
maybe we can create a boolen TradeOnOff for use it as a filter, somethink like this :
IF DayProfit < (-1)*10 THEN
TradeOnOff = 0
ENDIF
If LongCondition AND TradeOnOff Then
Buy 1 Shares AT Market
ENDIF
I’m not sure how to do this, if you have any ideas or links on the forum
lest say this named rules :
A: Counting losses per day
B: If my loss is more than 10 per day then I stop trading for the day
C: If my loss is more than 40 per week then I stop trading for the week
D: If my loss is more than 100 I stop trading for hole month
E: We will also try to keep track of the winnings, and why not add a small part of the winnings to allow us to bet more
for the B rule I think this boolen as a condition is ok :
DayLostCondition = DayProfit > -10
for the C rule I think this boolen as a condition is ok :
WeekProfit = MondayProfit + TuesdayProfit + WednesdayProfit + ThursdayProfit + FridayProfit
WeekLostCondition = WeekProfit > -40
and for buy condition we have to test this both boolen with buy condition like this :
IF LongSignal AND DayLostCondition AND WeekLostCondition THEN
Buy 1 Shares AT Market
ENDIF
what do you think ? and if some one can help for count week losses for add the D rule ?
tks in advance for any help or link
I correct myself for the DayOfWeek function, is there a function to retrieve the current week or do you have to divide the DayOfWeek function by 7 ?
IF DayOfWeek = 1 THEN
MondayProfit = DayProfit
ELSIF DayOfWeek = 2 THEN
TuesdayProfit = DayProfit
ELSIF DayOfWeek = 3 THEN
WednesdayProfit = DayProfit
ELSIF DayOfWeek = 4 THEN
ThursdayProfit = DayProfit
ELSIF DayOfWeek = 5 THEN
FridayProfit = DayProfit
ELSIF DayOfWeek = 6 THEN
MondayProfit = 0
TuesdayProfit = 0
WednesdayProfit = 0
ThursdayProfit = 0
FridayProfit = 0
ENDIF
and does Sunday exist? DayOfWeek = 7 ?
CurrentDayOfWeek
CurrentMonth
https://www.prorealcode.com/documentation/category/dateandtime/
Strangely there isn’t listed CurrentWeek
I’m fairly sure Sunday = 0 and so Monday = 1 … etc
I see that I am asking too many questions 😅,
I just did a test on a market that is open all the time and yes, I can confirm that Sunday is 0 and Saturday is 6, you can see in the photo : Sunday = Dimanche
and yes they haven’t CurrentWeek or WeekOfMonth :
Return CurrentWeek
Return WeekOfMonth
Complete list is:
CurrentTime: Current HourMinuteSecond (the market one).
CurrentSecond: Current (market) second.
CurrentMinute: Current (market) minute.
CurrentHour: Current (market) hour.
CurrentMonth: Current month (the market one).
CurrentDayOfWeek: Current day of the week.
CurrentYear: Current year (that of the market).
Today:Date of the current day (that of the market)
Yesterday:Date of the previous day of the market.
Tks you @Nicolas
How do we know which week of the year or which week of the month it is?
Start to count on year change:
if year<>year[1] then
monthcount = 1
endif
if month<>month[1] then
monthcount=monthcount+1
endif
Tks you, and how to know which week in the month we are, exemple the first or second week of the month pls ?
Nothing like a week of a month exists. 🙂
I mean, in reality. Or else you are going to tell me ? haha
I don’t have an answer yet, but I think with Nicolas’ answer there is a way to do something with maybe divisions and the Day function to know which week you are in the month or in the year
And Maybe you have an answer for me in this thread Link here
The first week of the year is week #1 and it is the one in which 4+ days belong to the new year (4, 5, 6 or 7, while 1, 2 or 3 is the last week of the prior year). From there on you start counting up to 52 (occasionally 53) weeks.
Some hints at https://www.prorealcode.com/topic/tomorrows-date/.