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.

stop loss change time
 Post subject: stop loss change time Post rating: 0   New post Posted: Thu 16 Aug, 2012, 16:22 
User avatar

User rating: 0
Joined: Thu 13 Oct, 2011, 17:27
Posts: 21
Location: SwitzerlandSwitzerland
hello, what command can i use to get the time stamp of the last stop loss change?

the time stamp of the last tick can be retrieved pretty easily through the history.
now i need the same for the time when my strategy last changed the stop loss.

thanks


 
 Post subject: Re: stop loss change time Post rating: 0   New post Posted: Thu 23 Aug, 2012, 13:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We do not store such information in history but it is possible to capture stop loss change event:
    public void onMessage(IMessage message) throws JFException {
      if(message.getType().equals(IMessage.Type.STOP_LOSS_LEVEL_CHANGED)) {

         System.out.println(dateToStr(message.getCreationTime()));
      }
    }

   public String dateToStr(long time) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") {
         {
            setTimeZone(TimeZone.getTimeZone("GMT"));
         }
      };
      return sdf.format(time);
   }


 
 Post subject: Re: stop loss change time Post rating: 0   New post Posted: Thu 23 Aug, 2012, 18:26 
User avatar

User rating: 0
Joined: Thu 13 Oct, 2011, 17:27
Posts: 21
Location: SwitzerlandSwitzerland
ok thank you for this solution:)

well, i am updating the SL for my oders under the onTick function.
and currently i used to get a lot of these "can't change SL price more than once in a second".
now, what would be perfect is if just before submitting a new SL my strategy would check if the last SL change was long enough ago (more than 1 sec).

can that be done while the onTick function keeps running for all instruments?

thanks


 
 Post subject: Re: stop loss change time Post rating: 0   New post Posted: Mon 27 Aug, 2012, 08:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Set_Stop_Loss_price/Keep_track_on_Stop_Loss_changes


 
 Post subject: Re: stop loss change time Post rating: 0   New post Posted: Wed 29 Aug, 2012, 17:50 
User avatar

User rating: 0
Joined: Thu 13 Oct, 2011, 17:27
Posts: 21
Location: SwitzerlandSwitzerland
oh of course ....we can memorize the lastTickTime:)
things can be so simple sometimes haha
and sorry... this just did not come to my mind:P
thank you so much for your help


 

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