일목균형표 전략조건 수정
This commit is contained in:
@@ -695,13 +695,17 @@ public class LiveConditionStatusService {
|
||||
primarySeries.getEndIndex() - evalCount + 1);
|
||||
|
||||
List<BacktestResponse.Signal> signals = new ArrayList<>();
|
||||
boolean inPosition = false;
|
||||
for (int i = startIdx; i <= primarySeries.getEndIndex(); i++) {
|
||||
long barTimeSec = barOpenEpochSec(primarySeries, i);
|
||||
double close = primarySeries.getBar(i).getClosePrice().doubleValue();
|
||||
|
||||
Boolean entryMet = evaluateOverallRuleOnChart(
|
||||
buyDsl, primarySeries, seriesOverrides, market, params, visual, barTimeSec);
|
||||
if (Boolean.TRUE.equals(entryMet)) {
|
||||
Boolean exitMet = evaluateOverallRuleOnChart(
|
||||
sellDsl, primarySeries, seriesOverrides, market, params, visual, barTimeSec);
|
||||
|
||||
if (!inPosition && Boolean.TRUE.equals(entryMet)) {
|
||||
signals.add(BacktestResponse.Signal.builder()
|
||||
.time(barTimeSec)
|
||||
.type("BUY")
|
||||
@@ -709,11 +713,8 @@ public class LiveConditionStatusService {
|
||||
.barIndex(i)
|
||||
.quantity(0)
|
||||
.build());
|
||||
}
|
||||
|
||||
Boolean exitMet = evaluateOverallRuleOnChart(
|
||||
sellDsl, primarySeries, seriesOverrides, market, params, visual, barTimeSec);
|
||||
if (Boolean.TRUE.equals(exitMet)) {
|
||||
inPosition = true;
|
||||
} else if (inPosition && Boolean.TRUE.equals(exitMet)) {
|
||||
signals.add(BacktestResponse.Signal.builder()
|
||||
.time(barTimeSec)
|
||||
.type("SELL")
|
||||
@@ -721,6 +722,7 @@ public class LiveConditionStatusService {
|
||||
.barIndex(i)
|
||||
.quantity(0)
|
||||
.build());
|
||||
inPosition = false;
|
||||
}
|
||||
}
|
||||
return signals;
|
||||
|
||||
@@ -504,6 +504,7 @@ public class StrategyDslToTa4jAdapter {
|
||||
case "LAGGING_GT_PRICE" -> buildChikouVsPriorCloseRule(series, indParams, true);
|
||||
case "LAGGING_LT_PRICE" -> buildChikouVsPriorCloseRule(series, indParams, false);
|
||||
case "LAGGING_ABOVE_PRIOR_CLOUD" -> buildChikouAbovePriorCloudRule(series, indParams);
|
||||
case "CHIKOU_CROSS_ABOVE_PRIOR_CLOUD" -> buildChikouCrossAbovePriorCloudRule(series, indParams);
|
||||
case "VOLUME_GT_MA_RATIO" -> {
|
||||
double ratio = cond.path("compareValue").asDouble(1.5);
|
||||
int len = intP(indParams, "length", 5);
|
||||
@@ -1054,6 +1055,15 @@ public class StrategyDslToTa4jAdapter {
|
||||
return new OverIndicatorRule(close, priorCloudTop);
|
||||
}
|
||||
|
||||
/** 후행스팬이 26봉 전 구름 상단을 상향 돌파하는 순간 (1회성 진입 트리거) */
|
||||
private Rule buildChikouCrossAbovePriorCloudRule(BarSeries s, Map<String, Object> p) {
|
||||
int d = ichimokuChikouDisplacement(p);
|
||||
ClosePriceIndicator close = new ClosePriceIndicator(s);
|
||||
NumericIndicator cloudTop = NumericIndicator.of(ichimokuSpanA(s, p)).max(ichimokuSpanB(s, p));
|
||||
Indicator<Num> priorCloudTop = new PreviousValueIndicator(cloudTop, d);
|
||||
return new CrossedUpIndicatorRule(close, priorCloudTop);
|
||||
}
|
||||
|
||||
/** 종가가 구름 위 */
|
||||
private Rule buildCloudAboveRule(BarSeries s, Map<String, Object> p) {
|
||||
NumericIndicator cloudTop = NumericIndicator.of(ichimokuSpanA(s, p)).max(ichimokuSpanB(s, p));
|
||||
|
||||
Reference in New Issue
Block a user