0

I'd like to program an indicator (not a strategy) in order to backtest a portfolio of five different symbols in one script. The aim is to find out how my trading strategy performs across various symbols and time ranges. Let's say my strategy is to simply enter a trade on a MA crossup and exit on the opposite signal. How can I perform the necessary calculations for each symbol without generating a lot of code? Should I use request.security and call a custom function?

Sorry, this is a real newbie question, I suppose. Any help is much appreciated!

1 Answers1

0

Unless you need a screener, I would say you just code your indicator for one symbol and manually change the ticker id and see how it performs there.

If you need a screener, you need to use the request.security() function to get data from different tickers.

In any case, you need to keep track of the entry price, take profit price and stop loss price. You need to use a var variable for those so you can "save" their values. And then calculate the profit, loss and any other statistics yourself. You can use a table to display the results.

vitruvius
  • 15,740
  • 3
  • 16
  • 26