Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Console print nothing!
 Post subject: Console print nothing! Post rating: 0   New post Posted: Sun 10 Jun, 2018, 03:39 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
private IConsole console;
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
}

public void onTick(Instrument instrument, ITick tick) throws JFException {
console.getOut().println("Instrument:" + instrument + " ask price:" + tick.getAsk());
}

Code print nothing...


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Mon 11 Jun, 2018, 14:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Most likely you are trying to invoke onTick method in Market Offline hours.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Mon 11 Jun, 2018, 15:51 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
Most likely you are trying to invoke onTick method in Market Offline hours.

Thanks ,I will try it.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 15 Jun, 2018, 02:14 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
Most likely you are trying to invoke onTick method in Market Offline hours.



But yesterday I used the same code to print log, it still printed nothing...


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 15 Jun, 2018, 11:42 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It's impossible to identify problem only by few line of code. Please, provide full your strategy sample.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 15 Jun, 2018, 11:54 
User avatar

User rating: 13
Joined: Mon 27 Jul, 2015, 16:30
Posts: 110
Location: Canada, Mission
for tick.getBid/Ask you have to imply history - example: history.getLastTick(Instrument.EURUSD).getAsk()

import com.dukascopy.api.IHistory;

////on class //
this.history = context.getHistory();


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 15 Jun, 2018, 15:54 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
It's impossible to identify problem only by few line of code. Please, provide full your strategy sample.


That's the examples in Jforex,console didn't print the instrument......

package examples;

import java.util.*;
import java.text.*;

import com.dukascopy.api.*;

public class BollingerBandExample implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;

    @Configurable("selectedInstrument:")
    public Instrument selectedInstrument = Instrument.EURUSD;
    @Configurable("selectedPeriod:")
    public Period selectedPeriod = Period.TEN_MINS;
    @Configurable("stopLossPips:")
    public int stopLossPips = 25;
    @Configurable("takeProfitPips:")
    public int takeProfitPips = 50;

    private boolean lowCross = false;
    private boolean upperCross = false;

    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss");

    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();

        context.setSubscribedInstruments(Collections.singleton(selectedInstrument), true);
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (!instrument.equals(selectedInstrument) || !period.equals(selectedPeriod)) {
            return;
        }
   

    console.getOut().println("Instrument:" + selectedInstrument);

        long time = bidBar.getTime();
        Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, selectedPeriod, new OfferSide[] {OfferSide.BID},
                "BBANDS", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {20, 2.0, 2.0, 0}, Filter.WEEKENDS, 1, time, 0);
        double bollingerUpperValue = ((double[]) indicatorResult[0])[0];
        double bollingerMiddleValue = ((double[]) indicatorResult[1])[0];
        double bollingerLowerValue = ((double[]) indicatorResult[2])[0];

        if (askBar.getClose() < bollingerLowerValue) {
            lowCross = true;
        }
        if (bidBar.getClose() > bollingerUpperValue) {
            upperCross = true;
        }

        if (lowCross && askBar.getClose() >= bollingerLowerValue) {
            boolean existLong = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existLong = order.isLong();
                    if (existLong) {
                        break;
                    }
                }
            }

            if (!existLong) {
                double stopLoss = bidBar.getClose() - selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = bidBar.getClose() + selectedInstrument.getPipValue() * takeProfitPips;

                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.BUY, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }

            upperCross = false;
            lowCross = false;

        } else if (upperCross && bidBar.getClose() <= bollingerUpperValue) {
            boolean existShort = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existShort = !order.isLong();
                    if (existShort) {
                        break;
                    }
                }
            }

            if (!existShort) {
                double stopLoss = askBar.getClose() + selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = askBar.getClose() - selectedInstrument.getPipValue() * takeProfitPips;

                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.SELL, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }

            upperCross = false;
            lowCross = false;
        }
    }

    private String getLabel(long time) {
        return "IVF" + DATE_FORMAT.format(time) + generateRandom(10000) + generateRandom(10000);
    }

    private String generateRandom(int n) {
        int randomNumber = (int) (Math.random() * n);
        String answer = "" + randomNumber;
        if (answer.length() > 3) {
            answer = answer.substring(0, 4);
        }
        return answer;
    }
}


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 15 Jun, 2018, 16:11 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
JP7 wrote:
for tick.getBid/Ask you have to imply history - example: history.getLastTick(Instrument.EURUSD).getAsk()

import com.dukascopy.api.IHistory;

////on class //
this.history = context.getHistory();



I have already used IHistory.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Sat 16 Jun, 2018, 08:55 
User avatar

User rating: 13
Joined: Mon 27 Jul, 2015, 16:30
Posts: 110
Location: Canada, Mission
There you Go !
Moved printing line to onTick(Instrument instrument, ITick tick)
I did not work because you call ITick tick onBar
((( public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws ….)))

 
import java.util.*;
import java.text.*;
 
import com.dukascopy.api.*;
 
public class BollingerBandExample implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
 
    @Configurable("selectedInstrument:")
    public Instrument selectedInstrument = Instrument.EURUSD;
    @Configurable("selectedPeriod:")
    public Period selectedPeriod = Period.TEN_MINS;
    @Configurable("stopLossPips:")
    public int stopLossPips = 25;
    @Configurable("takeProfitPips:")
    public int takeProfitPips = 50;
 
    private boolean lowCross = false;
    private boolean upperCross = false;
 
    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss");
 
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.setHistory(context.getHistory());
        this.setContext(context);
        this.indicators = context.getIndicators();
        this.setUserInterface(context.getUserInterface());
 
        context.setSubscribedInstruments(Collections.singleton(selectedInstrument), true);
    }
 
    public void onAccount(IAccount account) throws JFException {
    }
 
    public void onMessage(IMessage message) throws JFException {
    }
 
    public void onStop() throws JFException {
    }
 
    public void onTick(Instrument instrument, ITick tick) throws JFException {
      console.getOut().println("Instrument:" + instrument + " ask price:" + tick.getAsk());
    }
 
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (!instrument.equals(selectedInstrument) || !period.equals(selectedPeriod)) {
            return;
        }


        long time = bidBar.getTime();
        Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, selectedPeriod, new OfferSide[] {OfferSide.BID},
                "BBANDS", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {20, 2.0, 2.0, 0}, Filter.WEEKENDS, 1, time, 0);
        double bollingerUpperValue = ((double[]) indicatorResult[0])[0];
        @SuppressWarnings("unused")
      double bollingerMiddleValue = ((double[]) indicatorResult[1])[0];
        double bollingerLowerValue = ((double[]) indicatorResult[2])[0];
 
        if (askBar.getClose() < bollingerLowerValue) {
            lowCross = true;
        }
        if (bidBar.getClose() > bollingerUpperValue) {
            upperCross = true;
        }
 
        if (lowCross && askBar.getClose() >= bollingerLowerValue) {
            boolean existLong = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existLong = order.isLong();
                    if (existLong) {
                        break;
                    }
                }
            }
 
            if (!existLong) {
                double stopLoss = bidBar.getClose() - selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = bidBar.getClose() + selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.BUY, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
 
        } else if (upperCross && bidBar.getClose() <= bollingerUpperValue) {
            boolean existShort = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existShort = !order.isLong();
                    if (existShort) {
                        break;
                    }
                }
            }
 
            if (!existShort) {
                double stopLoss = askBar.getClose() + selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = askBar.getClose() - selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.SELL, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
        }
    }
 
    private String getLabel(long time) {
        return "IVF" + DATE_FORMAT.format(time) + generateRandom(10000) + generateRandom(10000);
    }
 
    private String generateRandom(int n) {
        int randomNumber = (int) (Math.random() * n);
        String answer = "" + randomNumber;
        if (answer.length() > 3) {
            answer = answer.substring(0, 4);
        }
        return answer;
    }

   public IHistory getHistory() {
      return history;
   }

   public void setHistory(IHistory history) {
      this.history = history;
   }

   public IContext getContext() {
      return context;
   }

   public void setContext(IContext context) {
      this.context = context;
   }

   public IUserInterface getUserInterface() {
      return userInterface;
   }

   public void setUserInterface(IUserInterface userInterface) {
      this.userInterface = userInterface;
   }
}


Attachments:
BollingerBandExample.java [5.31 KiB]
Downloaded 93 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Sat 16 Jun, 2018, 09:06 
User avatar

User rating: 13
Joined: Mon 27 Jul, 2015, 16:30
Posts: 110
Location: Canada, Mission
Method 2 - calling IHistory onBar

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
console.getOut().println("Instrument:" + instrument + " ask price:" + history.getLastTick(instrument).getAsk());


 
import java.util.*;
import java.text.*;
 
import com.dukascopy.api.*;
 
public class BollingerBandExample implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
 
    @Configurable("selectedInstrument:")
    public Instrument selectedInstrument = Instrument.EURUSD;
    @Configurable("selectedPeriod:")
    public Period selectedPeriod = Period.TEN_MINS;
    @Configurable("stopLossPips:")
    public int stopLossPips = 25;
    @Configurable("takeProfitPips:")
    public int takeProfitPips = 50;
 
    private boolean lowCross = false;
    private boolean upperCross = false;
 
    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss");
 
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.setHistory(context.getHistory());
        this.setContext(context);
        this.indicators = context.getIndicators();
        this.setUserInterface(context.getUserInterface());
 
        context.setSubscribedInstruments(Collections.singleton(selectedInstrument), true);
    }
 
    public void onAccount(IAccount account) throws JFException {
    }
 
    public void onMessage(IMessage message) throws JFException {
    }
 
    public void onStop() throws JFException {
    }
 
    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
 
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
          console.getOut().println("Instrument:" + instrument + " ask price:" + history.getLastTick(instrument).getAsk());

       if (!instrument.equals(selectedInstrument) || !period.equals(selectedPeriod)) {
            return;
        }


        long time = bidBar.getTime();
        Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, selectedPeriod, new OfferSide[] {OfferSide.BID},
                "BBANDS", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {20, 2.0, 2.0, 0}, Filter.WEEKENDS, 1, time, 0);
        double bollingerUpperValue = ((double[]) indicatorResult[0])[0];
        @SuppressWarnings("unused")
      double bollingerMiddleValue = ((double[]) indicatorResult[1])[0];
        double bollingerLowerValue = ((double[]) indicatorResult[2])[0];
 
        if (askBar.getClose() < bollingerLowerValue) {
            lowCross = true;
        }
        if (bidBar.getClose() > bollingerUpperValue) {
            upperCross = true;
        }
 
        if (lowCross && askBar.getClose() >= bollingerLowerValue) {
            boolean existLong = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existLong = order.isLong();
                    if (existLong) {
                        break;
                    }
                }
            }
 
            if (!existLong) {
                double stopLoss = bidBar.getClose() - selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = bidBar.getClose() + selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.BUY, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
 
        } else if (upperCross && bidBar.getClose() <= bollingerUpperValue) {
            boolean existShort = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existShort = !order.isLong();
                    if (existShort) {
                        break;
                    }
                }
            }
 
            if (!existShort) {
                double stopLoss = askBar.getClose() + selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = askBar.getClose() - selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.SELL, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
        }
    }
 
    private String getLabel(long time) {
        return "IVF" + DATE_FORMAT.format(time) + generateRandom(10000) + generateRandom(10000);
    }
 
    private String generateRandom(int n) {
        int randomNumber = (int) (Math.random() * n);
        String answer = "" + randomNumber;
        if (answer.length() > 3) {
            answer = answer.substring(0, 4);
        }
        return answer;
    }

   public IHistory getHistory() {
      return history;
   }

   public void setHistory(IHistory history) {
      this.history = history;
   }

   public IContext getContext() {
      return context;
   }

   public void setContext(IContext context) {
      this.context = context;
   }

   public IUserInterface getUserInterface() {
      return userInterface;
   }

   public void setUserInterface(IUserInterface userInterface) {
      this.userInterface = userInterface;
   }
}


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Sun 17 Jun, 2018, 09:59 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
JP7 wrote:
There you Go !
Moved printing line to onTick(Instrument instrument, ITick tick)
I did not work because you call ITick tick onBar
((( public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws ….)))

 
import java.util.*;
import java.text.*;
 
import com.dukascopy.api.*;
 
public class BollingerBandExample implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
 
    @Configurable("selectedInstrument:")
    public Instrument selectedInstrument = Instrument.EURUSD;
    @Configurable("selectedPeriod:")
    public Period selectedPeriod = Period.TEN_MINS;
    @Configurable("stopLossPips:")
    public int stopLossPips = 25;
    @Configurable("takeProfitPips:")
    public int takeProfitPips = 50;
 
    private boolean lowCross = false;
    private boolean upperCross = false;
 
    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss");
 
    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.setHistory(context.getHistory());
        this.setContext(context);
        this.indicators = context.getIndicators();
        this.setUserInterface(context.getUserInterface());
 
        context.setSubscribedInstruments(Collections.singleton(selectedInstrument), true);
    }
 
    public void onAccount(IAccount account) throws JFException {
    }
 
    public void onMessage(IMessage message) throws JFException {
    }
 
    public void onStop() throws JFException {
    }
 
    public void onTick(Instrument instrument, ITick tick) throws JFException {
      console.getOut().println("Instrument:" + instrument + " ask price:" + tick.getAsk());
    }
 
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (!instrument.equals(selectedInstrument) || !period.equals(selectedPeriod)) {
            return;
        }


        long time = bidBar.getTime();
        Object[] indicatorResult = indicators.calculateIndicator(selectedInstrument, selectedPeriod, new OfferSide[] {OfferSide.BID},
                "BBANDS", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {20, 2.0, 2.0, 0}, Filter.WEEKENDS, 1, time, 0);
        double bollingerUpperValue = ((double[]) indicatorResult[0])[0];
        @SuppressWarnings("unused")
      double bollingerMiddleValue = ((double[]) indicatorResult[1])[0];
        double bollingerLowerValue = ((double[]) indicatorResult[2])[0];
 
        if (askBar.getClose() < bollingerLowerValue) {
            lowCross = true;
        }
        if (bidBar.getClose() > bollingerUpperValue) {
            upperCross = true;
        }
 
        if (lowCross && askBar.getClose() >= bollingerLowerValue) {
            boolean existLong = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existLong = order.isLong();
                    if (existLong) {
                        break;
                    }
                }
            }
 
            if (!existLong) {
                double stopLoss = bidBar.getClose() - selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = bidBar.getClose() + selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.BUY, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
 
        } else if (upperCross && bidBar.getClose() <= bollingerUpperValue) {
            boolean existShort = false;
            for (IOrder order : engine.getOrders(selectedInstrument)) {
                if (order.getState() == IOrder.State.OPENED || order.getState() == IOrder.State.FILLED) {
                    existShort = !order.isLong();
                    if (existShort) {
                        break;
                    }
                }
            }
 
            if (!existShort) {
                double stopLoss = askBar.getClose() + selectedInstrument.getPipValue() * stopLossPips;
                double takeProfit = askBar.getClose() - selectedInstrument.getPipValue() * takeProfitPips;
 
                engine.submitOrder(getLabel(time), selectedInstrument, IEngine.OrderCommand.SELL, 0.1, 0, 5, stopLoss, takeProfit, 0, "");
            }
 
            upperCross = false;
            lowCross = false;
        }
    }
 
    private String getLabel(long time) {
        return "IVF" + DATE_FORMAT.format(time) + generateRandom(10000) + generateRandom(10000);
    }
 
    private String generateRandom(int n) {
        int randomNumber = (int) (Math.random() * n);
        String answer = "" + randomNumber;
        if (answer.length() > 3) {
            answer = answer.substring(0, 4);
        }
        return answer;
    }

   public IHistory getHistory() {
      return history;
   }

   public void setHistory(IHistory history) {
      this.history = history;
   }

   public IContext getContext() {
      return context;
   }

   public void setContext(IContext context) {
      this.context = context;
   }

   public IUserInterface getUserInterface() {
      return userInterface;
   }

   public void setUserInterface(IUserInterface userInterface) {
      this.userInterface = userInterface;
   }
}




Do you think console.getout() can't work in OnBar()?


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Sun 17 Jun, 2018, 11:27 
User avatar

User rating: 13
Joined: Mon 27 Jul, 2015, 16:30
Posts: 110
Location: Canada, Mission
Method 2 - calling IHistory onBar

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
console.getOut().println("Instrument:" + instrument + " ask price:" + history.getLastTick(instrument).getAsk());


Please run the tests I gave you before you make statements ….. I answer your questions and I gave you examples …..

;) Cheers


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Mon 18 Jun, 2018, 16:40 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
JP7 wrote:
Method 2 - calling IHistory onBar

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
console.getOut().println("Instrument:" + instrument + " ask price:" + history.getLastTick(instrument).getAsk());


Please run the tests I gave you before you make statements ….. I answer your questions and I gave you examples …..

;) Cheers


Thanks for your help,but unfortunately, consle still print nothing.
Console.getout() is a methond that call by user, but user can't see how it was encapsulated,So I need the developer's help.
I don't think it have difference between OnBar() or OnTick().


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Tue 19 Jun, 2018, 16:11 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
console.getOut() method in your strategy example works correctly.
Note that onBar executes only on fully formed candles.

Image


Attachments:
onBar.JPG [71.36 KiB]
Downloaded 287 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Thu 21 Jun, 2018, 00:58 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
console.getOut() method in your strategy example works correctly.
Note that onBar executes only on fully formed candles.

Image



Does it work well in BackTest?


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Thu 21 Jun, 2018, 08:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Bletherfeng wrote:
API Support wrote:
console.getOut() method in your strategy example works correctly.
Note that onBar executes only on fully formed candles.

Image



Does it work well in BackTest?

Yes, of course. But in HT you need select "Show messages" checkbox

Image


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Thu 21 Jun, 2018, 15:17 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
Bletherfeng wrote:
API Support wrote:
console.getOut() method in your strategy example works correctly.
Note that onBar executes only on fully formed candles.

Image



Does it work well in BackTest?

Yes, of course. But in HT you need select "Show messages" checkbox

Image



But my console didn't print anything...


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Thu 21 Jun, 2018, 15:48 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Very strange. Take a screenshot and upload it here.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 22 Jun, 2018, 02:40 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
API Support wrote:
Very strange. Take a screenshot and upload it here.



Image
https://drive.google.com/open?id=11DZfF ... FgdxmYkvMv

Please help.


 
 Post subject: Re: Console print nothing! Post rating: 0   New post Posted: Fri 22 Jun, 2018, 08:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You talked about problem with console in backtesting, or not? In this case messages will be printed in "Historical Tester" tab.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com