Good morning, a little help with this please.
I have read a post where it is indicated that the date range is applied to the Backtest but not to the generation of signals and if you want to avoid this, you should use: inrange= Status("barinrange"); but I have not managed to do it well.
I attach a simple code to Buy when the price crosses the WMA30. I want it to show the signals from the start date of my Backtest (01/01/24) but as the system gives a Buy signal on 06/11/23 and the price does not close below the WMA30 again, this signal that should be given on 05/08/24 does not appear.
Please, how can I make it not take into account the signals prior to the date range of my backtest?
Thank you very much
The AFL code:
_SECTION_BEGIN("Sistema WMA30 Semanal");
// 1. TIPO DE SISTEMA [SIEMPRE]
SetBacktestMode( backtestRegular );
// 5. BACKTESTER SETTINGS [SIEMPRE]
SetOption( "InitialEquity", 30000 ); // Establecemos el tamaño total de la cartera, el Capital Inicial
SetTradeDelays(0,0,0,0); //Compra y Vende el mismo día de la señal (sin retrasos)
SetOption("CommissionMode", 2); // El Mode 2 es: $ per trade
SetOption( "CommissionAmount", 1 ); // Establecemos las comisiones de entrada y de salida: 1$
BuyPrice = SellPrice = Close; // Utilizará el Close como precio
Short=Cover=0; // No permitimos cortos
// 8. TAMAÑO DE LA POSICIÓN [SIEMPRE]
// Posición variable en función de la curva de capital (reinvirtiendo beneficios)
SetPositionSize( 100, spsPercentOfEquity); // Para 1 posición, el 100%
// 9. CÁLCULO INDICADORES [SIEMPRE]
SPX=Foreign("$SPX","C");//En el AFL cogerá los datos del índice pero el backtest lo pasaré sobre el ETF SPY (del que aplicaré las características)
MediaPonderada = WMA(SPX,30);
// 10. REGLAS DEL SISTEMA [SIEMPRE]
CruceAlcista = Cross(SPX,MediaPonderada);// Cruce Alcista
CruceBajista = Cross(MediaPonderada, SPX); // Cruce Bajista
Buy = CruceAlcista;
Sell = CruceBajista;
BuyPrice = SellPrice = Close;// Qué precio usará, en este caso el Close
Short=Cover=0; // No permitimos cortos
_SECTION_END();