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.

leverage alert
 Post subject: leverage alert Post rating: 0   Post Posted: Mon 16 Apr, 2012, 23:37 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
Hi,

I would like to setup alerts on leverage change


 
The Best Answer  Post subject: Re: leverage alert Post rating: 0   Post Posted: Tue 17 Apr, 2012, 11:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Do you mean leverage or "use of leverage"?


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Tue 01 May, 2012, 22:24 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
use of leverage


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Tue 01 May, 2012, 22:27 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
any change "use of leverage" raises alert


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Wed 02 May, 2012, 07:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider doing something like this:
package jforex.account;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import com.dukascopy.api.*;

public class UseOfLeverageAlerter implements IStrategy {

    double lastUseOfLeverage;
    private IAccount account;
    private IConsole console;
   
    @Configurable("Use dialog")
    public boolean showDialog = true;
   
    @Override
    public void onStart(IContext context) throws JFException {
        account = context.getAccount();
        console = context.getConsole();
        lastUseOfLeverage = context.getAccount().getUseOfLeverage();

    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
        double currentUseOfLeverage = account.getUseOfLeverage();
        if(Double.compare(currentUseOfLeverage, lastUseOfLeverage) != 0){
            String infoMessage = String.format("Leverage changed from %s to %s",
                    lastUseOfLeverage, currentUseOfLeverage);
            console.getOut().println(infoMessage);
            if(showDialog){
                JOptionPane.showMessageDialog(new JFrame("dialog"),infoMessage);
            }
            lastUseOfLeverage = currentUseOfLeverage;
        }
    }

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}

    @Override
    public void onMessage(IMessage message) throws JFException {}

    @Override
    public void onAccount(IAccount account) throws JFException {}

    @Override
    public void onStop() throws JFException {}

}


Attachments:
UseOfLeverageAlerter.java [1.51 KiB]
Downloaded 288 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Wed 02 May, 2012, 17:33 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
when changing the "Use of Leverage", can be told that some alarm,song,melodies?


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Wed 02 May, 2012, 18:01 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
can be replaced by INFO messages, the audible alarm ?


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Thu 03 May, 2012, 09:53 
User avatar

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


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Thu 03 May, 2012, 12:05 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
Can you send me to attach. the finished program, simply, use of leverage> 0, the alarm is active, that is all


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Thu 03 May, 2012, 12:52 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
just change the condition:
if(Double.compare(currentUseOfLeverage, lastUseOfLeverage) != 0){

to
if(Double.compare(currentUseOfLeverage, 0) == 1 && Double.compare(lastUseOfLeverage, 0) == 0){
See more on compare:
https://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html#compare(java.lang.Object,%20java.lang.Object)


 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Sun 06 May, 2012, 22:31 
User avatar

User rating: 0
Joined: Tue 07 Feb, 2012, 19:18
Posts: 7
Location: Serbia, Belgrade
I tried to add an alarm sound start in this program, but to exclude and expel this message:



21:19:21 Strategy "UseOfLeverageAlerter" is stopped at 2012-05-06 21:19:21.569 GMT on the local computer with parameters "Alarm file"=[D:\dukas\wav\feelgood.wav], "Use dialog"=[true]

21:19:21 Stopping "UseOfLeverageAlerter" strategy at 2012-05-06 21:19:21.569 GMT on the local computer
21:19:21 java.security.AccessControlException: access denied (java.io.FilePermission D:\dukas\wav\feelgood.wav read) @ jforex.account.UseOfLeverageAlerter.playSound(UseOfLeverageAlerter.java:131)


please help me, what did I go wrong?


Attachments:
UseOfLeverageAlerter N.java [2.59 KiB]
Downloaded 292 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: leverage alert Post rating: 0   Post Posted: Thu 10 May, 2012, 15:59 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You have to include this annotation before the class name
@RequiresFullAccess //  let your code to access any file or directory that you need


 

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