|
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.
slowK/D value in Stoch |
Victor
|
Post subject: slowK/D value in Stoch |
Post rating: 0
|
Posted: Tue 24 Aug, 2010, 09:18
|
|
User rating: 2
Joined: Thu 19 May, 2011, 09:37 Posts: 86 Location: India, Chennai
|
Hi Support, Can you give example code of picking up values of indicators.. like slowk,slowd,FastF value in indicators.stoch. I would like to build a strategy around this and couldn't go further. I do see lots of examples of multiple MA cross overs but failed to see any samples on this. (converted samples from MT for MACD and Stoch is there). But if I know how to pick a specific cvalue from Stoch or MACD for that matter. Thanks in advance for the help.
|
|
|
|
 |
[Frank]
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 05:15
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Hi, I even need help with stoschastic function. I used the following code: double stoch[][] = indicators.stoch(myInstrument, myPeriodo, OfferSide.BID, fastKPeriod, slowKPeriod, IIndicators.MaType.SMA, slowDPeriod, IIndicators.MaType.SMA, Filter.WEEKENDS, numberOfCandlesBefore, bidBar.getTime(), numberOfCandlesAfter) ; print("stoch[0][0]: " + stoch[0][0]); it prints values, but I don't know if they are K o D value. Could anyone help me to find out the K ed D values of stochastic indicator for the current bar ? Best regards, Frank
|
|
|
|
 |
Victor
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 10:42
|
|
User rating: 2
Joined: Thu 19 May, 2011, 09:37 Posts: 86 Location: India, Chennai
|
Frank wrote: Hi, I even need help with stoschastic function. I used the following code: double stoch[][] = indicators.stoch(myInstrument, myPeriodo, OfferSide.BID, fastKPeriod, slowKPeriod, IIndicators.MaType.SMA, slowDPeriod, IIndicators.MaType.SMA, Filter.WEEKENDS, numberOfCandlesBefore, bidBar.getTime(), numberOfCandlesAfter) ; print("stoch[0][0]: " + stoch[0][0]); it prints values, but I don't know if they are K o D value. Could anyone help me to find out the K ed D values of stochastic indicator for the current bar ? Best regards, Frank Frank: I was trying to build a stoch cross over condition but couldn't find the slowk, slowd values. Let's see whether anybody can support here. by the way your print function doesn't work for me. tnd.Surya
|
|
|
|
 |
[Frank]
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 13:30
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
sorry, I forgot to include the onBar function:
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { ... your code ... double stoch[][] = indicators.stoch(myInstrument, myPeriodo, OfferSide.BID, fastKPeriod, slowKPeriod, IIndicators.MaType.SMA, slowDPeriod, IIndicators.MaType.SMA, Filter.WEEKENDS, numberOfCandlesBefore, bidBar.getTime(), numberOfCandlesAfter) ; print("stoch[0][0]: " + stoch[0][0]);
}
Best regards, Frank
|
|
|
|
 |
[Frank]
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 13:45
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
and even these declaration-assignments: public Instrument myInstrument = Instrument.EURUSD; public Period myPeriodo = Period.ONE_MIN;
int fastKPeriod = 10;
int slowKPeriod = 3 ;
int slowDPeriod = 3;
int numberOfCandlesBefore = 3;
int numberOfCandlesAfter = 0;
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { ... your code ...
double stoch[][] = indicators.stoch(myInstrument, myPeriodo, OfferSide.BID, fastKPeriod, slowKPeriod, IIndicators.MaType.SMA, slowDPeriod, IIndicators.MaType.SMA, Filter.WEEKENDS, numberOfCandlesBefore, bidBar.getTime(), numberOfCandlesAfter) ;
print("stoch[0][0]: " + stoch[0][0]);
} Best regards, Frank
|
|
|
|
 |
[Frank]
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 14:16
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
for print function use the following code public void print(String string) { console.getOut().println(string); } Best regards, Frank
|
|
|
|
 |
Victor
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Thu 02 Sep, 2010, 19:26
|
|
User rating: 2
Joined: Thu 19 May, 2011, 09:37 Posts: 86 Location: India, Chennai
|
Frank wrote: for print function use the following code public void print(String string) { console.getOut().println(string); } Best regards, Frank Hi Frank Many thanks. If you change the print command to print("stoch[0][0]:" + stoch[0][1] + " " + stoch[1][1]); You will get answer like below: 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 18:22:30 stoch[0][0]:50.66666666665921 53.60722610721933 the first one is slowK value and second one is slowD value. Hope this helps. rgds/Surya
|
|
|
|
 |
[Frank]
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Fri 03 Sep, 2010, 01:41
|
|
User rating: 0
Joined: Thu 02 Sep, 2010, 05:01 Posts: 49
|
Thanks Surya. I noted however that values printed are different from values in chart (even considering the different Timezone). The values are the same if I use valueK = stoch[0][2]; valueD = stoch[1][2]; but I even found a simpler code: int numberOfCandlesBefore = 1;
valueK = stoch[0][0]; valueD = stoch[1][0]; you will find that values printed are equal to values in the chart. A note about comparing printed values and values in the chart, consider tha the values in the chart are in GMT TIME and printed values are adjusted to local time, so here is the procedure to compare values: 1. open the pairs used in the program and add the stoch indicator 2. choose a time, for example 2010.08.31 00:00, note the K and D values 3. consider your TimeZone, for example GMT +3 4. add the difference to time so you obtain 2010.08.31 03:00, find this time among printed values and you will find that K and D values are equal to values in the chart Best regards, Frank
|
|
|
|
 |
Victor
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Fri 03 Sep, 2010, 05:24
|
|
User rating: 2
Joined: Thu 19 May, 2011, 09:37 Posts: 86 Location: India, Chennai
|
Thanks Frank, I did verify the values with the chart and it did match. I used 5,3,3 and wma. you can check this.
now the next step would be to define the K and D.. separately and use it in the parameter to the logic. If you crack let me know. I guess it could be a new indicator or just use getoutputparameter. I am not sure but am trying to figure out. I am no Java programmer and the T&E method is costing too much time for me.
It seems one need to have Java knowledge to do the trading here. But I will overcome soon. rgds/Surya
|
|
|
|
 |
Victor
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Fri 03 Sep, 2010, 07:12
|
|
User rating: 2
Joined: Thu 19 May, 2011, 09:37 Posts: 86 Location: India, Chennai
|
Frank: ok use these u will get the net result double slowk = stoch[0][0]; double slowd = stoch[1][0]; the first [0] = slowk and first[1]=slowd the second [0] represents the candle numbers from long to parameters (if it is 3 to looks back then 0 = 3rd candle 1 = 2nd candle and 2 = current candle) or is it the same thing you had already mentioned. and thanks. I did start the process from the print function you mentioned.
@Support: thnx. If the assumptions/explanations is wrong pls do let us know.
rgds/Surya
|
|
|
|
 |
API Support
|
Post subject: Re: slowK/D value in Stoch |
Post rating: 0
|
Posted: Mon 06 Sep, 2010, 13:57
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|