Your Seetu code can run on Collective2 in predefined times and it can send signals to your trading system.
This is a description how to manage that.
Say you have a Seetu code which includes your trading logic and C2tradingSignal commands.
-
You need a Collective2 trading system as a target of generated signals.
-
Tell Seetu what is your trading system ID.
Use the following command (replace “123456789” by your trading system ID):
SetOption("C2TradingSystemId",123456789);
-
Tell Seetu what symbols to use:
SetOption("Symbols","AAPL,VLO,MSFT,INTC,GOOG,YHOO,GE");
-
Optionally, you can also specify what time range should be used.
Probably the best way is “Last N bars”.
Do not forget that technical indicators usually need some extra bars to be calculated. For example a simple moving average CalcMA(Close,30) needs 30 bars to have its first value defined.
Here are options:
-
Last N bars:
SetOption("ApplyToRecentBars", 50);
You have “a floating” time range. The start of time range moves each business day by one day and the end of the range is always the last bar in the database.
-
Last N days:
SetOption("ApplyToRecentDays", 50);
You have “a floating” time range. The start of time range moves each day by one day and the end of the range is always the last bar in the database.
-
Specify an exact time range (start-end):
SetOption("ApplyFromTime", "2012-01-02");
SetOption("ApplyToTime", "2015-01-02");
-
Specify just the start of the range. The end will be the latest bar in the database.
SetOption("ApplyFromTime", "2012-01-02");
SetOption("ApplyToTime", "");
If “ApplyToTime” is an empty string, it means “to the last bar in the database.”
-
Specify just the end of the range. The start will be the first bar in the database.
SetOption("ApplyFromTime", "");
SetOption("ApplyToTime", "2016-01-02");
If “ApplyFromTime” is an empty string, it means “from the first bar in the database.”
-
-
Intraday strategies need an additional setup which defines time and frequency for strategy run.
This mandatory step for intraday strategies is defined by this command in your code:
SetOption("RunItSpec","YOUR_INTRADAY_SPEC_HERE");
See the “Intraday” examples below.
-
Compile your strategy and set parameters on the Run it tab.
Note
What is a difference between “ApplyToRecentBars” and “ApplyToRecentDays”?
ApplyToRecentDays uses dates. But for weekends and holidays there are no bars in the database.
It means, if we use for example SetOption("ApplyToRecentDays", 30); on 30th Apr 2015 that our calculation will start on 1th Apr, 2015 and use 22 bars, because there are 22 trading days in that month. CalcMA(Close, 30) will not be defined yet on 30th Apr 2015.
If we SetOption("ApplyToRecentBars", 30); on 30th Apr 2015, our calculation will start on 20th Mar, 2015 and use 30 bars. CalcMA(Close, 30) will be defined on 30th Mar 2015 for the first time.
Example 12. RunIt code example
// Set options like InitialCapital, RoundLotSize, SetPositionSize, ... SetOption("C2TradingSystemId",111111111); SetOption("Symbols", "AAPL,VLO,MSFT,INTC,GOOG,YHOO,GE" ); // This strategy needs at least 26 bars for CalcMACD. // We can set 30 to be sure. If we restrict a time range this way, strategy calculation will be fast. SetOption("ApplyToRecentBars", 30); Buy = Cross(CalcMACD(), CalcMACDSignal()); C2TradingSignal(sigBTO, Amount = 100, PriceType = PriceLimit); C2TradingSignalCond(sigBTO, sigSTC);
Example 13. Intraday setup example 1
This example shows just one intraday setup item for clarity:
SetOption("RunItSpec","{mon, every 10 minutes between 10:10 and 15:40}");
Example 14. Intraday setup example 2
This example uses two days (Monday, Friday) in the setup:
SetOption("RunItSpec","{mon, every 10 minutes between 10:10 and 15:40}, {fri, every 20 minutes between 10:00 and 15:20}");
Example 15. Intraday setup example 3
This example uses all days in the setup. Each day is on the separate line for clarity. But do not forget: all those lines form one string value and must be enclosed in quotes. You can't use comments or any other items in that setup structure.
SetOption("RunItSpec"," {mon, every 10 minutes between 10:00 and 15:30 }, {tue, every 10 minutes between 10:00 and 15:30 }, {wed, every 15 minutes between 11:30 and 23:45 }, {thu, every 5 minutes between 6:00 and 23:45 }, {fri, every 10 minutes between 12:00 and 14:00 }, {sat, every 30 minutes between 13:00 and 14:30 }, {sun, every 30 minutes between 13:00 and 14:30 } ");