Hello, Which trading software to backtest strategy ? This trading software should be free or try before buy. A big plus is if you can add the code ready to use to run this strategy : Strategy to backtest Be 8 days long. Then 5 days cash. Then 6 days short. Then 8 days cash. Repeat cycle. Be 8 days long. Then 5 days cash. Then 6 days short. Then 8 days cash. Repeat cycle. Etc.. Thanks,
Amibroker could do that. Probably a lot of work even for someone with experience on it though... Create a for loop that keeps running a certain # of cycles, or a while loop that runs for some condition .. Basic idea is to create a function that sets the variables - Buy Sell Short Cover While (something is true) Set Cycle Regime 1 for 8 days Then Set Cycle Regime 2 for 5 days Then Set Cycle Regime 3 for 6 days Than set Cycle Regim 4 for 8 days Cycle { Regime 1 - Long Buy = 1 Sell = 0 Short = 0 Cover = 0 Regime 2 - Buy = 0 Sell = 1 Short = 0 Cover = 0 Regime 3 = Buy = 0 Sell = 0 Short = 1 Cover = 0 Regime 4 = Buy = 0 Sell = o Short = 0 Cover = 1 }
I have tried Amibroker, without success. With GOOG from 01/06/2009, the first trade 10/06/2009. With other symbols it vary. If you success to code this strategy with success please publish it here. Code: iLong = 8; iAfterLong = 5; iShort = 6; iAfterShort = 8; StatusLong = 11; StatusAfterLong = 12; StatusShort = 13; StatusAfterShort = 14; State = StatusLong; iCtr = 999999; for ( i = 0; i < BarCount; i++ ) { switch ( State ) { case StatusLong: if ( iCtr >= iLong ) { Buy[i] = True; State = StatusAfterLong; iCtr = 0; } else { iCtr++; } break; case StatusAfterLong: if ( iCtr >= iAfterLong ) { Sell[i] = True; State = StatusShort; iCtr = 0; } else { iCtr++; } break; case StatusShort: if ( iCtr >= iShort ) { Short[i] = True; State = StatusAfterShort; iCtr = 0; } else { iCtr++; } break; case StatusAfterShort: if ( iCtr >= iAfterShort ) { Cover[i] = True; State = StatusLong; iCtr = 0; } else { iCtr++; } break; default: break; } } Plot( Close, "Close", colorBlack, styleCandle );
I don't know why the counter is set so high.... It seems to be doing two different things - one is running in a loop while the other function is to act as a counter for the # of days that have passed for the strategy... I think that might have been causing an issue... I'm not familiar with using Buy ... usually I just write a simple Buy = 0 or 1.... Did you post this on the amibroker users yahoo group?