Name

SetOption — Sets a value of the option

Synopsis

SetOption (Item,
  Value);

Returns

NOTHING

Parameters

Name Type Default Description
Item string
Value any

Description

This function is inspired by AmiBroker function: www.amibroker.com/guide/afl/setoption.html

Collective2 extensions

C2TradingSystemId
SetOption("C2TradingSystemId",123456789);

Collective2 trading system ID. Trading signals will be sent to this trading system.

Symbols
SetOption("Symbols","AAPL,MSFT,INTC");

A list of symbols for the strategy.

ApplyFromTime
SetOption("ApplyFromTime", "2014-01-02");

A start of the time range.

ApplyToTime
SetOption("ApplyToTime", "2014-01-02");

An end of the time range.

ApplytoRecentBars
SetOption("ApplytoRecentBars", 50);

Analysis will be applied to the defined number of most recent quotations.

ApplytoRecentDays
SetOption("ApplytoRecentDays", 50);

Analysis will be applied to the defined number of most recent days.

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.

Periodicity
SetOption("Periodicity",DAILY);
SetOption("Periodicity",MINUTE5);

Possible values: DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY

Possible intraday values: MINUTE1, MINUTE5, MINUTE15, MINUTE30, HOUR1

This option corresponds to AmiBroker's Periodicity in the Backtester settings dialog. See https://www.amibroker.com/guide/w_settings.html

RunItSpec

Intraday strategy run setup. This setup defines times and frequencies when the Collective2 backend will run the strategy.

Test your strategy at first and make sure your strategy does not run longer than the frequency defined in this specification. In the case you strategy is still running and the next starting time is effective, strategy is not started at that moment. In other words: your running frequency can't be shorter than the time needed to run the strategy.

It is a good idea to define the shortest possible time range needed for your strategy. See "ApplyToRecentBars". If your strategy uses - for example - MA(Close,30) it needs actually just 30 bars to run intraday. When backtesting, you can use several months of data. But it is not needed and it is counterproductive for intraday runs. It can happen that your strategy will run too long and will not run so frequently as you specified. It is your, developer, responsibility to set everything correctly to make it work smoothly.

SetOption("RunItSpec","INTRADAY_SETUP_SPEC");

Where INTRADAY_SETUP_SPEC is a string value enclosed in double quotes with this structure:

"{DAY_OF_WEEK, every M minutes between START and END }"

Where

DAY_OF_WEEK

is one of: mon, tue, wed, thu, fri, sat, sun

M

is a number of minutes between 1 and 1439

START and END

is a time specification in the 24 hours format HH:MM. The colon is mandatory.

Example 3. 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 4. 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 5. 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 }
                ");

Figure 1. Intraday run spec



Amibroker compatible

AccountMargin, AllowSameBarExit, CommissionMode (1, 2 and 3), CommissionAmount, HoldMinBars, InitialEquity, MaxOpenPositions, MinPositionValue, MinShares, NoDefaultColumns, RoundLotSize

See http://www.amibroker.com/guide/afl/setoption.html

Not implemented

ActivateStopsImmediately, DisableRuinStop, EarlyExitBars, EarlyExitDays, EarlyExitFee, EveryBarNullCheck, ExtraColumnsLocation, FuturesMode, GenerateReport, HoldMinDays, InterestRate, PortfolioReportMode, PriceBoundChecking, RefreshWhenCompleted, RequireDeclarations, ReverseSignalForcesExit, SeparateLongShortRank, SettlementDelay, UseCustomBacktestProc, UsePrevBarEquityForPosSizing, WorstRankHeld

See http://www.amibroker.com/guide/afl/setoption.html