public class Study
extends java.lang.Object
implements java.lang.Cloneable
Constructor and Description |
---|
Study() |
Modifier and Type | Method and Description |
---|---|
protected void |
addFigure(Figure figure)
Adds a figure to the end of the figure list (for the default plot).
|
protected void |
addFigure(java.lang.String plotName,
Figure figure)
Adds a figure to the end of the figure list for the plot associated with the given plot name.
|
protected void |
addFigureFront(Figure figure)
Adds a figure to the start of the figure list (for the default plot).
|
protected void |
addFigureFront(java.lang.String plotName,
Figure figure)
Adds a figure to the start of the figure list for the plot associated with the given plot name.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the given property change listener.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds the given property change listener.
|
protected void |
calculate(int index,
DataContext ctx)
Override this method to calculate the values at a specific index in
the data series.
|
protected void |
calculateValues(DataContext ctx)
By default, this method is called on events where the data series has been affected.
|
protected void |
clearFigures()
Clears the figures associated with this study (all figures).
|
protected void |
clearFigures(java.lang.String plotName)
Clears the figures associated with the given plot.
|
void |
clearState()
Override this method to clear any internal state that may be kept within the study.
|
Study |
clone()
Creates a clone (copy) of this study.
|
boolean |
crossedAbove(DataSeries series,
int index,
java.lang.Object key1,
double val)
Convenience Method.
|
boolean |
crossedAbove(DataSeries series,
int index,
java.lang.Object key1,
java.lang.Object key2)
Convenience Method.
|
boolean |
crossedAbove(java.lang.Object key1,
double val)
Convenience Method.
|
boolean |
crossedAbove(java.lang.Object key1,
java.lang.Object key2)
Convenience Method.
|
boolean |
crossedBelow(DataSeries series,
int index,
java.lang.Object key1,
double val)
Convenience Method.
|
boolean |
crossedBelow(DataSeries series,
int index,
java.lang.Object key1,
java.lang.Object key2)
Convenience Method.
|
boolean |
crossedBelow(java.lang.Object key1,
double val)
Convenience Method.
|
boolean |
crossedBelow(java.lang.Object key1,
java.lang.Object key2)
Convenience Method.
|
void |
debug(java.lang.String msg)
Logs a debug message to the study log.
|
void |
destroy()
This method is called when the study is being disposed.
|
void |
error(java.lang.String msg)
Logs an error message to the study log.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Fires a property change event for the given property name if the newValue is different from the oldValue
|
java.lang.String |
format(double d)
Formats the give value as a displayable value on the graph.
|
java.lang.String |
get(java.lang.String ID,
java.lang.Object... params)
Retrieves the locale dependent string from the resource bundle identified in
the StudyHeader annotation.
|
java.util.List<BarSize> |
getBarSizes()
Gets the list of bar sizes required by this study.
|
Enums.EntryState |
getEntryState()
Gets the current entry state of this strategy.
|
java.util.List<Figure> |
getFigures()
Gets the list of figures associated with the default plot.
|
java.util.List<Figure> |
getFigures(java.lang.String plotName)
Gets the list of figures associated with the plot with the given name.
|
StudyHeader |
getHeader()
This convenience method gets the StudyHeader annotation defined for this study.
|
java.util.List<Instrument> |
getInstruments()
Gets the list of instruments required by this study.
|
java.lang.String |
getLabel()
Gets the display label for the default plot including setting values.
|
java.lang.String |
getLabel(java.lang.String plotName)
Gets the display label for the given plot including setting values.
|
int |
getMinBars()
Gets the minimum number of bars required to display this study.
|
int |
getMinBars(DataContext ctx)
Gets the minimum number of bars required to display this study.
|
java.lang.Long |
getMinStartTime()
Gets the minimum start time (milliseconds since 1970) required to display this study (null if no minimum is required)
|
java.lang.Long |
getMinStartTime(DataContext ctx)
Gets the minimum start time (milliseconds since 1970) required to display this study (null if no minimum is required)
|
RuntimeDescriptor |
getRuntimeDescriptor()
Gets the 'runtime' descriptor.
|
Settings |
getSettings()
Gets the user defined settings.
|
SettingsDescriptor |
getSettingsDescriptor()
Gets the settings descriptor.
|
Enums.StrategyState |
getState()
Gets the current state of this strategy.
|
java.lang.Float |
getStopPrice()
Gets the current stop price for an active strategy.
|
java.lang.Float |
getTargetPrice()
Gets the current target price (exit price) for an active strategy.
|
void |
info(java.lang.String msg)
Logs an info message to the study log.
|
void |
initialize(Defaults defaults)
This method is called to initialize the design and runtime settings.
|
boolean |
isCancelInProgress()
returns true if the strategy is currently being cancelled.
|
boolean |
isLong()
returns true if this strategy is 'long'.
|
boolean |
isRepaintAllOnUpdate()
Indicates if a full repaint of the graph is necessary when the latest bar is updated.
|
boolean |
isShort()
returns true if this strategy is 'short'.
|
void |
onActivate(OrderContext ctx)
This method is called when the strategy is activated.
|
void |
onBarClose(DataContext ctx)
This method is called when the latest bar in the data series has been closed.
|
void |
onBarClose(OrderContext ctx)
This method is called when the current bar has been closed.
|
void |
onBarOpen(DataContext ctx)
This method is called when the latest bar in the data series is first opened.
|
void |
onBarOpen(OrderContext ctx)
This method is called when the current bar is first opened.
|
void |
onBarUpdate(DataContext ctx)
This method is called when the latest bar in the data series has been updated.
|
void |
onBarUpdate(OrderContext ctx)
This method is called when the current bar has been updated.
|
void |
onDataSeriesMoved(DataContext ctx)
This method is called when the start and end indices of the data series have changed.
|
void |
onDataSeriesUpdated(DataContext ctx)
This method is called when additional historical data is loaded into the data
series or when a new bar has been added to the data series.
|
void |
onDeactivate(OrderContext ctx)
This method is called when the strategy is deactivated.
|
void |
onEnterNow(OrderContext ctx)
This method is called on response to the 'Enter Now' button on the strategy panel.
|
void |
onLoad(Defaults defaults)
This method is called when the study is first loaded and before the
data is loaded.
|
void |
onNewDataSeries(DataContext ctx)
This method is called when a new data series is created.
|
void |
onOrderCancelled(OrderContext ctx,
Order order)
This method is called when an order is cancelled.
|
void |
onOrderFilled(OrderContext ctx,
Order order)
This method is called when an order is filled.
|
void |
onOrderModified(OrderContext ctx,
Order order)
This method is called when an order is cancelled.
|
void |
onOrderRejected(OrderContext ctx,
Order order)
This method is called when an order is rejected.
|
void |
onPositionClosed(OrderContext ctx)
This method is called when the current open position is closed.
|
void |
onReset(OrderContext ctx)
This method is called when the strategy is reset.
|
void |
onSessionEnded(OrderContext ctx,
TimeFrame session)
This method is called when a trading session is ended.
|
void |
onSessionStarted(OrderContext ctx,
TimeFrame session)
This method is called when a trading session is started.
|
void |
onSettingsUpdated(DataContext ctx)
This method is called whenever the settings for the study have been updated.
|
void |
onSignal(OrderContext ctx,
java.lang.Object signalKey)
This method is called when a signal is generated by the study.
|
protected void |
postcalculate(DataContext ctx)
Override this method to perform work after calculate and calculateValues() is called.
|
protected void |
precalculate(DataContext ctx)
Override this method to perform work before calculate and calculateValues() is called.
|
protected void |
removeFigure(Figure figure)
Removes the given figure from the figure list for the default plot (if it exists).
|
protected void |
removeFigure(java.lang.String plotName,
Figure figure)
Removes the given figure from the figure list for the plot associated with the given name.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the given property listener.
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes the given property listener for the given propertyName.
|
double |
round(double d)
Rounds the give value to the minimum value displayable on the graph.
|
void |
setCancelInProgress(boolean b)
Sets the cancel in progress state for this strategy
|
void |
setEntryState(Enums.EntryState state)
Sets the current state of this strategy.
|
void |
setLong(java.lang.Boolean b)
Sets this strategy as "long' (if true)
|
void |
setMinBars(int bars)
Sets the minimum number of bars required to display this study.
|
void |
setMinStartTime(java.lang.Long time)
Sets the minimum start time (milliseconds since 1970) to display this study (null if no minimum is required)
|
void |
setRuntimeDescriptor(RuntimeDescriptor desc)
Sets the 'runtime' descriptor.
|
void |
setSettings(Settings settings)
Sets the user defined settings.
|
void |
setSettingsDescriptor(SettingsDescriptor sd)
Sets the settings descriptor.
|
void |
setState(Enums.StrategyState state)
Sets the current state of this strategy.
|
void |
setStopPrice(java.lang.Float price)
Sets the stop price for the active strategy.
|
void |
setTargetPrice(java.lang.Float price)
Sets the target price for the active strategy.
|
void |
setVetoCloseOnDeactivate(boolean b) |
void |
warning(java.lang.String msg)
Logs a warning message to the study log.
|
public void initialize(Defaults defaults)
defaults
- system defaultspublic void onLoad(Defaults defaults)
defaults
- system defaultsprotected void precalculate(DataContext ctx)
ctx
- data contextprotected void postcalculate(DataContext ctx)
ctx
- data contextprotected void calculate(int index, DataContext ctx)
index
- - index in the data seriesctx
- - Data Contextprotected void calculateValues(DataContext ctx)
ctx
- data contextpublic boolean isRepaintAllOnUpdate()
public void onBarOpen(DataContext ctx)
ctx
- data contextpublic void onBarUpdate(DataContext ctx)
ctx
- data contextpublic void onBarClose(DataContext ctx)
ctx
- data contextpublic void onDataSeriesMoved(DataContext ctx)
ctx
- data contextpublic void onDataSeriesUpdated(DataContext ctx)
ctx
- data contextpublic void onNewDataSeries(DataContext ctx)
ctx
- data contextpublic void onSettingsUpdated(DataContext ctx)
ctx
- data contextpublic void clearState()
public final RuntimeDescriptor getRuntimeDescriptor()
public final void setRuntimeDescriptor(RuntimeDescriptor desc)
desc
- runtime descriptor objectpublic final SettingsDescriptor getSettingsDescriptor()
public final void setSettingsDescriptor(SettingsDescriptor sd)
sd
- descriptor objectpublic final Settings getSettings()
public final void setSettings(Settings settings)
settings
- public java.util.List<BarSize> getBarSizes()
public java.util.List<Instrument> getInstruments()
public final StudyHeader getHeader()
public java.lang.String getLabel()
public java.lang.String getLabel(java.lang.String plotName)
plotName
- name of the study plotprotected final void clearFigures()
protected final void clearFigures(java.lang.String plotName)
plotName
- name of the study plotprotected final void addFigure(Figure figure)
figure
- figure to addprotected final void addFigureFront(Figure figure)
figure
- figure to addprotected final void addFigure(java.lang.String plotName, Figure figure)
plotName
- name of the study plotfigure
- figure to addprotected final void addFigureFront(java.lang.String plotName, Figure figure)
plotName
- name of the study plotfigure
- figure to addprotected final void removeFigure(Figure figure)
figure
- figure to removeprotected final void removeFigure(java.lang.String plotName, Figure figure)
plotName
- name of the study plotfigure
- figure to removepublic final java.util.List<Figure> getFigures()
public final java.util.List<Figure> getFigures(java.lang.String plotName)
plotName
- name of the study plotpublic int getMinBars()
public int getMinBars(DataContext ctx)
ctx
- data contextpublic void setMinBars(int bars)
bars
- minimum number of barspublic java.lang.Long getMinStartTime()
public java.lang.Long getMinStartTime(DataContext ctx)
ctx
- data contextpublic void setMinStartTime(java.lang.Long time)
time
- minimum start time (milliseconds since 1970)public void onActivate(OrderContext ctx)
ctx
- order contextpublic void onSessionStarted(OrderContext ctx, TimeFrame session)
ctx
- order contextsession
- time framepublic void onSessionEnded(OrderContext ctx, TimeFrame session)
ctx
- order contextsession
- time frame sessionpublic void onBarOpen(OrderContext ctx)
ctx
- order contextpublic void onBarUpdate(OrderContext ctx)
ctx
- order contextpublic void onBarClose(OrderContext ctx)
ctx
- order contextpublic void onSignal(OrderContext ctx, java.lang.Object signalKey)
ctx
- order contextsignalKey
- public void onDeactivate(OrderContext ctx)
ctx
- order contextpublic void setVetoCloseOnDeactivate(boolean b)
public void onReset(OrderContext ctx)
ctx
- order contextpublic void onPositionClosed(OrderContext ctx)
ctx
- order contextpublic void onEnterNow(OrderContext ctx)
ctx
- order contextpublic void onOrderFilled(OrderContext ctx, Order order)
ctx
- order contextorder
- order that was filledpublic void onOrderCancelled(OrderContext ctx, Order order)
ctx
- order contextorder
- order that was cancelledpublic void onOrderRejected(OrderContext ctx, Order order)
ctx
- order contextorder
- order that was rejectedpublic void onOrderModified(OrderContext ctx, Order order)
public final Enums.StrategyState getState()
public final void setState(Enums.StrategyState state)
state
- strategy statepublic final Enums.EntryState getEntryState()
public final void setEntryState(Enums.EntryState state)
state
- entry statepublic final boolean isLong()
public final boolean isShort()
public final void setLong(java.lang.Boolean b)
b
- flag that indicates if this strategy is longpublic final boolean isCancelInProgress()
public final void setCancelInProgress(boolean b)
b
- true if this strategy is being cancelledpublic final java.lang.Float getStopPrice()
public final void setStopPrice(java.lang.Float price)
price
- stop pricepublic final java.lang.Float getTargetPrice()
public final void setTargetPrice(java.lang.Float price)
price
- target price (null for no target)public final java.lang.String get(java.lang.String ID, java.lang.Object... params)
ID
- identifier in the resource bundlepublic final double round(double d)
d
- - the value to roundpublic final java.lang.String format(double d)
d
- - the value to roundpublic final boolean crossedAbove(java.lang.Object key1, java.lang.Object key2)
key1
- - key that identifies the first series of valueskey2
- - key that identifies the second series of valuespublic final boolean crossedAbove(DataSeries series, int index, java.lang.Object key1, java.lang.Object key2)
series
- - series that contains the valuesindex
- - index in the data serieskey1
- - key that identifies the first series of valueskey2
- - key that identifies the second series of valuespublic final boolean crossedAbove(java.lang.Object key1, double val)
key1
- - key that identifies the first series of valuesval
- -value to cross abovepublic final boolean crossedAbove(DataSeries series, int index, java.lang.Object key1, double val)
series
- - series that contains the valuesindex
- - index in the data serieskey1
- - key that identifies the first series of valuesval
- -value to cross abovepublic final boolean crossedBelow(java.lang.Object key1, java.lang.Object key2)
key1
- - key that identifies the first series of valueskey2
- - key that identifies the second series of valuespublic final boolean crossedBelow(DataSeries series, int index, java.lang.Object key1, java.lang.Object key2)
series
- - series that contains the valuesindex
- - index in the data serieskey1
- - key that identifies the first series of valueskey2
- - key that identifies the second series of valuespublic final boolean crossedBelow(java.lang.Object key1, double val)
key1
- - key that identifies the first series of valuesval
- -value to cross belowpublic final boolean crossedBelow(DataSeries series, int index, java.lang.Object key1, double val)
series
- - series that contains the valuesindex
- - index in the data serieskey1
- - key that identifies the first series of valuesval
- -value to cross belowpublic final void debug(java.lang.String msg)
msg
- debug messagepublic final void info(java.lang.String msg)
msg
- info messagepublic final void warning(java.lang.String msg)
msg
- warning messagepublic final void error(java.lang.String msg)
msg
- error messagepublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- property change listenerpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- name of the propertylistener
- property change listenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- property change listenerpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- name of the propertylistener
- property change listenerprotected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyName
- name of the propertyoldValue
- old (previous) value for this propertynewValue
- new value for the propertypublic void destroy()
public Study clone()
clone
in class java.lang.Object