Max Lost per day

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #214057 quote
    ZeroCafeine
    Participant
    Senior

    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
    #214059 quote
    Nicolas
    Keymaster
    Master

    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? 😉

    ZeroCafeine thanked this post
    #214098 quote
    ZeroCafeine
    Participant
    Senior

    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

    #214110 quote
    ZeroCafeine
    Participant
    Senior

    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

    #214112 quote
    ZeroCafeine
    Participant
    Senior

    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 ?

    #214118 quote
    GraHal
    Participant
    Master

    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

    ZeroCafeine thanked this post
    #214122 quote
    ZeroCafeine
    Participant
    Senior

    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

    Capture-decran-2023-05-04-a-15.08.39.png Capture-decran-2023-05-04-a-15.08.39.png
    #214124 quote
    ZeroCafeine
    Participant
    Senior

    and yes they haven’t CurrentWeek or WeekOfMonth :

    
    Return CurrentWeek
    
    Return WeekOfMonth
    GraHal thanked this post
    Capture-decran-2023-05-04-a-15.07.10.png Capture-decran-2023-05-04-a-15.07.10.png
    #214157 quote
    Nicolas
    Keymaster
    Master

    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.

    #214159 quote
    ZeroCafeine
    Participant
    Senior

    Tks you @Nicolas

    How do we know which week of the year or which week of the month it is?

    #214160 quote
    Nicolas
    Keymaster
    Master

    Start to count on year change:

    if year<>year[1] then 
     monthcount = 1
    endif 
    
    if month<>month[1] then 
     monthcount=monthcount+1
    endif 
    #214163 quote
    ZeroCafeine
    Participant
    Senior

    Tks you, and how to know which week in the month we are, exemple the first or second week of the month pls ?

    #214168 quote
    PeterSt
    Participant
    Master

    Nothing like a week of a month exists. 🙂
    I mean, in reality. Or else you are going to tell me ? haha

    #214185 quote
    ZeroCafeine
    Participant
    Senior

    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

    #214186 quote
    robertogozzi
    Moderator
    Master

    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/.

    ZeroCafeine thanked this post
Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.

Max Lost per day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 17 replies,
has 5 voices, and was last updated by ZeroCafeine
2 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/03/2023
Status: Active
Attachments: 2 files
Logo Logo
Loading...