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.

T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ?
 Post subject: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Wed 27 Jun, 2012, 13:47 

User rating: 0
Joined: Wed 22 Feb, 2012, 10:34
Posts: 4
Hello,
There is JForex inbuild indicator called T3 ( not TEMA ). There are options to change colour when there is trend Up, or when there is trend Down. Is it possible to add custom sound alert ? It would be a great option.


 
The Best Answer  Post subject: Re: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Thu 28 Jun, 2012, 09:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
see:
https://www.dukascopy.com/wiki/#Create_Alert/Play_sound_on_indicator_trend_change


 
 Post subject: Re: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Sat 30 Jun, 2012, 12:59 

User rating: 0
Joined: Wed 22 Feb, 2012, 10:34
Posts: 4
Works great. Is it possible to add popup window with the information on which pair ( if you use it on few ) trend change ?


 
 Post subject: Re: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Sat 30 Jun, 2012, 13:40 

User rating: 0
Joined: Wed 22 Feb, 2012, 10:34
Posts: 4
Ok I added it by myself.


 
 Post subject: Re: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Fri 06 Jul, 2012, 08:45 

User rating: 0
Joined: Wed 22 Feb, 2012, 10:34
Posts: 4
Is it possible to add email alert to this code ? I tried by myself but I am not a programmist, and it not work....
Here is a code :

package jforex.codebase;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.sound.sampled.*;

import com.dukascopy.api.*;
import com.dukascopy.api.IIndicators.AppliedPrice;

@RequiresFullAccess
public class T3EURAUD implements IStrategy {
    private IContext context;
    private IIndicators indicators;
    private IHistory history;
   
    @Configurable("")
    public Instrument instrument = Instrument.EURAUD;
    @Configurable("")
    public Period period = Period.FIVE_MINS;
    @Configurable("")
    public OfferSide side = OfferSide.BID;
    @Configurable("")
    public AppliedPrice appliedPrice = AppliedPrice.CLOSE;
    @Configurable("")
    public Filter filter = Filter.NO_FILTER;
    @Configurable("")
    public int t3TimePeriod = 15;
    @Configurable("")
    public double t3vFactor = 1;
    //@Configurable("")
    public File trendUpAlarm = new File("C:\\JForex\\malong.wav");   
    //@Configurable("")
    public File trendDownAlarm = new File("C:\\JForex\\mashort.wav");

    private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss SSS");
    private static int LAST = 2;
    private static int PREV = 1;
    private static int SCND_TO_LAST = 0;
   
    public void onStart(IContext context) throws JFException {
        this.context = context;
        this.indicators = context.getIndicators();   
        this.history = context.getHistory();
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));       
        print("start");
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (!this.period.equals(period) || !this.instrument.equals(instrument)){
            return;
        }

        double[] t3 = indicators.t3(instrument, period, side, appliedPrice, t3TimePeriod, t3vFactor, filter, 3, bidBar.getTime(), 0);
       
        if(t3[PREV] > t3[SCND_TO_LAST] && t3[LAST] < t3[PREV]){ //down trend
            playSound(trendDownAlarm);
            showPopup(instrument.toString() + " DOWN");
        } else if(t3[PREV] < t3[SCND_TO_LAST] && t3[LAST] > t3[PREV]){ //up trend
            playSound(trendUpAlarm);
            showPopup(instrument.toString() + " UP");
        }
    }
   
    private void playSound(File wavFile) throws JFException {
        print(sdf.format(history.getLastTick(instrument).getTime()) + " play: " + wavFile.getName());
        try {
            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(wavFile);
            AudioFormat af = audioInputStream.getFormat();
            int nSize = (int) (af.getFrameSize() * audioInputStream.getFrameLength());
            byte[] audio = new byte[nSize];
            DataLine.Info info = new DataLine.Info(Clip.class, af, nSize);
            audioInputStream.read(audio, 0, nSize);
            Clip clip = (Clip) AudioSystem.getLine(info);
            clip.open(af, audio, 0, nSize);
            clip.start();
        } catch (Exception e) {
            e.printStackTrace();
            print("error on play: " + e.getMessage());
            //throw new JFException(e);
        }
    }
     private void showPopup(String text) {
            JOptionPane optionPane = new JOptionPane(text, JOptionPane.WARNING_MESSAGE);
            JDialog dialog = optionPane.createDialog("Alеrt");
            dialog.setVisible(true);
        }
   


    private void print(Object o){
        context.getConsole().getOut().println(o);
    }

    public void onAccount(IAccount account) throws JFException {    }
    public void onMessage(IMessage message) throws JFException {    }
    public void onStop() throws JFException {}
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }

}



 
 Post subject: Re: T3 - Triple Exponential Moving Average (T3) - sound alert on colour change ? Post rating: 0   New post Posted: Fri 06 Jul, 2012, 09:00 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Send_e-mail
Also you can find here an example strategy which uses this:
viewtopic.php?f=7&t=47277


 

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