I've observed this in the past, but this is using
Live JForex FXDD ver 2.28.5 with JForex API ver. 2.9.4
It appears to me that there is a bug in the API or in JForex's structures
relating to charts when a local Strategy attempts to iterate through
available charts based on Instrument.
When the chart is created from the "Instruments" area in JForex
using "Open Chart" then it is always found as expected.
But if the chart Instrument is subsequently changed, or if the
chart is created through "cloning" of another chart, then
the Strategy may be unable to detect the chart through iteration
based upon the Instrument.
Here is a snippet of the code used to search for charts
with a given instrument, which is either TICK or has an
interval period less than 3 minutes. For these charts
the code would then do something like place graphic
objects on the chart.
It appears that either the Instrument is not recognized
or the other selection criteria fail, unless the chart is
created "fresh" using "Open Chart" from the Instruments
area in JForex.
Issues arise if the chart is "cloned" from another chart
or apparently if the chart Instrument is changed to
match the instrument this code is searching for, but
is then unable to recognize.
I wonder if anybody else has seen or suspected a problem
like this? There's an easy workaround, which is always
to create charts using "Open Chart", but there seems
to be some underlying bug here.
So, to be clear. While the Strategy is already running, and
it has detected some chart(s). Then if we add another
chart by changing an existing chart from one other Instrument
to match the Instrument the Strategy is searching for,
we would expect the Strategy could then detect that
additional chart, but seems not to recognize it ?
Perhaps getCharts(instrument) is not seeing the new chart
in the collection.....
HyperScalper
Set<IChart> charts = context.getCharts(instrument); // e.g. EUR/USD
for (IChart chart : charts) {
boolean useThisChart = false;
if (chart.getSelectedPeriod()==Period.TICK) {
useThisChart=true; // specifically check for a tick chart
}
if (!useThisChart) {
Period period = chart.getSelectedPeriod();
Unit unit = period.getUnit();
// then also check for 3 minute or less Period chart
if (unit.getInterval()<=180000) useThisChart=true;
}
if (!useThisChart) continue; // skip this chart
// place marks on this chart, since it is
// either a TICK chart of has an interval short enough
}