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.

ibar bugs
 Post subject: ibar bugs Post rating: 0   New post Posted: Tue 04 Aug, 2015, 13:20 
User avatar

User rating: 2
Joined: Sat 02 May, 2015, 20:20
Posts: 20
Location: Ukraine, Kyiv
Well I have attempted to make use of several custom indicators I spent many hours programming, believing that once the indicators were correct I could just "plug them in" to a strategy. Not even close however. Ibar history has serious issues. calling multiple time frames will confuse it for sure after a certain amount of time. Then it's garbage inputs to your strategy. Eventually the code below will not return the correct values as read from the indy on the chart. Getting the high from the indy is impossible for some reason even though it is one of the outputs!! Simply trying to calculate new highs on volume on 2 different time frames will run you into trouble. Soooo... for the newbies out there, get used to writing everything to a file from your indy and reading it from your strategy. It would be helpful if there were some global variables like MT4 so we could at least pass a variable reliably around the platform, be it strategy, indicator or plugin.

Support, is there such a thing in java for us?????

Thanks!
TBB

if (period.equals(Period.ONE_MIN)){
        bestvolhighest1m = 0;
        long bid1mtime = 0;
        double bid1m = Double.NaN;
        double ask1m = Double.NaN;
        for (int count1m = 0; count1m < 1000; count1m++) {             
                try {
                   bid1mtime = history.getBar(instrument, Period.ONE_MIN, OfferSide.BID, count1m).getTime();
                } catch (Exception e) { // Catch exception if any
                console.getOut().print("history access eror in 1min: " + e.getMessage());
                }
                try {
                   bid1m = history.getBar(instrument, Period.ONE_MIN, OfferSide.BID, count1m).getVolume();
                } catch (Exception e) { // Catch exception if any
                console.getOut().print("history access eror in 1min: " + e.getMessage());
                }
                try {
                   ask1m = history.getBar(instrument, Period.ONE_MIN, OfferSide.ASK, count1m).getVolume();
                } catch (Exception e) { // Catch exception if any
                console.getOut().print("history access eror in 1min: " + e.getMessage());
                }
                   //print("bid1mtime ="+sdf.format(bid1mtime)+" bid1m = "+bid1m+" ask1m = "+ask1m+" bestvolhighest1m = "+bestvolhighest1m);
                        if (bid1mtime != 0 && TimeHour(bid1mtime) < Starttime_cumulation /*&& TimeDay(inputs[0][i].getTime()) == TimeDay(inputs[0][inputs[0].length - 1].getTime()) && TimeMonth(inputs[0][i].getTime()) == TimeMonth(inputs[0][inputs[0].length - 1].getTime()) && TimeYear(inputs[0][i].getTime()) == TimeYear(inputs[0][inputs[0].length - 1].getTime()) */ ) {
                            //console.getOut().println("i = "+i+" time = "+TimeHour(inputs[0][i].getTime())+" reg time = "+inputs[0][i].getTime()+ " date = "+TimeDay(inputs[0][i].getTime())+ " current day = "+ TimeDay(inputs[0][inputs[0].length - 1].getTime())  );
                            //bestvolhighest1m = 0;
                            break;
                        }
                        if (bid1mtime != 0 && TimeHour(bid1mtime) > Starttime_cumulation /*&& TimeDay(inputs[0][i].getTime()) == TimeDay(inputs[0][inputs[0].length - 1].getTime()) && TimeMonth(inputs[0][i].getTime()) == TimeMonth(inputs[0][inputs[0].length - 1].getTime()) && TimeYear(inputs[0][i].getTime()) == TimeYear(inputs[0][inputs[0].length - 1].getTime()) */ ) {
                            //print("bid1mtime ="+sdf.format(bid1mtime)+" bid1m = "+bid1m+" ask1m = "+ask1m);
                            if ( bid1m + ask1m > bestvolhighest1m) {
                                bestvolhighest1m = bid1m + ask1m;
                                  //print("bid1mtime ="+sdf.format(bid1mtime)+" bid1m = "+bid1m+" ask1m = "+ask1m+" bestvolhighest1m = "+bestvolhighest1m);
                            }
                           
                        }
               
           }
       

if (period.equals(Period.FIVE_MINS)){
           IBar onebarago5m = null;
           onebarago5m = history.getBar(instrument,Period.FIVE_MINS, OfferSide.BID, 1);
           bestvolhighest5m = 0;long
           bid5mtime = 0;
           double bid5m = Double.NaN;
           double ask5m = Double.NaN;
           for (int count5m = 0; count5m < 200; count5m++) {             
                   try {
                       bid5mtime = history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, count5m).getTime();
                   } catch (Exception e) { // Catch exception if any
                      console.getOut().print("history access eror in 1min: " + e.getMessage());
                   } 
                   try { 
                       bid5m = history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, count5m).getVolume();
                   } catch (Exception e) { // Catch exception if any
                      console.getOut().print("history access eror in 1min: " + e.getMessage());
                   }
                   try {
                       ask5m = history.getBar(instrument, Period.FIVE_MINS, OfferSide.ASK, count5m).getVolume();
                   } catch (Exception e) { // Catch exception if any
                     console.getOut().print("history access eror in 1min: " + e.getMessage());
                   }
                   //print("bid5mtime ="+sdf.format(bid5mtime)+" bid5m = "+bid5m+" ask5m = "+ask5m+" bestvolhighest5m = "+bestvolhighest5m);
                        if (bid5mtime != 0 && TimeHour(bid5mtime) < Starttime_cumulation /*&& TimeDay(inputs[0][i].getTime()) == TimeDay(inputs[0][inputs[0].length - 1].getTime()) && TimeMonth(inputs[0][i].getTime()) == TimeMonth(inputs[0][inputs[0].length - 1].getTime()) && TimeYear(inputs[0][i].getTime()) == TimeYear(inputs[0][inputs[0].length - 1].getTime()) */ ) {
                            //console.getOut().println("i = "+i+" time = "+TimeHour(inputs[0][i].getTime())+" reg time = "+inputs[0][i].getTime()+ " date = "+TimeDay(inputs[0][i].getTime())+ " current day = "+ TimeDay(inputs[0][inputs[0].length - 1].getTime())  );
                            //bestvolhighest5m = 0;
                            break;
                        }
                        if (bid5mtime != 0 && TimeHour(bid5mtime) > Starttime_cumulation /*&& TimeDay(inputs[0][i].getTime()) == TimeDay(inputs[0][inputs[0].length - 1].getTime()) && TimeMonth(inputs[0][i].getTime()) == TimeMonth(inputs[0][inputs[0].length - 1].getTime()) && TimeYear(inputs[0][i].getTime()) == TimeYear(inputs[0][inputs[0].length - 1].getTime()) */ ) {
                            //print("bid5mtime ="+sdf.format(bid5mtime)+" bid5m = "+bid5m+" ask5m = "+ask5m);
                            if ( bid5m + ask5m > bestvolhighest5m) {
                                bestvolhighest5m = bid5m + ask5m;
                                  //print("bid5mtime ="+sdf.format(bid5mtime)+" bid5m = "+bid5m+" ask5m = "+ask5m+" bestvolhighest5m = "+bestvolhighest5m);
                            }
                           
                        }
               
           }
           


 
 Post subject: Re: ibar bugs Post rating: 0   New post Posted: Wed 12 Aug, 2015, 11:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide full example to reproduce the problem.
Here you can find an example on how to calculate custom indicator from strategy: Use custom indicator in strategies


 

Jump to:  

cron
  © 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