Trading every 10. days of the month
Forums › ProRealTime English forum › ProOrder support › Trading every 10. days of the month
- This topic has 17 replies, 2 voices, and was last updated 4 years ago by
Suffi.
-
-
09/09/2021 at 8:29 PM #17716609/09/2021 at 9:28 PM #177172
There you go:
123If ((Day = 10) or ((Day > 10) and (Day[1] < 10))) ThenBUY 1 Contract at MarketEndif2 users thanked author for this post.
09/10/2021 at 1:35 PM #177207Hello Roberto,
thanks for the support, please add a little explanation.
(Day = 10) or ((Day > 10) this is the 10th of the month or the next day if the 10th is a Sunday.
(Day[1] < 10) ????? what is meant by this?
Shouldn’t something from DAY OF WEEK (0 or 6) go in there?Greetings
Suffi09/10/2021 at 4:24 PM #177213When DAY returns a day it’s because that one is a trading day.
If that day is 10 that’s easy, no other chacks are needed.
If that day is NOT a trading day, then the number 10 will NEVER be detected, so you want (have) to trade the next trading day.
If Friday is day 9, then Monday will be day 12. That’s when it works, as Day[0](Monday) > 10 AND Day[1] (Friday) < 10. The same occurs when Friday is Day 8 and Monday is Day 11.
They are NOT 10, but one is greater and the previous one is lower. This means that 12 or 11 is the first trading day AFTER 10.
Example (t = Trading day):
days 1 2 3 4 5 6 7 8 9 10 11 12 13
. t t – – t t t t t – – t t09/10/2021 at 4:36 PM #17721709/10/2021 at 4:57 PM #177219On the forum you can find many code snippets to be used as tools in addition to built-in instructions and constants.
This is a very useful place (thanks to GraHal for having created and still managing it regularly)
Snippet Library1 user thanked author for this post.
09/10/2021 at 6:15 PM #177222Hello Roberto,
I do not get the desired result, where is the error?
The narrow bars are correct trades (open on 10, – close on 15), the wide ones are closed on 15 of the next month or the month after?
Greetings
Suffibuy at 10.12345678910111213141516171819If (((Day = 10) or ((Day > 10) and (Day[1] < 10))) AND CurrentTime =90000 ) Then //AND HOUR=9BuyTime = 1ELSEBuyTime = 0ENDIFIf (((Day = 15) or ((Day > 15) and (Day[1] < 15))) AND CurrentTime =150000 ) Then //AND HOUR=15SellTime = 1ELSESellTime = 0ENDIFIF (NOT OnMarket AND BuyTime=1) THENBUY 1 CONTRACTS AT MARKETENDIFIF (OnMarket AND SellTime=1) THENSELL AT MARKETENDIF09/10/2021 at 6:31 PM #177225What instrument and TF is it?
09/10/2021 at 6:34 PM #17722609/11/2021 at 9:38 AM #177240That code works on a Daily chart, because when using an intraday TF, at 9 or 15, DAY[0] will always be the same as DAY[1], so if the day is 10 or 15, it works perfectly, otherwise it needs to be changed so that it sets a flag whenever Day 10 and Day 15 is detected on the first bar of the day:
1234567891011121314151617181920212223242526272829303132333435363738ONCE Day10 = 0ONCE Day15 = 0IF Month <> Month[1] THENDay10 = 0Day15 = 0ENDIFIF (Day = 10) or ((Day > 10) and (Day[1] < 10)) THENDay10 = 1ENDIFIF (Day = 15) or ((Day > 15) and (Day[1] < 15)) THENDay15 = 1ENDIFIF OnMarket THENDay10 = 0ENDIFIf Day10 AND (CurrentTime =90000) Then //AND HOUR=9BuyTime = 1ELSEBuyTime = 0ENDIFIf Day15 AND (CurrentTime =150000) Then //AND HOUR=15SellTime = 1ELSESellTime = 0ENDIFIF (NOT OnMarket AND BuyTime=1) THENBUY 1 CONTRACTS AT MARKETENDIFIF (OnMarket AND SellTime=1) THENSELL AT MARKETENDIF//graph Day//graph currenttime//graph BuyTime//graph SellTime09/11/2021 at 1:06 PM #177252Hi Roberto,
perfect, it works, unfortunately my programming skills are not enough to understand it completely.
Now I have tried to optimise the date.
The code only works if the trade runs within the same month.
Errors follow when buying on the 20th and closing on the 2nd of the next month.I tried to change it here:
IF Month <> Month[1] THEN
Day10 = 0
Day15 = 0
without successGreetings
Suffi09/11/2021 at 1:28 PM #17725309/11/2021 at 4:06 PM #177260The code I posted works on any month.
– BUY enters a Long trade
– SELL exits a Long trade
– SELLSHORT enters a Short trade
– EXITSHORT exits a Short trade
09/11/2021 at 7:12 PM #17726609/12/2021 at 9:45 AM #177276It’s not much different, you actually don’t have to care about the month, just the days:
- open on the 20th
- close on the 4th
There you go:
123456789101112131415161718BuyTime = 0SellTime = 0IF (Day = 4) or ((Day > 4) and (Day[1] < 4)) THENSellTime = 1ENDIFIF (Day = 20) or ((Day > 20) and (Day[1] < 20)) THENBuyTime = 1ENDIFIF NOT LongOnMarket AND BuyTime THENBUY 1 CONTRACTS AT MARKETENDIFIF LongOnMarket AND SellTime THENSELL AT MARKETENDIF//graph Day//graph currenttime//graph BuyTime//graph SellTime -
AuthorPosts
Find exclusive trading pro-tools on
