Closing Price January Higher than December Close

Forums ProRealTime English forum ProOrder support Closing Price January Higher than December Close

Viewing 15 posts - 1 through 15 (of 19 total)
  • #231197

    Good Morning!

    I have problems to get the right programmcode for this case:

    if one of the closing prices between the 5th and 10th trading day in January is above the previous year’s closing price then go long after the 24th trading day in any month if condition is met and not yet long.

    Sell if the closing price closes below SMA200 (minus 3%).

     

    Thank you very much.

     

    #231225

    @Admin: Can you switch the offer to ProOrder Support.

    That would be nice. Here on indicator it is wrong.

    #231235
    JS

    Hi,

    Try this one:

    1 user thanked author for this post.
    #231239

    @JS: Thank you very much! That is very nice.

    Can you shortly explain the meaning of Threshold.

    Thank you.

    #231240

    @JS: Thank you very much! That is very nice.

    Can you shortly explain the meaning of Threshold.

    Thank you.

    #231241
    JS

    Hi,

    If the Close>YearClose (in which the YearClose is the threshold) and the other day conditions are also true (Day>=5 and Day<=10) then the value of the threshold condition is equal to 1. (So, Close>YearClose and Day>=5 and Day<=10)

    I’ve broken this down in the code because you can’t check the given days (3) at the same time if:

    Day>=5 and Day<=10 and Day>24 (it is impossible that Day>=5 and Day<=10 AND Day>24) that’s why I’ve broken it down)

    I hope it’s a little clear, if not ask questions…

    1 user thanked author for this post.
    #232422

    Hello @JS!

    i have checked the code because in manuel backtesting I get different entry points.

    So the problem is, that the code from you only buy when the day >24 from each month is over the close level of December of the previous year. That is a little bit different from my idea.

     

    My idea was if  one close price between 5 and 10 january is higher than the close price of the last day of the december than you can buy every month after day 24 if you are not on the market.

    So the Time between 5 and january is the condition for every month buy

    So the code has to say:

    SUP Close DEZ 2023 (4769,83)

    9.1. Close (4756,5) = wrong (Day=6)

    10.1. Close (4783,45) = True (DAY=7)

    ..

    so in 2024 i can buy on 25.01., and wenn i have a exit after that time, i can buy again on 26.2. and on 25.3 and so one.

    Thank you sir

     

    #232434
    JS

    Hi @Lambo

    I see what you mean, the check must be done every month…

    Unfortunately, I’m not very good with “Time and Date” and I don’t see the solution now…sorry.

    Maybe someone else sees it?

    1 user thanked author for this post.
    #232455

    This code seems to meet your criteria (tested on DAX, 1h TF):

     

     

    2 users thanked author for this post.
    #232458

    Hello Roberto,

    i have put the code into a SUP Index for Backtesting. But nothing happens here.

    I saw the line for the previous year closing but no buy and sell.

    Can you shortly look at my code:

    defparam preloadbars=5000
    defparam cumulateorders=false
    size=(100000+strategyprofit)/(close)

    ONCE EntryDay = 24
    ONCE MonthDay1 = 5
    ONCE MonthDay2 = 10
    ONCE Tally = 0
    ONCE AboveFlag = 0
    ONCE YearClose = 2024

    // ate the beginning of each year save the closing price of the previous year
    IF OpenYear <> OpenYear[1] THEN
    YearClose = close[1]
    ENDIF

    // at the beginning of each Month reset the tally of trading days to zero
    IF (OpenMonth <> OpenMonth[1]) THEN
    Tally = 0
    AboveFlag = 0
    ENDIF

    // each new day updates the tally
    IF (OpenDay <> OpenDay[1]) THEN
    Tally = Tally + 1
    ENDIF

    // between day 5 and day 10 check if the price is above the previous Year’s closing price
    IF (Tally >= MonthDay1) AND (Tally <= MonthDay2) THEN
    AboveFlag = max(AboveFlag,close > YearClose)
    ENDIF

    // enter after trading day 24 if conditions are met
    IF (Tally > EntryDay) AND AboveFlag AND Not OnMarket THEN
    buy size contracts at market
    AboveFlag = 0
    ENDIF

    // exit when the price closes below (Sma200 – 3%)
    Sma200 = average[200,0](close) * 0.97
    ExitFlag = close < Sma200
    IF LongOnMarket AND ExitFlag THEN
    SELL AT MARKET
    ENDIF
    // debugging section
    graphonprice YearClose coloured(“Blue”)
    graphonprice Sma200 coloured(“Fuchsia”)
    //graph Tally
    //graph AboveFlag

    #232469

    You must have enough bars to access the previous year’s last bar (on a 1-minute TF you will need 200K bars, but after June it won’t work at all).

     

     

    1 user thanked author for this post.
    #232472

    Thank you sir. I want to use it on day Chart. It is an optimazier for the Month ultimo trading. go long at the end of the month.

    So I am working with 1 day as timeframe.

    Can you check your Code with SUP Kassa? I don’t get a trade and 5.000 days are as a preloud enough for some years I think.

    #232480

    Because there are not enough trading days in each month, try:

    the line

    doesn’t affect any calculations and can even be safely removed. In any case it is a price, not a year (such as 2024).

     

     

    #232488

    here I Have an example for the trade idea:

    Year 2008: No close between 5th and 10 th january is higher than previous year close  –> so in this year is no entry on every 25. of each month if not on the market. The january barometer say no good long year

    Year 2011: at least one close between 5th and 10 th january  is higher than previous year close -> So if you are not on the market you have to buy on every 25 th of every month in this year.

    Exit one: sell if close is higher donchian 200 up

    Exit SL: if course close goes unter the SMA200-3%

    You see in 2011 there are some exits (red cross) and entry (green arrow). You also have to buy in this strategy when you are unter the previous year close ond 25 th August and on 25th of november.

    I hope you understand it.

    Thanks

     

    #232500

    There you go:

     

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 19 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login