@krab29, tak teraz na szybko rzuciłem okiem na ten prosty test świecy o 12:45. Trzeba lekko zmodyfikować ten kod, bo liczy świece weekendowe i na dodatek jest bug w jforex albo tak po prostu to działa, w kazdym razie dodatkowo trzeba świece z niedzieli odfiltrować dodając warunek żeby nie liczyło świec z wolumenem 0. Więc ten kod będzie wyglądał tak
Kod: Zaznacz cały
package jforex;
import java.util.*;
import com.dukascopy.api.*;
public class Strategy_30112020_navi implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
public OfferSide side = OfferSide.BID;
private int up = 0;
private int down = 0;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
print("skuteczność wzrostowe : " + ((up * 100) / (up + down)) + "%" );
print("skuteczność spadkowe : " + ((down * 100) / (up + down)) + "%");
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
Date date = new Date(bidBar.getTime());
IBar bar = history.getBar(instrument, Period.FIFTEEN_MINS, side, 1);
if (date.getDay() != 6 && date.getDay() != 7 && bar.getVolume() != 0) {
if (period.equals(Period.FIFTEEN_MINS)) { // bo szukamy na M15
if (date.getHours() == 12 && date.getMinutes() == 45) {
if (isBullBar(bar)) {
up++;
} else {
down++;
}
print("up : " + up + " down: " + down + " " + bar);
//context.pause();
}
}
}
}
public boolean isBullBar(IBar bar) {
return (bar.getOpen() > bar.getClose()) ? false : true;
}
public void print(Object o) {
console.getOut().println(o);
}
}
I okazuje się że takie naiwne podejście dałoby w zeszłym miesiącu 61% skuteczności przy obstawianiu wzrostowych, a za 3 miesiące wstecz byłoby to 56% na EU heh.
btw. na końcu testu wykonywana jest funkcja onStop(). Albo po zatrzymaniu strategii. Można tam wypisywać te wartości.
Więc plan minimum do zarabiania spełniony, bo potrzeba min. 55% przy stałym ryzyku na każdy trejd
btw. Tutaj jest ten sam test tylko ze wstawianiem pionowych linii na tych świecach. Tylko pozmieniali coś i dodali teraz Real-Time i After-Finish w Custom Settings w ustawieniach testu, więc trzeba dać RealTime i nie naciskać stop tylko pause. I miec zaznaczone żeby pokazywało wykres "visual mode"
Kod: Zaznacz cały
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.*;
import java.awt.Color;
public class Strategy_30112020_navi implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private IChart chart;
public OfferSide side = OfferSide.BID;
private int up = 0;
private int down = 0;
IChartObjectFactory factory = null;
public Instrument selectedInstrument = Instrument.EURUSD;
private int counter = 0;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
this.chart = context.getChart(selectedInstrument);
factory = chart.getChartObjectFactory();
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
print("skuteczność wzrostowe : " + ((up * 100) / (up + down)) + "%" );
print("skuteczność spadkowe : " + ((down * 100) / (up + down)) + "%");
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
Date date = new Date(bidBar.getTime());
IBar bar = history.getBar(instrument, Period.FIFTEEN_MINS, side, 1);
if (date.getDay() != 6 && date.getDay() != 7 && bar.getVolume() != 0) {
if (period.equals(Period.FIFTEEN_MINS)) { // bo szukamy na M15
if (date.getHours() == 12 && date.getMinutes() == 45) {
if (isBullBar(bar)) {
up++;
// dodaj linie na wykres
IVerticalLineChartObject line = factory.createVerticalLine(getLabel(instrument), bar.getTime());
line.setColor(Color.RED);
chart.add(line);
} else {
down++;
}
print("up : " + up + " down: " + down + " " + bar);
//context.pause();
}
}
}
}
protected String getLabel(Instrument instrument) {
return instrument.name() + System.currentTimeMillis() + (counter++);
}
public boolean isBullBar(IBar bar) {
return (bar.getOpen() > bar.getClose()) ? false : true;
}
public void print(Object o) {
console.getOut().println(o);
}
}
I dopiero tutaj widać że jest sporo małych świec, prawie doji hyhy. Więc jednak nie jest tak kolorowo jak się wydawało na początku jak pierwszy raz bez visual mode puścisz test.
No ale tak mniej więcej sobie testuję wstępnie różne rzeczy