Seasonality Analysis Indicator small bug fix

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #57755 quote
    Vonasi
    Moderator
    Master

    There is a very minor graphical error in the coding of my Seasonality Analysis indicator in the library. Please replace lines 256 to 302 with the following or alternatively download the corrected ITF file attached to this post.

    IF StartMonth = 1 THEN
    DrawText("            From Jan #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 2 THEN
    DrawText("            From Feb #StartYear#" ,barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 3 THEN
    DrawText("            From Mar #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 4 THEN
    DrawText("            From Apr #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 5 THEN
    DrawText("            From May #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 6 THEN
    DrawText("            From Jun #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 7 THEN
    DrawText("            From Jul #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 8 THEN
    DrawText("           From Aug #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 9 THEN
    DrawText("            From Sep #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 10 THEN
    DrawText("            From Oct #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 11 THEN
    DrawText("            From Nov #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    IF StartMonth = 12 THEN
    DrawText("            From Dec #StartYear#",barindex,15.5,SansSerif,Standard,10)coloured(0,0,0)
    ENDIF
    
    GraHal, Nicolas and Despair thanked this post
    #57781 quote
    Nicolas
    Keymaster
    Master

    Thank you, your indicator has been updated in the library. Great post! 🙂

    Seasonality Analysis

    #57784 quote
    Vonasi
    Moderator
    Master

    Thanks Nicolas.

    I have just converted the indicator into two new versions. One that looks back at a fixed number of years from today so that the latest results are always from the latest sample period. A sort of always up to date walk forward.

    In the second version you can set an in sample and an out of sample period so as to be able to check reliability of results more accurately.

    Once I’ve double checked that they do what they say on the tin do you think it is best that I post them to the library or maybe just put them in a related forum post. I’m a bit conscious of filling up the library with similar indicators as this may not be what you want for the library.

    #57786 quote
    Nicolas
    Keymaster
    Master

    I’m a bit conscious of filling up the library with similar indicators as this may not be what you want for the library.

    Don’t worry about this, post them. Since indicators are linked with their tags, if someone want something related to “seasonality”, he/she will find a lot of things and that’s a good point.

    In the second version you can set an in sample and an out of sample period so as to be able to check reliability of results more accurately.

    OMG, sounds enormous! 🙂

    #57796 quote
    Vonasi
    Moderator
    Master

     

    OMG, sounds enormous! 🙂

    Only 772 very repetitive lines of code. Thank goodness for cut and paste and the find and replace all facility!

    Nobody thanked this post
    #57802 quote
    Nicolas
    Keymaster
    Master

    You could have used external indicators as functions, instead of copy paste them X times in the same code.

    #57810 quote
    Vonasi
    Moderator
    Master

    I did originally set it up as two separate codes. One for in sample and the other for out but it felt a bit clumsy so I combined the two. I hate calling on external indicators. I much prefer stand alone code. Sometimes I just like to make my life difficult. It makes the beer taste better.

    The code is now up to 939 lines as I’ve added a rating system for the combined in sample and out of sample returns for each month!

    I may have to stop now or I will go to sleep dreaming of Jan, Feb, Mar…….

    #57813 quote
    Nicolas
    Keymaster
    Master

    😆 good job! Passion feeds passion. Have a good night.

    #57814 quote
    Vonasi
    Moderator
    Master

    Minor bug fix no.2!

    I just noticed that the description when you hover over the speech bubble in the corner for the Seasonality Analysis indicator is incorrect as it was for an older version.

    I’ve attached a new itf with the correct text.

    Hopefully this is the last bug I spot.

    Yannick thanked this post
    #57822 quote
    Alai-n
    Participant
    Veteran

    (Post off topic folder)

    Good evening Vonasi, you seem to me to have a good command of your subject. That’s why I would like to ask you if you would feel able to translate the attached code (easylanguage) into probuilder language?

    Waves of Wolfe

    //Wolfe Wave Pattern --------------------------- 
    Pa:=Trough(4,LOW,5);
Pb:=Peak(3,HIGH,5);
P1:=Trough(3,LOW,5);
P2:=Peak(2,HIGH,5);
P3:=Trough(2,LOW,5);
P4:=Peak(1,HIGH,5);
P5:=Trough(1,LOW,5);
tb:=TroughBars(1,LOW,5);
eki1:=If(tb<=4 AND p1 > pa AND pb < p2 AND p1 < p4 AND p1 > p3 AND p3 > p5 AND p4 < p2,1,0); p1:=Trough(3,LOW,5); 
    p3:=Trough(2,LOW,5);
p5:=Trough(1,LOW,5);
o1:=p1-p3;
o2:=p1-p5; a1:=TroughBars(3,LOW,5)-TroughBars(2,LOW,5); a2:=TroughBars(3,LOW,5)-TroughBars(1,LOW,5); tan1:=o1/a1; 
    tan2:=o2/a2; eki2:=Abs(tan1-tan2); If(eki1 AND eki2 <= .2 ,2,0 
    
    //Codice Easy language ==============HEADER============== 
    //Study based on Connors & Raschke's "Wolfe Waves" 
    //====== DECLARATIONS ==== 
    INPUTS:
TICKCHG(10), {Change (number of ticks) required to set up a new swing high/low.} PCTCHG(.2), {Percent change in price to set up a new swing high/low}
OCCUR(1),
PLOTBARS(40),
ETALINE(TRUE),
ZIGZAG(TRUE); 
    ARRAY: PBAR[50](0), P[50](0); 
    VARS:
X(0),
PP(1),
JA_SLOPE1(0),
JLA_CTR(0),
JLA_LINE(0),
JAIRHBAR(0), { LAST SWING HIGH BAR}
JAIRLBAR(0), {LAST SWING LOW BAR} LOWSEEK(FALSE), {LOOKING FOR A LOW OR A HIGH?} W(0), {COUNTER} 
    JLA_IRH(0), {LAST SWING HIGH VALUE} JLA_IRL(99999), {LAST SWING LOW VALUE} JA_SLOPE2(0),
JA_SLOPE3(0), 
    JLA_PT1(0), WOLFE(0); 
    {===========MAIN PROGRAM============} 
    
    IF CURRENTBAR = 1 THEN P[50] = C; 
    IF LOWSEEK = FALSE AND P[50] <= H THEN BEGIN
P[50] = H;
PBAR[50] = 0; 
    END; 
    IF LOWSEEK = TRUE AND P[50] >= L THEN BEGIN
P[50] = L;
PBAR[50] = 0; 
    END; 
    IF (LOWSEEK = FALSE AND PBAR[50] <> 0) THEN BEGIN
IF (TICKCHG = 0
AND L < P[50] * ( 1 - PCTCHG / 100) ) 
    OR (TICKCHG <> 0
AND L < ( P[50] - tickchg * minmove points)) THEN
BEGIN
IF ZIGZAG = TRUE THEN PLOT4[PBAR[50]](P[50],"SWINGS"); 
    LOWSEEK = TRUE; 
    FOR W = 1 TO 49
BEGIN
PBAR[W] = PBAR[W+1]; P[W] = P[W+1]; 
    END; 
    P[50] = L; PBAR[50] = 0; END;
END; 
    IF (LOWSEEK = TRUE AND PBAR[50] <> 0) THEN BEGIN
IF (TICKCHG = 0 
    
    AND H> P[50] * ( 1 + PCTCHG / 100))
OR (TICKCHG <> 0
AND H > (P[50] + tickchg * minmove points )) THEN
BEGIN
IF ZIGZAG = TRUE THEN PLOT4[PBAR[50]](P[50],"SWINGS"); LOWSEEK = FALSE; 
    FOR W = 1 TO 49
BEGIN
PBAR[W] = PBAR[W+1]; P[W] = P[W+1]; 
    END; 
    P[50] = H; PBAR[50] = 0; END;
END; 
    IF TIME = LASTCALCTIME
AND DATE = LASTCALCDATE
AND P[48 - PP] <> 0 THEN
BEGIN
PP = -1;
WOLFE = 0;
WHILE WOLFE < OCCUR AND PP < 46 BEGIN
PP = PP + 1;
VALUE1 = P[47-PP];
VALUE2 = P[48-PP];
VALUE3 = P[49-PP];
VALUE4 = P[50-PP]; 
    CONDITION1 =
VALUE2 > VALUE1
AND VALUE4 > VALUE3 AND VALUE4 < VALUE2 AND VALUE3 < VALUE1 AND VALUE4 > VALUE1; 
    
    CONDITION2 =
VALUE2 < VALUE1
AND VALUE4 < VALUE3 AND VALUE4 > VALUE2 AND VALUE3 > VALUE1 AND VALUE4 < VALUE1; 
    IF CONDITION1 OR CONDITION2 THEN WOLFE = WOLFE + 1; END; 
    JA_SLOPE1 = (P[49-PP] - P[47-PP]) / (PBAR[47-PP] - PBAR[49-PP]); JA_SLOPE2 = (P[50-PP] - P[47-PP]) / (PBAR[47-PP] - PBAR[50-PP]); 
    {LINE 1-3}
VALUE90 = TL_New(DATE[PBAR[47-PP]],TIME[PBAR[47-PP]],P[47-PP],
DATE[PBAR[49-PP]], TIME[PBAR[49-PP]],P[49-PP]);
Value14=TL_SetColor(VALUE90, 5);
{VALUE93 = TL_SetExtRight(VALUE90,TRUE);}
VALUE94 = TL_SETEND(VALUE90,DATE[PBAR[49-PP]-PLOTBARS],TIME[PBAR[49-PP]- PLOTBARS],TL_GETVALUE(VALUE90,DATE[PBAR[49-PP]-PLOTBARS],TIME[PBAR[49-PP]-PLOTBARS])); 
    {LINE 1-4}
VALUE91 = TL_NEW(DATE[PBAR[47-PP]],TIME[PBAR[47-PP]],P[47-PP],
DATE[PBAR[50-PP]], TIME[PBAR[50-PP]],P[50-PP]);
Value14=TL_SetColor(VALUE91, 16); TL_SETEND(VALUE91,DATE[PBAR[49-PP]-PLOTBARS],TIME[PBAR[49-PP]- PLOTBARS],TL_GETVALUE(VALUE91,DATE[PBAR[49-PP]-PLOTBARS],TIME[PBAR[49-PP]-PLOTBARS])); 
    {ETA LINE} 
    IF ETALINE THEN
BEGIN
VALUE92 = TL_NEW(DATE[PBAR[48-PP]],TIME[PBAR[48-PP]],P[48-PP],
DATE[PBAR[50-PP]], TIME[PBAR[50-PP]],P[50-PP]);
Value14=TL_SetColor(VALUE92, 4); TL_SETEND(VALUE92,DATE[PBAR[50-PP]-PLOTBARS],TIME[PBAR[50-PP]- PLOTBARS],TL_GETVALUE(VALUE92,DATE[PBAR[50-PP]-PLOTBARS],TIME[PBAR[50-PP]-PLOTBARS])); 
    
    END; END; 
    IF DATE = LASTCALCDATE AND TIME = LASTCALCTIME AND ZIGZAG = TRUE THEN BEGIN 
    JA_SLOPE3 = (P[50] - P[49]) / (PBAR[49] - PBAR[50]);
FOR JLA_CTR = PBAR[49] DOWNTO PBAR[50]
BEGIN
PLOT4[JLA_CTR](P[49] + (PBAR[49] - JLA_CTR) * JA_SLOPE3,"Swings"); END; 
    END; 
    FOR W = 1 TO 50
BEGIN
PBAR[W] = PBAR[W]+1; END;

    To tell the truth I do not know what this code is worth! But currently, I think it is the only available free access.
    I’ll be curious to see it work, but unfortunately I do not have the skills to translate it under Probuilder.
    The basic idea is to see if its operation can be closer to that on the attached video …!

    #57826 quote
    Vonasi
    Moderator
    Master

    Sorry Alai-n EasyLanguage is not my thing.

    Thank you for thinking that I might be able to help but to be totally honest I dabbled with programming when I was a kid (in the days of ZX Spectrums and Commodore 64’s!) and I went to IT college after school while working for a company that wrote programs for city traders – but this was back in the late 80’s when just getting a line on a graph took a month. I  gave it up quickly when I realised that I hated sitting behind a desk and went off and became an engineer instead. I have always loved finding solutions to problems which I guess is how I now end up coding PRT in my free time (which I have a lot of). I like creating indicators that can be adapted into strategies rather than just using off the shelf indicators. I only really started on PRT coding eight months ago so I am sure there are others on here who can be of more use. Sorry to disappoint.

    On a separate note I spent some time studying Waves of Wolfe and to be honest with you found no merit in it. If you spend long enough staring at enough lines on enough graphs you can see what ever you want to see!

    #58614 quote
    Alai-n
    Participant
    Veteran

    Thank you for your reply Vonasi and too bad for my code Waves of Wolfe, which leaves me still very curious;)

    In any case, thank you very much for your contribution to the effort of this site.

    #58924 quote
    Yannick
    Participant
    Veteran

    Hi

    Thanks for sharing your seasonality analysis.

    Would you be able to mix your seasonality indicator and your trend checker to built seasonal trading algorithm?

    Something inspired by http://systemtradersuccess.com/seasonal-strategies-built-right-way/ even there is no code published

    Regards

    #58936 quote
    Vonasi
    Moderator
    Master

    I’m not sure what the exact thing is that you are asking for?

    I have read that article before you posted the link and I was inspired by the suggestion that walk forward analysis was better than starting with a fixed date and always using that fixed date each month. Better to move the start point forward one month every month. I converted my indicator into this a couple of days ago and then had a better idea. Why not have two periods that walk forward – an in sample and out of sample for easy comparison of reliability? So I converted it to do this. I then added a rating system for each month using the results from each sample weighted more on the more recent out of sample results. I have posted this to the library and it is pending review before being listed.

    I like the idea in the article of looking at the historical results for the up and coming days and would like to write this as an indicator.

    As for converting it all to a trading strategy that would take quite a bit of thought and I’m not sure that just trading now because this day last year for the last few years was profitable is a good basis for a strategy. Best just to use the analysis and maybe the rating score to adjust trade direction and position sizing month by month to give you an edge in other strategies.

    I have had a lot of time recently for indicator writing but this will shortly change due to other commitments and I doubt I will have much time to code. I have a long list of ‘would like to do’s’ already and not enough hours in the day!

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Seasonality Analysis Indicator small bug fix


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 13 replies,
has 4 voices, and was last updated by Vonasi
8 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/08/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...