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.

false signals in my strategy
 Post subject: false signals in my strategy Post rating: 0   New post Posted: Wed 13 Mar, 2013, 06:12 
User avatar

User rating: 0
Joined: Wed 07 Mar, 2012, 06:02
Posts: 58
Location: SwitzerlandSwitzerland
Hello,

I have a strategy in place that needs some improvement for preventing false entries, could you please add the following to my code.
(the below is just an example for a sell signal, though both sides are required)

Image

A trade entry should be avoided if the -di is not rising (which it is in the example) and the willr indicator is not touching the -20 line or below at the same time. This filter is valid until 4 bars after the trade entry signal of the strategy, otherwise the trade entry signal is to be cancelled.
For a buy signal, this would mean if the +di is not rising and the willr indicator is not touching the -80 line or above (at the same time) until 4 bars after the buy signal of the strategy, then this trade entry signal is to be ignored.

Below I provide the code snippets where I understand that the protection against false entries need to be added.

        // PLACE ORDER
        if (buySign) {
            orderMgr.closeAllShortOdrers();
            if(orderMgr.canAddOrder(OrderCommand.BUY)) {
                if(useMinMaxStopLoss) {
                    orderMgr.submitOrder(OrderCommand.BUY, instrument, tick, min3);
                } else {
                    orderMgr.submitOrder(OrderCommand.BUY, instrument, tick);
                }
            }

        } else if (sellSign) {
            orderMgr.closeAllLongOdrers();
            if(orderMgr.canAddOrder(OrderCommand.SELL)) {
                if(useMinMaxStopLoss) {
                    orderMgr.submitOrder(OrderCommand.SELL, instrument, tick, max3);
                } else {
                    orderMgr.submitOrder(OrderCommand.SELL, instrument, tick);
                }
            }
        }
    }


        public IOrder submitOrder(OrderCommand orderCommand, Instrument instr, ITick t) throws JFException {

            if(!canAddOrder(orderCommand)) {
                return null;
            }

            double stopLossPrice = 0.0;


/************************************************/
/*  ORDER                                       */
    /************************************************/

    private class MyOrder {

        private IOrder order;
        private Map<String, Object> properties;

        MyOrder(IOrder order) {
            this.order = order;
        }

        void setProperty(String key, Object value) {
            if (properties == null) {
                properties = new HashMap();
            }
            properties.put(key, value);
        }

        Object getProperty(String key) {
            return properties.get(key);
        }

        void close() throws JFException {
            if (order == null) {
                return;
            }
            if (order.getState() == IOrder.State.CREATED) {
                order.waitForUpdate();
            }
            if (order.getState() == IOrder.State.OPENED) {
                order.close(); // close 1
                order.waitForUpdate();
            }
            if (order.getState() == IOrder.State.FILLED) {
                // order in state OPENNED -> close 1 -> order FILLED before CLOSED -> recieves message ORDER_ALREADY_FILLED -> close 2
                order.close(); // close 2
                order = null;
            }
        }

        boolean isActive() throws JFException {
            if (order != null && order.getState() != IOrder.State.CLOSED && order.getState() != IOrder.State.CANCELED) {
                return true;
            }
            return false;
        }

        boolean inState(IOrder.State state) {
            return order.getState() == state;
        }


 
 Post subject: Re: false signals in my strategy Post rating: 0   New post Posted: Wed 13 Mar, 2013, 08:29 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Unfortunately we do not provide with a private programming support.
Please resort to External Programmers https://www.dukascopy.com/swiss/english/forex/jforex/external/


 
 Post subject: Re: false signals in my strategy Post rating: 0   New post Posted: Wed 13 Mar, 2013, 12:50 
User avatar

User rating: 0
Joined: Wed 07 Mar, 2012, 06:02
Posts: 58
Location: SwitzerlandSwitzerland
I dont understand, you helped me orginally create this strategy end of last year !? :roll:


 

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