Closing Price January Higher than December Close
Forums › ProRealTime English forum › ProOrder support › Closing Price January Higher than December Close
- This topic has 18 replies, 3 voices, and was last updated 4 months ago by robertogozzi.
-
-
04/08/2024 at 7:30 AM #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.
04/08/2024 at 1:26 PM #231225@Admin: Can you switch the offer to ProOrder Support.
That would be nice. Here on indicator it is wrong.
04/08/2024 at 2:12 PM #231235Hi,
Try this one:
YearClose123456789101112131415161718TimeFrame(1 year, UpdateOnClose)YearClose=CloseTimeFrame(Daily, UpdateOnClose)If Day>=5 and Day<=10 and Close>YearClose thenThreshold=1EndIfIf NOT LongOnMarket and Day>24 and Threshold thenBuy 1 contract at MarketEndIfSMA200=Average[200](Close)If Close Crosses Under SMA200 or PositionPerf<-0.03 thenSell at MarketThreshold=0EndIfGraph YearClose as "YearClose"1 user thanked author for this post.
04/08/2024 at 2:29 PM #23123904/08/2024 at 2:32 PM #23124004/08/2024 at 2:47 PM #231241Hi,
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.
05/07/2024 at 11:28 AM #232422Hello @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
05/07/2024 at 3:56 PM #23243405/08/2024 at 10:24 AM #232455This code seems to meet your criteria (tested on DAX, 1h TF):
123456789101112131415161718192021222324252627282930313233343536373839404142434445ONCE EntryDay = 24ONCE MonthDay1 = 5ONCE MonthDay2 = 10ONCE Tally = 0ONCE AboveFlag = 0ONCE YearClose = 99999999// at the beginning of each year save the closing price of the previous yearIF OpenYear <> OpenYear[1] THENYearClose = close[1]ENDIF// at the beginning of each Month reset the tally of trading days to zeroIF (OpenMonth <> OpenMonth[1]) THENTally = 0AboveFlag = 0ENDIF// each new day updates the tallyIF (OpenDay <> OpenDay[1]) THENTally = Tally + 1ENDIF// between day 5 and day 10 check if the price is above the previous Year's closing priceIF (Tally >= MonthDay1) AND (Tally <= MonthDay2) THENAboveFlag = max(AboveFlag,close > YearClose)ENDIF// enter after trading day 24 if conditions are metIF (Tally > EntryDay) AND AboveFlag AND Not OnMarket THENBUY 1 CONTRACT AT MARKETAboveFlag = 0ENDIF// exit when the price closes below (Sma200 - 3%)Sma200 = average[200,0](close) * 0.97ExitFlag = close < Sma200IF LongOnMarket AND ExitFlag THENSELL AT MARKETENDIF// debugging sectiongraphonprice YearClose coloured("Blue")graphonprice Sma200 coloured("Fuchsia")//graph Tally//graph AboveFlag05/08/2024 at 10:35 AM #232458Hello 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 AboveFlag05/08/2024 at 11:54 AM #232469You 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.
05/08/2024 at 12:51 PM #232472Thank 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.
05/08/2024 at 2:51 PM #232480Because there are not enough trading days in each month, try:
1ONCE EntryDay = 20the line
1ONCE YearClose = 0doesn’t affect any calculations and can even be safely removed. In any case it is a price, not a year (such as 2024).
05/08/2024 at 3:24 PM #232488here 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
05/08/2024 at 5:18 PM #232500There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051ONCE EntryDay = 18ONCE MonthDay1 = 5ONCE MonthDay2 = 10ONCE Tally = 0ONCE AboveFlag = 0// ate the beginning of each year save the closing price of the previous yearIF OpenYear <> OpenYear[1] THENYearClose = close[1]AboveFlag = 0ENDIF// at the beginning of each Month reset the tally of trading days to zeroIF (OpenMonth <> OpenMonth[1]) THENTally = 0ENDIF// each new day updates the tallyIF (OpenDay <> OpenDay[1]) THENTally = Tally + 1ENDIF// between day 5 and day 10 check if the price is above the previous Year's closing priceIF (Tally >= MonthDay1) AND (Tally <= MonthDay2) AND (OpenMonth = 1) THENAboveFlag = max(AboveFlag,close > YearClose)ENDIF// enter after trading day 24 if conditions are metIF (Tally > EntryDay) AND AboveFlag AND Not OnMarket THENBUY 1 CONTRACT AT MARKETENDIF// TAKE PROFIT: exit when the price closes below DONCHIAN UPONCE p = 20Upper = HIGHEST[p](HIGH[1])TPflag = close > UpperIF LongOnMarket AND TPflag THENSELL AT MARKETENDIF// STOP LOSS: exit when the price closes below (Sma200 - 3%)Sma200 = average[200,0](close) * 0.97SLflag = close < Sma200IF LongOnMarket AND SLflag THENSELL AT MARKETENDIF// debugging sectiongraphonprice YearClose coloured("Blue")graphonprice Sma200 coloured("Fuchsia")//graph Tally//graph AboveFlag1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on