add OHLC plugin
This commit is contained in:
74
test.epl
74
test.epl
@ -1,6 +1,70 @@
|
||||
-- in_trading_hours is set to true if the current time
|
||||
-- is inside the normal
|
||||
create variable bool in_trading_hours
|
||||
-- test.epl - sample setup
|
||||
--
|
||||
-- Statements must be separated by an empty line.
|
||||
|
||||
-- update in_trading_hours variable on each tick
|
||||
on Tick as t set in_trading_hours = (EPLHelpers.getHour(t.time) >= 9 and EPLHelpers.getHour(t.time) < 17)
|
||||
|
||||
-- The time the trading logic will begin to enter trades.
|
||||
-- Exiting trades is 24/7.
|
||||
create constant variable int StartTimeHour = 9
|
||||
|
||||
-- The time the trading logic will begin to enter trades.
|
||||
-- Exiting trades is 24/7.
|
||||
create constant variable int EndTimeHour = 17
|
||||
|
||||
-- The time frame or tickbar count of the data to be analyzed or
|
||||
-- traded. Examples: 5s, 1m, 1h 30m, 2h, 12h, 1d.
|
||||
create constant variable string Interval = '15s'
|
||||
|
||||
-- Amount to be traded, measured in units.
|
||||
create constant variable int TradeSize = 100000
|
||||
|
||||
-- InTradingHours will be set to true if the current time is between
|
||||
-- StartTime and EndTime.
|
||||
create variable bool InTradingHours = false
|
||||
|
||||
-- Update on each tick
|
||||
on TickEvent as t set InTradingHours =
|
||||
(EPLHelpers.getHour(t.time) >= StartTimeHour and
|
||||
EPLHelpers.getHour(t.time) < EndTimeHour)
|
||||
|
||||
-- A stream of OHLC values
|
||||
create variant schema OHLCStream as OHLCValue
|
||||
|
||||
insert into OHLCStream
|
||||
select * from TickEvent#OHLC(Interval, time, midDouble)
|
||||
|
||||
|
||||
--
|
||||
-- testing/debug/WIP below
|
||||
--
|
||||
|
||||
-- create window LongEntryTimeWindow#time(60 min) as
|
||||
-- select * from LongEntryEvent
|
||||
|
||||
--
|
||||
-- create window TicksTimeWindow#time(30 sec) as
|
||||
-- select * from TickEvent
|
||||
|
||||
-- on TickEvent insert into TicksTimeWindow select * from TickEvent
|
||||
|
||||
-- on TickEvent as t merge TicksTimeWindow as win
|
||||
-- where win.time
|
||||
-- insert into OrdersWindow select * from MerchandiseProductEvent
|
||||
-- set InTradingHours =
|
||||
-- (EPLHelpers.getHour(t.time) >= StartTimeHour and
|
||||
-- EPLHelpers.getHour(t.time) < EndTimeHour)
|
||||
|
||||
|
||||
-- LECount = (1,clock,60 min) == only allow one long entry per clock hour example: one LE between 1:00pm to 1:59pm
|
||||
|
||||
-- B1 = ValueWhen( (ref(sma(5,c),-1)>ref(sma(5,c),-2)<ref(sma(5,c),-3)), Ref(Low,-2), 1 )
|
||||
|
||||
-- something like "insert into CountPerSec select count(*) as cnt from XYZ.win:time_batch(1)" "select sum(cnt) from CountPerSec.win:time(1 hour)" for example, this has 1 second resolution of counts, define as you like
|
||||
|
||||
-- 1) String stmt = "insert into WebEventTotalCount select count(*) as cnt from " +
|
||||
-- "WebEvent.win:firstlength(1) A where A.page.pageName is not null ";
|
||||
|
||||
-- 2) String stmt = "update istream WebEventTotalCount set cnt = cnt + ( select count(*) as cnt from " +
|
||||
-- "WebEvent.win:time(1) A where A.page.pageName is not null ) " ;
|
||||
|
||||
-- 3) String stmt = " select cnt from WebEventTotalCount ";
|
||||
|
||||
Reference in New Issue
Block a user