Hi everyone, im new to PRT even if i have followed this forum on and of for years. I have no data skills but have read some threads about seasonallity and
would like to test if there is an edge in trying to find a bottom in Sept-Oct and a top in the spring compared to Buy in Oct and sell in May.
My code below dosen´t seem to work as i aming for, wich is buying at a low Rsi in any of the month 9-11. What do i do wrong, Should i use (If openmonth 9) or?
Greatful for any help.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Only buy sep-oct
IF Currentmonth = 9 or Currentmonth = 10 or Currentmonth = 11 THEN
Endif
// Conditions to enter long positions
Indicator1 = RSI[9](close)
c1 = (indicator1 CROSSES over 30)
If c1 then
BUY 1 CONTRACT AT MARKET
endif
// Only sell May-July
IF Currentmonth = 5 or Currentmonth = 6 or Currentmonth = 7 THEN
Endif
// Conditions to exit long positions
Indicator2 = RSI[14](close)
c2 = (indicator1 CROSSES under 70)
If c2 then
SELL AT MARKET
ENDIF
Hi there !
One example, of something you do not apply correct – where an EndIf is to be projected :
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Only buy sep-oct
IF Currentmonth = 9 or Currentmonth = 10 or Currentmonth = 11 THEN
//Endif // EndIf must not be here !
// Conditions to enter long positions
Indicator1 = RSI[9](close)
c1 = (indicator1 CROSSES over 30)
If c1 then
BUY 1 CONTRACT AT MARKET
endif
Endif // That EndIf should be here !
Otherwise I notice your RSI[9] which seems to be related to your 9th month ? anyway, if it is, your TimeFrame of the chart should be 1 month in that case.
(it is a bit guessing which direction you want to go, also with the notice that the RSI may not have reached 30 (on the low side) at all).
Regards and don’t be disappointed too soon !
Peter
Hi,
there is a mistake in your code in line 6 and 18. Your code says nothing if the candle is in sept-Nov period.
Here you have what you are searching for:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Only buy sep-oct
IF not longonmarket and (Currentmonth = 9 or Currentmonth = 10 or Currentmonth = 11) and RSI[9](close) CROSSES over 30 THEN
BUY 1 CONTRACT AT MARKET
endif
// Only sell May-July
// Conditions to exit long positions
IF longonmarket and (Currentmonth = 5 or Currentmonth = 6 or Currentmonth = 7) and RSI[14](close) CROSSES under 70 THEN
SELL AT MARKET
endif
graph rsi[14](close)coloured("red")
graph rsi[9](close)coloured("green")
graph 30
graph 70
Just one thing, if you are long and the RSI is not over and crosses under the 70 level between may and july you will not exit… Consider set a trail stop of something like this.
Thank you Peter and Iván for your help.
Iván i was trying a traling stop but it seems to hurt the overall to much so i wonder if there is any code that does something like:
If c2 is not met in month 6 then sell next day att market?
I also wonder about the indicator Buy and hold. I´m aming for a robust system that are equal or better than buy and hold but when i look at the buy and hold it looks
weard? It´s telling me that the index has done app +44% from 1996 to 2024 and my strategy about the same in terms of euros. It dosen feel right.
I attached a picture of the buy and hold indicator, both the system and the indicator starts with the same amount (10.000)
Thank!