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.

every 2 seconds && modify && SLprice
 Post subject: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Fri 12 Apr, 2013, 16:05 
User avatar

User rating: 0
Joined: Sun 03 Mar, 2013, 15:45
Posts: 34
Location: China, guangdong
double MySMA =Double.parseDouble(String .format("%.5f",indicators.sma(MyInstrument, MyPeriod, MyOfferSide, IIndicators.AppliedPrice.OPEN, MySMATimePeriod, 0)));
MyOrder = engine.submitOrder("BUY", MyInstrument, OrderCommand.BUYSTOP_BYBID, 0.001, MySMA,10);


Can you help me how to use the MySMA price every two seconds for MyOrder stop-loss price to modify?
I think it's too difficult!


 
 Post subject: Re: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Fri 12 Apr, 2013, 16:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Subcribe to a Period.TWO_SECS feed and run the code from there, see:
https://www.dukascopy.com/wiki/#Chart_feeds/Subscribe_to_a_feed


 
 Post subject: Re: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Fri 12 Apr, 2013, 16:28 
User avatar

User rating: 0
Joined: Sun 03 Mar, 2013, 15:45
Posts: 34
Location: China, guangdong
API Support wrote:
Subcribe to a Period.TWO_SECS feed and run the code from there, see:
https://www.dukascopy.com/wiki/#Chart_feeds/Subscribe_to_a_feed




Please elaborate..


 
 Post subject: Re: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Fri 12 Apr, 2013, 17:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Provide full example strategy of yours and describe which part you can't figure out how to implement.


 
 Post subject: Re: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Mon 15 Apr, 2013, 08:32 
User avatar

User rating: 0
Joined: Sun 03 Mar, 2013, 15:45
Posts: 34
Location: China, guangdong
API Support wrote:
Provide full example strategy of yours and describe which part you can't figure out how to implement.


OK!this is my code ..I want to modify the openPrice every ten seconds...
But the results have remained unchanged,please tell me where is the problem?

import com.dukascopy.api.*;
public class ModifyLimitOrderWithMessages implements IStrategy {

    private IConsole console;
    private IEngine engine;
    private IHistory history;   
    private IOrder order;
   
    public void onStart(IContext context) throws JFException {
        engine = context.getEngine();
        console = context.getConsole();
        history = context.getHistory();
       
        ITick tick = history.getLastTick(Instrument.EURUSD);
        double openPrice = tick.getBid() + 0.0020;
        double slippage = 1;
       
        order = engine.submitOrder("order1" , Instrument.EURUSD, IEngine.OrderCommand.BUYSTOP_BYBID, 0.001, openPrice, slippage);
        console.getOut().println(String.format("%s, amount=%s, open price=%s",order.getLabel(), order.getAmount(), order.getOpenPrice()));
        order.waitForUpdate(2000);
       
        while(slippage>0)
        order.setOpenPrice(openPrice+0.002);
        order.waitForUpdate(10000);
}


 
 Post subject: Re: every 2 seconds && modify && SLprice Post rating: 0   Post Posted: Mon 15 Apr, 2013, 09:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
use the onBar method with 10 sec bar filtration, see onBar description here:
https://www.dukascopy.com/wiki/#Strategy_API


 

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