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.

how to set SL to an indicator?
 Post subject: how to set SL to an indicator? Post rating: 0   New post Posted: Tue 22 Feb, 2011, 13:57 

User rating: 0
Joined: Thu 24 Jun, 2010, 04:04
Posts: 27
how to write the code when submitting an short order if i want to set SL to high band of emaEnvelope indicator of current candle

since SL should be double and emaEnvelope returns an array of double,if i just use
SL_ema_10mins_B=indicators.emaEnvelope(instrument,Period.TEN_MINS,OfferSide.BID,AppliedPrice.CLOSE, 5, 0.1,indicatorFilter, 2, prevBar1.getTime(), 2);
order = engine.submitOrder(getLabel(instrument), instrument, OrderCommand.SELL, amount,currentAsk,slip,SL_ema_10mins_B[0][0],0);

there will be java.lang.ArrayIndexOutOfBoundsException,how to deal with that?


 
 Post subject: Re: how to set SL to an indicator? Post rating: 0   New post Posted: Wed 23 Feb, 2011, 04:05 

User rating: 0
Joined: Thu 24 Jun, 2010, 04:04
Posts: 27
ok i can use double []emaEnvelope to set SL,but how to use double[][] emaEnvelope?

and what are double[][] emaEnvelope outputs?


 
 Post subject: Re: how to set SL to an indicator? Post rating: 0   New post Posted: Wed 23 Feb, 2011, 09:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
If you want to set an order stop loss price to the current candle ema envelope high band value please use the following code:
double [] currentEmaEnvelope = indicators.emaEnvelope(instrument, Period.TEN_MINS, OfferSide.BID, AppliedPrice.CLOSE, 5, 0.1, 0);
order = engine.submitOrder(getLabel(instrument), instrument, OrderCommand.SELL, amount,currentAsk,slip,currentEmaEnvelope[1] ,0);

When you need to get ema envelope indicator values with specified filter or you need to get the indicator values for several candles you have to use double[][] emaEnvelope. For example to get ema envelope values for last 3 candles you can use the following code:
double [][] ema_10 = indicators.emaEnvelope(instrument, Period.TEN_MINS, OfferSide.BID, AppliedPrice.CLOSE, 5, 0.1, Filter.NO_FILTER, 3, prevBar.getTime(), 0);

The ema_10[0][0] contains the 3rd candle lower band value, the ema_10[0][2] contains the last candle lower band value, ema_10[1][2] value contains the last candle upper band value

For additional information how to use indicators from a strategy, please take a look at the following JForex Wiki page: https://www.dukascopy.com/wiki/index.php ... Indicators


 
 Post subject: Re: how to set SL to an indicator? Post rating: 0   New post Posted: Thu 24 Feb, 2011, 14:29 

User rating: 0
Joined: Thu 24 Jun, 2010, 04:04
Posts: 27
Support wrote:
Hi,
If you want to set an order stop loss price to the current candle ema envelope high band value please use the following code:
double [] currentEmaEnvelope = indicators.emaEnvelope(instrument, Period.TEN_MINS, OfferSide.BID, AppliedPrice.CLOSE, 5, 0.1, 0);
order = engine.submitOrder(getLabel(instrument), instrument, OrderCommand.SELL, amount,currentAsk,slip,currentEmaEnvelope[1] ,0);

When you need to get ema envelope indicator values with specified filter or you need to get the indicator values for several candles you have to use double[][] emaEnvelope. For example to get ema envelope values for last 3 candles you can use the following code:
double [][] ema_10 = indicators.emaEnvelope(instrument, Period.TEN_MINS, OfferSide.BID, AppliedPrice.CLOSE, 5, 0.1, Filter.NO_FILTER, 3, prevBar.getTime(), 0);

The ema_10[0][0] contains the 3rd candle lower band value, the ema_10[0][2] contains the last candle lower band value, ema_10[1][2] value contains the last candle upper band value

For additional information how to use indicators from a strategy, please take a look at the following JForex Wiki page: https://www.dukascopy.com/wiki/index.php ... Indicators



thanks,supporter,one more question about indicator macdExt,i use double [] method ,does
[0]=fast line
[1]=slow line
[2]=macd hist

is this right?


 
 Post subject: Re: how to set SL to an indicator? Post rating: 0   New post Posted: Fri 25 Feb, 2011, 10:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
liyinan wrote:
i use double [] method ,does
[0]=fast line
[1]=slow line
[2]=macd hist

is this right?

[0] - MACD
[1] - MACD Signal
[2] - MACD Hist


 

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