$200 for small strategy update - ASAP

valB

New member
Joined
Jan 14, 2023
Posts
2
Likes
0
Hi All,

I need someone to help me update the logic of my algorithm. I need to change the logic in the SRO indicator - the algo needs to place SELL at the market order on the BUY signal and BUY at the market order on the SELL signal. I need to rename/update PROFIT TARGET into STOP order. I want to do some backtests with this setting before making any other significant upgrades. I need it done ASAP, within two days.

Val

=======================================

protected void calculate(int index, DataContext ctx) {
if (!this.getFigures().contains(this.StrategyLight)) {
this.addFigure(this.StrategyLight);
}

this.loadSettings();
DataSeries series = ctx.getDataSeries();
if (index >= 1) {
Object input = this.getSettings().getInput("input", BarInput.CLOSE);
double sro = 0.0;
double rHigh = (double)series.getHigh(index);
double rLow = (double)series.getLow(index);
double open = (double)series.getOpen(index);
double close = series.getDouble(index, input, 0.0);
double tRange = (double)series.getTrueRange(index);
if (tRange != 0.0) {
sro = (rHigh - open + (close - rLow)) / (2.0 * tRange);
}

series.setDouble(index, ITG_Strategy_Automatic.Values.SRO, sro);
series.setDouble(index, ITG_Strategy_Automatic.Values.BottomHack, 1.0);
series.setDouble(index, ITG_Strategy_Automatic.Values.TopHack, -0.1);
GuideInfo topGuide = this.getSettings().getGuide("topGuide");
double topG = topGuide.getValue();
GuideInfo bottomGuide = this.getSettings().getGuide("bottomGuide");
double bottG = bottomGuide.getValue();
Color upC = this.getSettings().getColor("upColor");
Color nC = this.getSettings().getColor("neutralColor");
Color dnC = this.getSettings().getColor("downColor");
series.setBarColor(index, ITG_Strategy_Automatic.Values.SRO, nC);
if (sro > topG) {
series.setBarColor(index, ITG_Strategy_Automatic.Values.SRO, upC);
}

if (sro < bottG) {
series.setBarColor(index, ITG_Strategy_Automatic.Values.SRO, dnC);
}

boolean sell = sro > topG && sro > this.highSell;
boolean buy = sro < bottG && sro < this.lowBuy;
series.setBoolean(index, ITG_Strategy_Automatic.Signals.SELL, sell);
series.setBoolean(index, ITG_Strategy_Automatic.Signals.BUY, buy);
if (!this.entryTime.equals("End of Bar") || series.isBarComplete(index)) {
String td = this.getSettings().getString("TRADE_DIRECTION");
boolean takeLongs = td.equals("Long and Short") || td.equals("Long Only");
boolean takeShorts = td.equals("Long and Short") || td.equals("Short Only");
Coordinate c;
MarkerInfo marker;
String msg;
if (sell) {
this.lowBuy = Double.MAX_VALUE;
this.highSell = sro;
c = new Coordinate(series.getStartTime(index), sro);
marker = this.getSettings().getMarker("downMarker");
msg = this.get("SELL_HIGH_SRO", new Object[]{Util.round(rHigh, 2), Util.round(sro, 3)});
if (marker.isEnabled() && !series.getBoolean(index, ITG_Strategy_Automatic.Values.ShortMarkerDrawn, false)) {
series.setBoolean(index, ITG_Strategy_Automatic.Values.ShortMarkerDrawn, true);
this.addFigure("Indicator", new Marker(c, Position.TOP, marker, msg));
}

if (takeShorts) {
ctx.signal(index, ITG_Strategy_Automatic.Signals.SELL, msg, rHigh);
}
}

if (buy) {
this.highSell = Double.NEGATIVE_INFINITY;
this.lowBuy = sro;
c = new Coordinate(series.getStartTime(index), sro);
marker = this.getSettings().getMarker("upMarker");
msg = this.get("BUY_LOW_SRO", new Object[]{Util.round(rLow, 2), Util.round(sro, 3)});
if (marker.isEnabled() && !series.getBoolean(index, ITG_Strategy_Automatic.Values.LongMarkerDrawn, false)) {
series.setBoolean(index, ITG_Strategy_Automatic.Values.LongMarkerDrawn, true);
this.addFigure("Indicator", new Marker(c, Position.BOTTOM, marker, msg));
}

if (takeLongs) {
ctx.signal(index, ITG_Strategy_Automatic.Signals.BUY, msg, rLow);
}
}

series.setComplete(index, series.isBarComplete(index));
}
}
}
================================================================
 
Top