You can import your own custom market quotes and market indicators into your account. Custom market quotes / indicators can include stocks, indexes, currencies, crypto, foreign stocks, interest rates, bonds, as well as proprietary indicators from other platforms.
There are multiple ways to incorporate Custom Indicators into your strategies.
Option 1: Import Indicators As CSV File
The easiest way to use custom indicators is to import them as a CSV file into your account.
To import custom indicators into your account, please see the following tutorial on importing custom quotes / indicators. Once your indicator is imported, you can use it to make trading decisions and adjustments.
https://www.optionstack.com/kb/import-custom-quotes-indicators/
Option 2: Use Scala
If you prefer to develop your strategy in Scala, you can also incorporate your own custom trading studies / indicators by writing your strategy in Scala using the Advanced Scala Editor.
Here are the instructions on how to incorporate your own custom studies in your strategies: (Custom Trading Indicators Example)
- Create a New Strategy using the Advanced Scala Editor
- Export your studies / indicators into a list of entry and exit dates
- Assign the list of entry / exit dates as Scala variables to be referenced in your strategy. For example, you can create an Array of Date for all the dates when your trading signals are triggered. (Note: If you are using EOD data, dates should have an EOD timestamp of “16:00 EST”)
/* Add trading signal dates using an Array of Date
* Dates should have an EOD timestamp of "16:00 EST".*/
var studies1_entryDates = Array (
new java.util.Date ("1/6/2020 16:00 EST"),
new java.util.Date ("1/13/2020 16:00 EST"),
new java.util.Date ("1/17/2020 16:00 EST")
);
var studies1_exitDates = Array (
new java.util.Date ("1/8/2020 16:00 EST"),
new java.util.Date ("1/16/2020 16:00 EST"),
new java.util.Date ("1/24/2020 16:00 EST")
);
- At every tick of data, compare the current timestamp with the custom dates specified from the step above. If the current timestamp matches any of your custom dates, execute the desired trade. You can use the this.getContext.getCurrentTimestep() to get the current timestamp inside the handleData() method.
def handleData () = {
// get the current time
var curTime= this.getContext.getCurrentTimestep();
// check if the current time matches the dates in studies1_entryDates
if (studies1_entryDates.contains(curTime) ) {
// if the current time matches entry dates, sell a strangle
var strategy1 = SPY.strategies.straddleStrangles.Strangle
strategy1.sell("sellstraddleStrangles.Strangle1", "Sell Strangle on entry signal").sizeBy.quantityFunction(() => {(1)})
}
}
- At every tick of data, compare the current timestamp with your custom exit dates. If the current timestamp matches any of your custom exit dates, close the trade.
this.selectPosition(orderID="sellstraddleStrangles.Strangle1").foreach ({ curItem =>
var curItemAsStrategy = curItem.asStrategy.strangle
// check if the current time matches the EXIT dates in studies1_exitDates
if (studies1_exitDates.contains(curTime) ) {
// if the current time matches EXIT dates, close the trade
curItemAsStrategy.close("Closing based on exit signal", fillInstantly=true);
}
}