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.

drawing strategy to the screen
 Post subject: drawing strategy to the screen Post rating: 0   New post Posted: Sun 21 Nov, 2010, 20:13 

User rating: 0
Joined: Sun 21 Nov, 2010, 19:57
Posts: 1
I have a simple strategy based on Stochastic oscillator see below.
My questions:
1) How can i have slowK and slowD drawn to the screen? I have seen the wiki article about drawOutput() by i dont see any example.
2) When i try to test the strategy below and add a Stochastic indicator to the chart, i get different results between what is drawn to the screen and the the calculated slowk/slowD.
Thanks!

@Configurable("Instrument") public Instrument confInstrument = Instrument.EURUSD; 
@Configurable("Period") public Period confPeriod = Period.FOUR_HOURS;
public void onBar(Instrument instrument, Period period, IBar askbar,
         IBar bidbar) throws JFException {
      double[] s1 = indicators.stoch(instrument, period, OfferSide.ASK,
            40, 10, MaType.SMA, 20, MaType.SMA, 1)
      double slowK= s1[0];
      double slowD = s1[1];
}


 
 Post subject: Re: drawing strategy to the screen Post rating: 0   New post Posted: Mon 22 Nov, 2010, 04:46 

User rating: 3
Joined: Mon 30 Aug, 2010, 13:06
Posts: 27
hello

1. The easiest way is to add the stochastic indicator to the chart, with the same parameters your strategy uses. This makes more sence than drawing it from within the strategy.

2. Make sure that you check for the correct period and instrument in the onBar function before you calculate the stoch values from period and instrument. also make sure that you use the same parameters for the indicator applied to the chart and your strategy.

best

simplex


 

Jump to:  

  © 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