// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("Formula 1"); // EnterAtRandom.afl // // Entry a position at the close of a random bar. // // A random entry for use as a benchmark. // Expect this entry to mirror the buy and hold. // It cannot be profitable taking long positions in // a declining market, or taking short positions // in a rising market. // // This code just waits a fixed number of bars to exit. // It can be used to test any of the exit systems. // // For market orders, enter and exit Market On Close // with no delay SetTradeDelays(0,0,0,0); BuyPrice = C; SellPrice = C; // Frequency is the number of entries per year. Frequency = Param("Entries per Year",12,1,100,1); // Repeatable is a switch. // True (1): the sequence of random numbers will be repeated. // False (0): each sequence is random. Repeatable = Param("Repeatable",0,0,1,1); // Seed is the number used to start the random sequence // when repeatable sequences are desired. Seed = Param("Seed", 13331,1,99999,1); // Generate a fraction, uniformly distributed // between 0.00000 AND 0.99999. NextRandom = IIf (Repeatable,Random(Seed),Random()); Buy = IIf (NextRandom=HoldBars; // The code for the exit being tested ends here. // Remove extra Buy and Sell signals. Buy = ExRem(Buy, Sell); Sell = ExRem(Sell,Buy); _SECTION_END();