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.

BWMFI ind question
 Post subject: BWMFI ind question Post rating: 0   New post Posted: Mon 28 May, 2012, 09:51 

User rating: 0
Joined: Thu 03 Nov, 2011, 21:46
Posts: 68
Location: Russian Federation,
hi support,
how and what options cause this indicator?

example, I want know last collor BAR indicator

Object[] bearsObject1 = indicators.calculateIndicator(currentInstrument, Period.ONE_HOUR, new OfferSide[]{OfferSide.BID}, "BWMFI", null, new Object[]{}, 1);
double bearGreen1 = (Double) bearsObject1[0];
double bearBrown1 = (Double) bearsObject1[1];
double bearBlue1 = (Double) bearsObject1[2];
double bearRose1 = (Double) bearsObject1[3];

if ( bearGreen1 >= 0 ) {

I must be sure that the last color was green ..
please see screenshot

thanks


Attachments:
greenColor.gif [13.82 KiB]
Downloaded 377 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: BWMFI ind question Post rating: 0   New post Posted: Mon 28 May, 2012, 14:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Try the following:
package jforex.strategies.indicators;

import java.awt.Color;

import com.dukascopy.api.*;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.OutputParameterInfo;

public class BWMFIisGreen implements IStrategy {

    private IIndicators indicators;
    private IConsole console;
   
    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("Period")
    public Period period = Period.ONE_MIN;
    @Configurable("Offer side")
    public OfferSide side = OfferSide.BID;
   
   
   
    @Override
    public void onStart(IContext context) throws JFException {
        console = context.getConsole();
        indicators = context.getIndicators();
        IIndicator indicator = indicators.getIndicator("bwmfi");
        double[] bwmfi = indicators.bwmfi(instrument, period, side, 0);
       
        for(int outputNr = 0; outputNr < indicator.getIndicatorInfo().getNumberOfOutputs(); outputNr++){
            if(Double.compare(bwmfi[outputNr],0) != 0){
                OutputParameterInfo info = indicator.getOutputParameterInfo(outputNr);
                console.getOut().println(String.format("Last bwmfi output is \"%s\" of color: %s. Is green: %s",
                      info.getName(), info.getColor(), info.getColor() == Color.GREEN));
            }
        }
       
        console.getOut().println();
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    @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:
BWMFIisGreen.java [1.8 KiB]
Downloaded 276 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: BWMFI ind question Post rating: 0   New post Posted: Mon 28 May, 2012, 14:33 

User rating: 0
Joined: Thu 03 Nov, 2011, 21:46
Posts: 68
Location: Russian Federation,
thanks
BUT:
You make for current color
double[] bwmfi = indicators.bwmfi(instrument, period, side, 0);

I want know PRE color
double[] bwmfi1 = indicators.bwmfi(instrument, period, side, 1);

example I need:
if ( bwmfi1(green1) ) {
buy = true;
and
if ( bwmfi1(brown1) ) {
sell = true;


 
 Post subject: Re: BWMFI ind question Post rating: 0   New post Posted: Tue 29 May, 2012, 07:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
package jforex.strategies.indicators;

import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;

/**
 * The strategy trades according to BWMFI indicator:
 *  - after a green histogram it makes a BUY order,
 *  - after a brown histogram - a SELL order.
 *
 */
public class BWMFIgreenBrown implements IStrategy {

    private IIndicators indicators;
    private IConsole console;
    private IEngine engine;
   
    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("Period")
    public Period period = Period.ONE_MIN;
    @Configurable("Offer side")
    public OfferSide side = OfferSide.BID;
   
    private final int GREEN = 0;
    private final int BROWN = 1;
    private final int BLUE = 2;
    private final int PINK = 3;
   
    private int counter;
   
    @Override
    public void onStart(IContext context) throws JFException {
        console = context.getConsole();
        indicators = context.getIndicators();
        engine = context.getEngine();
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if(instrument != this.instrument || period != this.period){
            return;
        }       
        double[] bwmfi = indicators.bwmfi(instrument, period, side, 1);       
        if(Double.compare(bwmfi[GREEN], 0) != 0){
            engine.submitOrder("greenOrder"+counter++, instrument, OrderCommand.BUY, 0.001);
        } else if(Double.compare(bwmfi[BROWN], 0) != 0){
            engine.submitOrder("brownOrder"+counter++, instrument, OrderCommand.SELL, 0.001);
        }
    }

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

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

    @Override
    public void onStop() throws JFException {}

}


Attachments:
BWMFIgreenBrown.java [1.93 KiB]
Downloaded 278 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: BWMFI ind question Post rating: 0   New post Posted: Tue 29 May, 2012, 09:51 

User rating: 0
Joined: Thu 03 Nov, 2011, 21:46
Posts: 68
Location: Russian Federation,
many thanks support


 

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