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.

Вопрос по фракталам
 Post subject: Вопрос по фракталам Post rating: 0   New post Posted: Fri 15 Apr, 2011, 00:16 

User rating: 0
Joined: Tue 09 Sep, 2008, 18:55
Posts: 9
I write a strategy based on Fractals arrows:

   @Configurable("Indicators timeframe")
        public Period ind_period = Period.ONE_HOUR;
...................................
        tperiod = 0;
        if (ind_period == Period.ONE_MIN) tperiod = 0;
        if (ind_period == Period.FIVE_MINS) tperiod = 1;
        if (ind_period == Period.TEN_MINS) tperiod = 2;
        if (ind_period == Period.FIFTEEN_MINS) tperiod = 3;
        if (ind_period == Period.THIRTY_MINS) tperiod = 4;
        if (ind_period == Period.ONE_HOUR) tperiod = 5;
        if (ind_period == Period.FOUR_HOURS) tperiod = 6;
        if (ind_period == Period.DAILY) tperiod = 7;
        if (ind_period == Period.WEEKLY) tperiod = 8;
        if (ind_period == Period.MONTHLY) tperiod = 9;
....................................
    // fractal calculation
    public double GetFractal(Instrument instrument, int mode) throws JFException {
          //mode = 1 - upper fractal; mode = 2 - lower fractal;
          double tempup = 0, tempdn = 0, fup = 0, fdn = 0;
          double[] fractal = indicators.fractal(instrument, ind_period, OfferSide.BID, tperiod, LookBack);
          if (!Double.isNaN(fractal[0])) fup = fractal[0];
          if (!Double.isNaN(fractal[1])) fdn = fractal[1];
          if ( fup != 0 && fdn == 0 && mode == 1) return(fup);
          if ( fdn != 0 && fup == 0 && mode == 2) return(fdn);
          print("F 0  = " + fractal[0] + "  F 1 = " + fractal[1]  );
          return(0);
    }
....................................
// function call
    double upfractal = GetFractal(instrument, 1);
    double dnfractal = GetFractal(instrument, 2);



Please take a look on the attached screen shot. My strategy should respond to arrows only instead of the indicator changes in whole.


Attachments:
fractals.PNG [80.73 KiB]
Downloaded 573 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: Вопрос по фракталам Post rating: 0   New post Posted: Fri 15 Apr, 2011, 16:07 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please make sure you apply filtration by instrument.
Also, please have a look at the following post: https://www.dukascopy.com/swiss/english ... hp?p=21773


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Sun 17 Apr, 2011, 12:41 

User rating: 0
Joined: Tue 09 Sep, 2008, 18:55
Posts: 9
Of course, I use the Instrument filtration.
I have no problem with receiving fractal signals.
But, look at the attachment, I receive the fractal signal by my strastegy at a place, where indicator doesn't put an arrow. It is very strange.


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Mon 18 Apr, 2011, 07:55 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please include the code you use for filtration and a value of the 'LookBack' variable in your post.


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Mon 18 Apr, 2011, 20:59 

User rating: 0
Joined: Tue 09 Sep, 2008, 18:55
Posts: 9
@Configurable("Instrument")
public Instrument currentInstrument = Instrument.EURUSD;

@Configurable("Fractal look back")
public int LookBack = 2;

@Configurable("Indicators timeframe")
public Period ind_period = Period.ONE_HOUR;


public void onStart(IContext context) throws JFException
{
tperiod = 0;
if (ind_period == Period.ONE_MIN) tperiod = 0;
if (ind_period == Period.FIVE_MINS) tperiod = 1;
if (ind_period == Period.TEN_MINS) tperiod = 2;
if (ind_period == Period.FIFTEEN_MINS) tperiod = 3;
if (ind_period == Period.THIRTY_MINS) tperiod = 4;
if (ind_period == Period.ONE_HOUR) tperiod = 5;
if (ind_period == Period.FOUR_HOURS) tperiod = 6;
if (ind_period == Period.DAILY) tperiod = 7;
if (ind_period == Period.WEEKLY) tperiod = 8;
if (ind_period == Period.MONTHLY) tperiod = 9;

return;
}

public double GetFractal(Instrument instrument, int mode) throws JFException {
//mode = 1 - upper fractal; mode = 2 - lower fractal;
// function returns zero or actual fractal
double tempup = 0, tempdn = 0, fup = 0, fdn = 0;
double[] fractal = indicators.fractal(instrument, ind_period, OfferSide.BID, tperiod, LookBack);
if (!Double.isNaN(fractal[0])) fup = fractal[0];
if (!Double.isNaN(fractal[1])) fdn = fractal[1];
if ( fup != 0 && fdn == 0 && mode == 1) return(fup);
if ( fdn != 0 && fup == 0 && mode == 2) return(fdn);
print("F 0 = " + fractal[0] + " F 1 = " + fractal[1] );
return(0);
}

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

if (instrument != currentInstrument) {
return;
}

//----------- Fractal -----------

double upfractal = GetFractal(instrument, 1);
double dnfractal = GetFractal(instrument, 2);

if (upfractal != 0) {......}
if (dnfractal != 0) {......}

return;
}


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Tue 19 Apr, 2011, 08:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
The workspace on your screenshot contains Fractal(3) indicator which means you opened the chart with an incorrect time frame:
  if (ind_period == Period.FIFTEEN_MINS) tperiod = 3; 

The following code might be useful:
public void onStart(IContext context) throws JFException {
  IChart chart = context.getChart(currentInstrument);
  chart.addIndicator(indicators.getIndicator("FRACTAL"), new Object[]{tperiod});
...
}


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Tue 19 Apr, 2011, 10:58 

User rating: 0
Joined: Tue 09 Sep, 2008, 18:55
Posts: 9
"Fractal(3)" at the workspace on my screenshot means that I use parameter Lookback = 3 ("Number of bars on sides" in the indicator settings).

How does it associate with time frame?


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Tue 19 Apr, 2011, 13:44 

User rating: 0
Joined: Tue 09 Sep, 2008, 18:55
Posts: 9
It seems, I understand....

I'm using this calling of fractal:
double[] fractal(Instrument instrument, Period period, OfferSide side, int timePeriod, int shift)

So, timePeriod in this function is the adjustable parameter of Fractal indicator?

And in my example I should call the indicator:
double[] fractal = indicators.fractal(instrument, ind_period, OfferSide.BID, LookBack, 0);

Is it correct?


 
 Post subject: Re: Вопрос по фракталам Post rating: 0   New post Posted: Wed 20 Apr, 2011, 07:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
That's right, "timePeriod" (or "Number of bars on sides") is Fractal indicator's optional parameter.
double[] fractal = indicators.fractal(instrument, ind_period, OfferSide.BID, LookBack, 0); 

Calculates fractal values for the current candle.


 

Jump to:  

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