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.

Trying to filter MACROSS
 Post subject: Trying to filter MACROSS Post rating: 0   New post Posted: Mon 10 Oct, 2011, 09:04 

User rating: -
Hi, I am trying to filter a MA Cross strategy using the MINMAX indicator

I have this and it makes some difference as it makes less trades now but it doesnt seem right, when I change the period for the minmax it makes no difference ? I am only at copy and paste level really :)

Any help would be most appreciated

double fastMA = indicators.sma(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, fastMAPeriod, 0);
                double fastMAonPreviousBar = indicators.sma(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, fastMAPeriod, 1);
                double slowMA = indicators.smma(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, slowMAPeriod, 0);
                double slowMAonPreviousBar = indicators.smma(instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, slowMAPeriod, 0);   
                double[] MM = null;
        MM = indicators.minMax(instrument, myPeriod, OfferSide.BID,
                AppliedPrice.CLOSE, 20, shift);
        double Min = MM[0];
        double Max = MM[0];
               
                if (positionsTotal(instrument) == 0)
                {
                    ////////// --- Condition for BUY --- //////////                           
                    if (bidPrice > Max && fastMAonPreviousBar < slowMAonPreviousBar && fastMA > slowMA)
                    {
                    buy(instrument, engine, profitLimit, lossLimit, volume);
 
                    }
               
                else 
                    ////////// --- Condition for Sell --- //////////
                    if (askPrice < Min && fastMAonPreviousBar > slowMAonPreviousBar && fastMA < slowMA)
                    {
                        sell(instrument, engine, profitLimit, lossLimit, volume);                   
                    }                   
              }


 
 Post subject: Re: Trying to filter MACROSS Post rating: 0   New post Posted: Tue 11 Oct, 2011, 09:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
kiwitraderfx wrote:
I have this and it makes some difference as it makes less trades now but it doesnt seem right, when I change the period for the minmax it makes no difference ?
Please consider adding print statements in order to log the values and see which execution path gets taken and why. See:
https://www.dukascopy.com/wiki/index.php ... ing_values


 

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