trading_system_1.epl: remove obsolete LE-derived values

This commit is contained in:
2019-02-12 10:18:19 -08:00
parent 7cec81d06b
commit 0fa5bc4693

View File

@ -60,13 +60,6 @@ create variable bool InTradingHours = false
on TickEvent as t on TickEvent as t
set InTradingHours = EPLHelpers.inTimeRange(t.time, TradingStartTime, TradingEndTime) set InTradingHours = EPLHelpers.inTimeRange(t.time, TradingStartTime, TradingEndTime)
--
-- In long position. Set later.
--
create variable bool InLongEntry = false
-- --
-- A stream of OHLC values calculated from TickEvents -- A stream of OHLC values calculated from TickEvents
@ -237,7 +230,6 @@ insert into LongEntryStream
and EPLHelpers.laterThan(B2.time, P2.time) and EPLHelpers.laterThan(B2.time, P2.time)
and EPLHelpers.laterThan(P1.time, B2.time) and EPLHelpers.laterThan(P1.time, B2.time)
and InTradingHours and InTradingHours
and not InLongEntry
-- Because multiple streams feed LongEntryStream (CurrentTick, -- Because multiple streams feed LongEntryStream (CurrentTick,
-- MaxHigh3Window, B1, B2...), an event on any of those streams causes -- MaxHigh3Window, B1, B2...), an event on any of those streams causes
@ -263,51 +255,37 @@ insert into LongEntryDistinct
-- Long entry derived values -- Long entry derived values
-- --
-- Register if We're in a long entry when we get the LongEntryDistinct
-- event. (InLongEntry is declared near top of file)
on LongEntryDistinct as le set InLongEntry = true
-- LongEntryTime contains the timestamp of the last long entry,
-- or null if none has happened yet.
create variable DateTime LongEntryTime = null
on LongEntryDistinct as le set LongEntryTime = le.time
-- LongEntryStopBarCount contains the number of OHLCStream bars that
-- have occurred since the most recent long entry.
create variable int LongEntryStopBarCount = 0
-- Reset LongEntryStopBarCount when we get a new LE.
on LongEntryDistinct as le set LongEntryStopBarCount = 0
-- Increment LongEntry StopBarCount on every bar. -- Increment LongEntry StopBarCount on every bar.
on OHLCStream as ohlc set LongEntryStopBarCount = LongEntryStopBarCount + 1 on OHLCStream
update OrderTable
set stopBarCount = stopBarCount + 1
where OrderTable.open
-- LongEntryPrice contains the price of the last long entry, -- on OHLCStream
-- or null if none has happened yet. -- update OrderTable
create variable BigDecimal LongEntryPrice = null -- set stopBarCount = case when stopBarCount is null then 1 else stopBarCount + 1 end
-- where OrderTable.open is not null
on LongEntryDistinct as le set LongEntryPrice = le.current -- and OrderTable.open
-- LongEntryPreEntryBar is a stream that keeps bars just prior to the -- LongEntryPreEntryBar is a stream that keeps bars just prior to the
-- last long entry -- last long entry
create schema LongEntryPreEntryBar -- create schema LongEntryPreEntryBar
as (time DateTime, -- as (time DateTime,
open double, -- open double,
high double, -- high double,
low double, -- low double,
close double) -- close double)
-- Add bars so long as we're not in a long position -- -- Add bars so long as we're not in a long position
insert into LongEntryPreEntryBar -- insert into LongEntryPreEntryBar
select time, open, high, low, close from OHLCStream -- select time, open, high, low, close from OHLCStream
where InLongEntry is false -- where InLongEntry is false
-- Contains the second-most-recent LongEntryPreEntryBar's "low" value -- -- Contains the second-most-recent LongEntryPreEntryBar's "low" value
create schema LongEntryPreEntryBarPrevLow (low double) -- create schema LongEntryPreEntryBarPrevLow (low double)
insert into LongEntryPreEntryBarPrevLow select prev(1, low) as low -- insert into LongEntryPreEntryBarPrevLow select prev(1, low) as low
from LongEntryPreEntryBar#length(2) -- from LongEntryPreEntryBar#length(2)
-- --