Back in 2015 I made a Swing strategy on #SP500 going long at the open the day after a Bank Holiday with 2 simple conditions.
So we have a win rate of 62%, a profit factor of 3.3. The average gain is approximately two times the average loss. Out of 40 years 27 years are positive 5 years are negative and the rest are without trades. We have a max drawdown that is approximately 13% of the total gain. So this is a long only strategy going long after an American bank holiday. It runs on the SP500 market. And here's the code. We have three entry conditions. The first entry condition is that today is a bank holiday. The second entry condition is that the day of the week cannot be Monday, it cannot be Sunday and the month must not be November. The third and last condition is that the close of today is smaller than the close of yesterday. And we have only one exit condition and that is that the internal bar strength indicator have a value of above point 95.
The code
defparam cumulateorders = false
if date = 19830103 then
datesignal = 3
elsif date = 19830117 then
datesignal = 3
elsif date = 19830221 then
datesignal = 3
elsif date = 19830530 then
datesignal = 3
elsif date = 19830620 then
datesignal = 3
elsif date = 19830705 then
datesignal = 3
elsif date = 19830905 then
datesignal = 3
elsif date = 19831010 then
datesignal = 3
elsif date = 19831112 then
datesignal = 3
elsif date = 19831124 then
datesignal = 3
elsif date = 19831226 then
datesignal = 3
elsif date = 19840103 then
datesignal = 3
elsif date = 19840117 then
datesignal = 3
elsif date = 19840221 then
datesignal = 3
elsif date = 19840530 then
datesignal = 3
elsif date = 19840620 then
datesignal = 3
elsif date = 19840705 then
datesignal = 3
elsif date = 19840905 then
datesignal = 3
elsif date = 19841010 then
datesignal = 3
elsif date = 19841112 then
datesignal = 3
elsif date = 19841124 then
datesignal = 3
elsif date = 19841226 then
datesignal = 3
elsif date = 19850103 then
datesignal = 3
elsif date = 19850117 then
datesignal = 3
elsif date = 19850221 then
datesignal = 3
elsif date = 19850530 then
datesignal = 3
elsif date = 19850620 then
datesignal = 3
elsif date = 19850705 then
datesignal = 3
elsif date = 19850905 then
datesignal = 3
elsif date = 19851010 then
datesignal = 3
elsif date = 19851112 then
datesignal = 3
elsif date = 19851124 then
datesignal = 3
elsif date = 19851226 then
datesignal = 3
elsif date = 19860103 then
datesignal = 3
elsif date = 19860117 then
datesignal = 3
elsif date = 19860221 then
datesignal = 3
elsif date = 19860530 then
datesignal = 3
elsif date = 19860620 then
datesignal = 3
elsif date = 19860705 then
datesignal = 3
elsif date = 19860905 then
datesignal = 3
elsif date = 19861010 then
datesignal = 3
elsif date = 19861112 then
datesignal = 3
elsif date = 19861124 then
datesignal = 3
elsif date = 19861226 then
datesignal = 3
elsif date = 19870103 then
datesignal = 3
elsif date = 19870117 then
datesignal = 3
elsif date = 19870221 then
datesignal = 3
elsif date = 19870530 then
datesignal = 3
elsif date = 19870620 then
datesignal = 3
elsif date = 19870705 then
datesignal = 3
elsif date = 19870905 then
datesignal = 3
elsif date = 19871010 then
datesignal = 3
elsif date = 19871112 then
datesignal = 3
elsif date = 19871124 then
datesignal = 3
elsif date = 19871226 then
datesignal = 3
elsif date = 19880103 then
datesignal = 3
elsif date = 19880117 then
datesignal = 3
elsif date = 19880221 then
datesignal = 3
elsif date = 19880530 then
datesignal = 3
elsif date = 19880620 then
datesignal = 3
elsif date = 19880705 then
datesignal = 3
elsif date = 19880905 then
datesignal = 3
elsif date = 19881010 then
datesignal = 3
elsif date = 19881112 then
datesignal = 3
elsif date = 19881124 then
datesignal = 3
elsif date = 19881226 then
datesignal = 3
elsif date = 19890103 then
datesignal = 3
elsif date = 19890117 then
datesignal = 3
elsif date = 19890221 then
datesignal = 3
elsif date = 19890530 then
datesignal = 3
elsif date = 19890620 then
datesignal = 3
elsif date = 19890705 then
datesignal = 3
elsif date = 19890905 then
datesignal = 3
elsif date = 19891010 then
datesignal = 3
elsif date = 19891112 then
datesignal = 3
elsif date = 19891124 then
datesignal = 3
elsif date = 19891226 then
datesignal = 3
elsif date = 19900103 then
datesignal = 3
elsif date = 19900117 then
datesignal = 3
elsif date = 19900221 then
datesignal = 3
elsif date = 19900530 then
datesignal = 3
elsif date = 19900620 then
datesignal = 3
elsif date = 19900705 then
datesignal = 3
elsif date = 19900905 then
datesignal = 3
elsif date = 19901010 then
datesignal = 3
elsif date = 19901112 then
datesignal = 3
elsif date = 19901124 then
datesignal = 3
elsif date = 19901226 then
datesignal = 3
elsif date = 19910103 then
datesignal = 3
elsif date = 19910117 then
datesignal = 3
elsif date = 19910221 then
datesignal = 3
elsif date = 19910530 then
datesignal = 3
elsif date = 19910620 then
datesignal = 3
elsif date = 19910705 then
datesignal = 3
elsif date = 19910905 then
datesignal = 3
elsif date = 19911010 then
datesignal = 3
elsif date = 19911112 then
datesignal = 3
elsif date = 19911124 then
datesignal = 3
elsif date = 19911226 then
datesignal = 3
elsif date = 19920103 then
datesignal = 3
elsif date = 19920117 then
datesignal = 3
elsif date = 19920221 then
datesignal = 3
elsif date = 19920530 then
datesignal = 3
elsif date = 19920620 then
datesignal = 3
elsif date = 19920705 then
datesignal = 3
elsif date = 19920905 then
datesignal = 3
elsif date = 19921010 then
datesignal = 3
elsif date = 19921112 then
datesignal = 3
elsif date = 19921124 then
datesignal = 3
elsif date = 19921226 then
datesignal = 3
elsif date = 19930103 then
datesignal = 3
elsif date = 19930117 then
datesignal = 3
elsif date = 19930221 then
datesignal = 3
elsif date = 19930530 then
datesignal = 3
elsif date = 19930620 then
datesignal = 3
elsif date = 19930705 then
datesignal = 3
elsif date = 19930905 then
datesignal = 3
elsif date = 19931010 then
datesignal = 3
elsif date = 19931112 then
datesignal = 3
elsif date = 19931124 then
datesignal = 3
elsif date = 19931226 then
datesignal = 3
elsif date = 19940103 then
datesignal = 3
elsif date = 19940117 then
datesignal = 3
elsif date = 19940221 then
datesignal = 3
elsif date = 19940530 then
datesignal = 3
elsif date = 19940620 then
datesignal = 3
elsif date = 19940705 then
datesignal = 3
elsif date = 19940905 then
datesignal = 3
elsif date = 19941010 then
datesignal = 3
elsif date = 19941112 then
datesignal = 3
elsif date = 19941124 then
datesignal = 3
elsif date = 19941226 then
datesignal = 3
elsif date = 19950103 then
datesignal = 3
elsif date = 19950117 then
datesignal = 3
elsif date = 19950221 then
datesignal = 3
elsif date = 19950530 then
datesignal = 3
elsif date = 19950620 then
datesignal = 3
elsif date = 19950705 then
datesignal = 3
elsif date = 19950905 then
datesignal = 3
elsif date = 19951010 then
datesignal = 3
elsif date = 19951112 then
datesignal = 3
elsif date = 19951124 then
datesignal = 3
elsif date = 19951226 then
datesignal = 3
elsif date = 19960103 then
datesignal = 3
elsif date = 19960117 then
datesignal = 3
elsif date = 19960221 then
datesignal = 3
elsif date = 19960530 then
datesignal = 3
elsif date = 19960620 then
datesignal = 3
elsif date = 19960705 then
datesignal = 3
elsif date = 19960905 then
datesignal = 3
elsif date = 19961010 then
datesignal = 3
elsif date = 19961112 then
datesignal = 3
elsif date = 19961124 then
datesignal = 3
elsif date = 19961226 then
datesignal = 3
elsif date = 19970103 then
datesignal = 3
elsif date = 19970117 then
datesignal = 3
elsif date = 19970221 then
datesignal = 3
elsif date = 19970530 then
datesignal = 3
elsif date = 19970620 then
datesignal = 3
elsif date = 19970705 then
datesignal = 3
elsif date = 19970905 then
datesignal = 3
elsif date = 19971010 then
datesignal = 3
elsif date = 19971112 then
datesignal = 3
elsif date = 19971124 then
datesignal = 3
elsif date = 19971226 then
datesignal = 3
elsif date = 19980103 then
datesignal = 3
elsif date = 19980117 then
datesignal = 3
elsif date = 19980221 then
datesignal = 3
elsif date = 19980530 then
datesignal = 3
elsif date = 19980620 then
datesignal = 3
elsif date = 19980705 then
datesignal = 3
elsif date = 19980905 then
datesignal = 3
elsif date = 19981010 then
datesignal = 3
elsif date = 19981112 then
datesignal = 3
elsif date = 19981124 then
datesignal = 3
elsif date = 19981226 then
datesignal = 3
elsif date = 19990103 then
datesignal = 3
elsif date = 19990117 then
datesignal = 3
elsif date = 19990221 then
datesignal = 3
elsif date = 19990530 then
datesignal = 3
elsif date = 19990620 then
datesignal = 3
elsif date = 19990705 then
datesignal = 3
elsif date = 19990905 then
datesignal = 3
elsif date = 19991010 then
datesignal = 3
elsif date = 19991112 then
datesignal = 3
elsif date = 19991124 then
datesignal = 3
elsif date = 19991226 then
datesignal = 3
elsif date = 20000103 then
datesignal = 3
elsif date = 20000117 then
datesignal = 3
elsif date = 20000221 then
datesignal = 3
elsif date = 20000530 then
datesignal = 3
elsif date = 20000620 then
datesignal = 0
elsif date = 20000705 then
datesignal = 3
elsif date = 20000905 then
datesignal = 3
elsif date = 20001010 then
datesignal = 0
elsif date = 20001112 then
datesignal = 3
elsif date = 20001124 then
datesignal = 3
elsif date = 20001226 then
datesignal = 3
elsif date = 20010103 then
datesignal = 3
elsif date = 20010117 then
datesignal = 3
elsif date = 20010221 then
datesignal = 3
elsif date = 20010530 then
datesignal = 3
elsif date = 20010620 then
datesignal = 3
elsif date = 20010705 then
datesignal = 3
elsif date = 20010905 then
datesignal = 0
elsif date = 20011010 then
datesignal = 3
elsif date = 20011112 then
datesignal = 3
elsif date = 20011124 then
datesignal = 3
elsif date = 20011226 then
datesignal = 3
elsif date = 20020103 then
datesignal = 3
elsif date = 20020117 then
datesignal = 3
elsif date = 20020221 then
datesignal = 3
elsif date = 20020530 then
datesignal = 3
elsif date = 20020620 then
datesignal = 3
elsif date = 20020705 then
datesignal = 3
elsif date = 20020905 then
datesignal = 0
elsif date = 20021010 then
datesignal = 3
elsif date = 20021112 then
datesignal = 3
elsif date = 20021124 then
datesignal = 3
elsif date = 20021226 then
datesignal = 3
elsif date = 20030103 then
datesignal = 3
elsif date = 20030117 then
datesignal = 0
elsif date = 20030221 then
datesignal = 0
elsif date = 20030530 then
datesignal = 3
elsif date = 20030620 then
datesignal = 3
elsif date = 20030705 then
datesignal = 3
elsif date = 20030905 then
datesignal = 3
elsif date = 20031010 then
datesignal = 3
elsif date = 20031112 then
datesignal = 3
elsif date = 20031124 then
datesignal = 3
elsif date = 20031226 then
datesignal = 3
elsif date = 20040103 then
datesignal = 3
elsif date = 20040117 then
datesignal = 3
elsif date = 20040221 then
datesignal = 3
elsif date = 20040530 then
datesignal = 3
elsif date = 20040620 then
datesignal = 3
elsif date = 20040705 then
datesignal = 3
elsif date = 20040905 then
datesignal = 3
elsif date = 20041010 then
datesignal = 3
elsif date = 20041112 then
datesignal = 3
elsif date = 20041124 then
datesignal = 3
elsif date = 20041226 then
datesignal = 3
elsif date = 20050103 then
datesignal = 3
elsif date = 20050117 then
datesignal = 3
elsif date = 20050221 then
datesignal = 3
elsif date = 20050530 then
datesignal = 3
elsif date = 20050620 then
datesignal = 3
elsif date = 20050705 then
datesignal = 3
elsif date = 20050905 then
datesignal = 3
elsif date = 20051010 then
datesignal = 3
elsif date = 20051112 then
datesignal = 3
elsif date = 20051124 then
datesignal = 3
elsif date = 20051226 then
datesignal = 3
elsif date = 20060103 then
datesignal = 3
elsif date = 20060117 then
datesignal = 3
elsif date = 20060221 then
datesignal = 3
elsif date = 20060530 then
datesignal = 3
elsif date = 20060620 then
datesignal = 3
elsif date = 20060705 then
datesignal = 3
elsif date = 20060905 then
datesignal = 3
elsif date = 20061010 then
datesignal = 3
elsif date = 20061112 then
datesignal = 3
elsif date = 20061124 then
datesignal = 3
elsif date = 20061226 then
datesignal = 3
elsif date = 20070103 then
datesignal = 3
elsif date = 20070117 then
datesignal = 3
elsif date = 20070221 then
datesignal = 3
elsif date = 20070530 then
datesignal = 3
elsif date = 20070620 then
datesignal = 3
elsif date = 20070705 then
datesignal = 3
elsif date = 20070905 then
datesignal = 3
elsif date = 20071010 then
datesignal = 3
elsif date = 20071112 then
datesignal = 3
elsif date = 20071124 then
datesignal = 3
elsif date = 20071226 then
datesignal = 3
elsif date = 20080103 then
datesignal = 0
elsif date = 20080117 then
datesignal = 3
elsif date = 20080221 then
datesignal = 3
elsif date = 20080530 then
datesignal = 3
elsif date = 20080620 then
datesignal = 0
elsif date = 20080705 then
datesignal = 3
elsif date = 20080905 then
datesignal = 3
elsif date = 20081010 then
datesignal = 3
elsif date = 20081112 then
datesignal = 3
elsif date = 20081124 then
datesignal = 3
elsif date = 20081226 then
datesignal = 3
elsif date = 20090103 then
datesignal = 3
elsif date = 20090117 then
datesignal = 3
elsif date = 20090221 then
datesignal = 0
elsif date = 20090530 then
datesignal = 3
elsif date = 20090620 then
datesignal = 3
elsif date = 20090705 then
datesignal = 3
elsif date = 20090905 then
datesignal = 3
elsif date = 20091010 then
datesignal = 3
elsif date = 20091112 then
datesignal = 3
elsif date = 20091124 then
datesignal = 3
elsif date = 20091226 then
datesignal = 3
elsif date = 20100103 then
datesignal = 3
elsif date = 20100117 then
datesignal = 3
elsif date = 20100221 then
datesignal = 3
elsif date = 20100530 then
datesignal = 3
elsif date = 20100620 then
datesignal = 3
elsif date = 20100705 then
datesignal = 3
elsif date = 20100905 then
datesignal = 3
elsif date = 20101010 then
datesignal = 3
elsif date = 20101112 then
datesignal = 3
elsif date = 20101124 then
datesignal = 3
elsif date = 20101226 then
datesignal = 3
elsif date = 20110103 then
datesignal = 3
elsif date = 20110117 then
datesignal = 3
elsif date = 20110221 then
datesignal = 3
elsif date = 20110530 then
datesignal = 3
elsif date = 20110620 then
datesignal = 3
elsif date = 20110705 then
datesignal = 3
elsif date = 20110905 then
datesignal = 3
elsif date = 20111010 then
datesignal = 3
elsif date = 20111112 then
datesignal = 3
elsif date = 20111124 then
datesignal = 3
elsif date = 20111226 then
datesignal = 3
elsif date = 20120103 then
datesignal = 3
elsif date = 20120117 then
datesignal = 3
elsif date = 20120221 then
datesignal = 3
elsif date = 20120530 then
datesignal = 3
elsif date = 20120620 then
datesignal = 3
elsif date = 20120705 then
datesignal = 3
elsif date = 20120905 then
datesignal = 3
elsif date = 20121010 then
datesignal = 3
elsif date = 20121112 then
datesignal = 3
elsif date = 20121124 then
datesignal = 3
elsif date = 20121226 then
datesignal = 3
elsif date = 20130103 then
datesignal = 3
elsif date = 20130117 then
datesignal = 3
elsif date = 20130221 then
datesignal = 3
elsif date = 20130530 then
datesignal = 3
elsif date = 20130620 then
datesignal = 3
elsif date = 20130705 then
datesignal = 3
elsif date = 20130905 then
datesignal = 3
elsif date = 20131010 then
datesignal = 3
elsif date = 20131112 then
datesignal = 3
elsif date = 20131124 then
datesignal = 3
elsif date = 20131226 then
datesignal = 3
elsif date = 20140103 then
datesignal = 3
elsif date = 20140117 then
datesignal = 3
elsif date = 20140221 then
datesignal = 3
elsif date = 20140530 then
datesignal = 3
elsif date = 20140620 then
datesignal = 3
elsif date = 20140705 then
datesignal = 3
elsif date = 20140905 then
datesignal = 3
elsif date = 20141010 then
datesignal = 3
elsif date = 20141112 then
datesignal = 3
elsif date = 20141124 then
datesignal = 3
elsif date = 20141226 then
datesignal = 3
elsif date = 20150103 then
datesignal = 3
elsif date = 20150117 then
datesignal = 3
elsif date = 20150221 then
datesignal = 3
elsif date = 20150530 then
datesignal = 3
elsif date = 20150620 then
datesignal = 0
elsif date = 20150705 then
datesignal = 3
elsif date = 20150905 then
datesignal = 3
elsif date = 20151010 then
datesignal = 3
elsif date = 20151112 then
datesignal = 3
elsif date = 20151124 then
datesignal = 3
elsif date = 20151226 then
datesignal = 3
elsif date = 20160103 then
datesignal = 3
elsif date = 20160117 then
datesignal = 3
elsif date = 20160221 then
datesignal = 3
elsif date = 20160530 then
datesignal = 3
elsif date = 20160620 then
datesignal = 3
elsif date = 20160705 then
datesignal = 3
elsif date = 20160905 then
datesignal = 3
elsif date = 20161010 then
datesignal = 3
elsif date = 20161112 then
datesignal = 3
elsif date = 20161124 then
datesignal = 3
elsif date = 20161226 then
datesignal = 3
elsif date = 20170103 then
datesignal = 3
elsif date = 20170117 then
datesignal = 3
elsif date = 20170221 then
datesignal = 3
elsif date = 20170530 then
datesignal = 3
elsif date = 20170620 then
datesignal = 3
elsif date = 20170705 then
datesignal = 3
elsif date = 20170905 then
datesignal = 3
elsif date = 20171010 then
datesignal = 3
elsif date = 20171112 then
datesignal = 3
elsif date = 20171124 then
datesignal = 3
elsif date = 20171226 then
datesignal = 3
elsif date = 20180103 then
datesignal = 3
elsif date = 20180117 then
datesignal = 3
elsif date = 20180221 then
datesignal = 3
elsif date = 20180530 then
datesignal = 3
elsif date = 20180620 then
datesignal = 3
elsif date = 20180705 then
datesignal = 3
elsif date = 20180905 then
datesignal = 3
elsif date = 20181010 then
datesignal = 3
elsif date = 20181112 then
datesignal = 3
elsif date = 20181124 then
datesignal = 3
elsif date = 20181226 then
datesignal = 3
elsif date = 20190103 then
datesignal = 3
elsif date = 20190117 then
datesignal = 3
elsif date = 20190221 then
datesignal = 3
elsif date = 20190530 then
datesignal = 3
elsif date = 20190620 then
datesignal = 3
elsif date = 20190705 then
datesignal = 3
elsif date = 20190905 then
datesignal = 3
elsif date = 20191010 then
datesignal = 3
elsif date = 20191112 then
datesignal = 3
elsif date = 20191124 then
datesignal = 3
elsif date = 20191226 then
datesignal = 3
elsif date = 20300103 then
datesignal = 3
elsif date = 20200117 then
datesignal = 3
elsif date = 20200221 then
datesignal = 0
elsif date = 20200530 then
datesignal = 3
elsif date = 20200620 then
datesignal = 3
elsif date = 20200705 then
datesignal = 3
elsif date = 20200905 then
datesignal = 3
elsif date = 20201010 then
datesignal = 3
elsif date = 20201112 then
datesignal = 3
elsif date = 20201124 then
datesignal = 3
elsif date = 20201226 then
datesignal = 3
elsif date = 20210103 then
datesignal = 3
elsif date = 20210117 then
datesignal = 3
elsif date = 20210221 then
datesignal = 2
elsif date = 20210530 then
datesignal = 3
elsif date = 20210620 then
datesignal = 3
elsif date = 20210705 then
datesignal = 3
elsif date = 20210905 then
datesignal = 3
elsif date = 20211010 then
datesignal = 3
elsif date = 20211112 then
datesignal = 3
elsif date = 20211124 then
datesignal = 3
elsif date = 20211226 then
datesignal = 3
elsif date = 20220103 then
datesignal = 3
elsif date = 20220117 then
datesignal = 3
elsif date = 20220221 then
datesignal = 3
elsif date = 20220530 then
datesignal = 3
elsif date = 20220620 then
datesignal = 3
elsif date = 20220705 then
datesignal = 3
elsif date = 20220905 then
datesignal = 3
elsif date = 20221010 then
datesignal = 3
elsif date = 20221112 then
datesignal = 3
elsif date = 20221124 then
datesignal = 3
elsif date = 20221226 then
datesignal = 3
elsif date = 20230103 then
datesignal = 3
elsif date = 20230117 then
datesignal = 3
elsif date = 20230221 then
datesignal = 3
elsif date = 20230530 then
datesignal = 3
elsif date = 20230620 then
datesignal = 3
elsif date = 20230705 then
datesignal = 3
elsif date = 20230905 then
datesignal = 3
elsif date = 20231010 then
datesignal = 3
elsif date = 20231112 then
datesignal = 3
elsif date = 20231124 then
datesignal = 3
elsif date = 20231226 then
datesignal = 3
else
datesignal = 0
endif
entryconditon1 = dayofweek <> 1 and dayofweek <> 7 and month <> 11
if dclose(0) < dclose(1) then
entrycondition2 = 1
endif
if entryconditon1 and entrycondition2 and datesignal then
buy 1 contract at market
endif
IBS = (Close - Low) / (High - Low)
if IBS > 0.95 then
sell at market
endif
コメント