My First Tradingsystem and EA -
1 2 3

thread: My First Tradingsystem and EA

  1. #11
    I have updated the EA a bit. Have tested it using constants that were MACD.
    The optimum in a backtest of this year 2008 was discovered with the following principles:MACD fast MA interval: 8 MACD slow MA interval: 14 MACD signal interval: 2 Here's the altered code for those who want to try it for themselfs:

    Inserted Code // ------------------------------------------------------------------ //| EA #1 | //| ===== | //| Date: 03.08.2008 | //| Author: AdamP | // ------------------------------------------------------------------ #define MAGICNUMBER 01082008 extern double Lots = 1.0; extern double TakeProfit = 200; extern double StopLoss = 50; extern int FastMA = 8; extern int SlowMA = 14; extern int Signal = 2; extern int RSIperiod = 14; // ------------------------------------------------------------------ //| Count open positions | // ------------------------------------------------------------------ int CalculateCurrentOrders() int buys=0,sells=0; // Go through all orders for(int I=0;ilt;OrdersTotal();I ) // We're only interested in trades that are in the trading pool // Closed or canceled orders Aren't interesting for us if(OrderSelect(I,SELECT_BY_POS,MODE_TRADES)==false ) break; // Count positions that were opened by us for the current currency if(OrderSymbol()==Symbol() OrderMagicNumber()==MAGICNUMBER) if(OrderType()==OP_BUY) buys ; if(OrderType()==OP_SELL) sells ; // Return open positions if(buysgt;0) return(buys); else return(-sells); // ------------------------------------------------------------------ //| Calculate optimal lot size | // ------------------------------------------------------------------ double LotsOptimized() return(Lots); // ------------------------------------------------------------------ //| Check for bullish market conditions | // ------------------------------------------------------------------ bool isBullishMarket() // Calculate current and previous MACD and and current signal line double SignalCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,S ignal,PRICE_CLOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Sig nal,PRICE_CLOSE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Si gnal,PRICE_CLOSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,RSIperiod,PRICE_CLOSE,1); return ((RsiCurrent gt; 50.0) (MacdPrevious lt; MacdCurrent) (MacdCurrent gt; SignalCurrent)); // ------------------------------------------------------------------ //| Check for bearish market conditions | // ------------------------------------------------------------------ bool isBearishMarket() // Calculate current and previous MACD and and current signal line double SignalCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,S ignal,PRICE_CLOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Sig nal,PRICE_CLOSE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Si gnal,PRICE_CLOSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,RSIperiod,PRICE_CLOSE,1); return ((RsiCurrent lt; 50.0) (MacdPrevious gt; MacdCurrent) (MacdCurrent lt; SignalCurrent)); // ------------------------------------------------------------------ //| Check for open order conditions | // ------------------------------------------------------------------ void CheckForOpen() double TP, SL; // Only trade on beginning of a new bar if (Volume#91;0#93; gt; 1) return; // Check for buy condition if (isBullishMarket()) OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,As k-StopLoss*Point,Ask TakeProfit*Point,,MAGICNUMBER,0,Green); // Check for sell condition if (isBearishMarket()) OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,B id StopLoss*Point,Bid-TakeProfit*Point,,MAGICNUMBER,0,Red); // ------------------------------------------------------------------ //| Start function | // ------------------------------------------------------------------ void start() IsTradeAllowed()==false) return; // If we have no open position check for opening one if(CalculateCurrentOrders()==0) CheckForOpen(); I have changed the following variables:TakeProfit: 200 StopLoss: 50 Lot size: 5.0 The result is nice: From 1st of january until now, the initial deposit of $10.000 would be nearly $100.000 (see attached image )

    Perhaps I need to add: should I do a backtest with the very same values from january 2007 till now, then that EA could have halfed my bank account (discontinued out at 50 percent )
    Having a lot size of 3.0 it would have been nearly $90.000 although...

  2. #12
    Thank you adamp for talk about your easy EA, I do backtest and the outcome was good. I hope the outcome will constant. I do a few new extern input in your Professional, little Modify for somebody who like Trailing Stop, just for alternative here. Happy Testing and hope you'll do some improvement for this EA...
    https://www.cliqforex.com/attachment...9634530915.ex4

  3. #13
    Junior Member piliolo's Avatar
    29
    I have updated the EA a little bit. Have tested it using different MACD constants.
    The best in a backtest of the year 2008 has been discovered with the following values:MACD fast MA interval: 8 MACD MA interval: 14 MACD signal interval: 2 Here's the altered code for those who want to try it for themselfs:

    Inserted Code // ------------------------------------------------------------------ //| EA #1 | //| ===== | //| Date: 03.08.2008 | //| Author: AdamP | // ------------------------------------------------------------------ #define MAGICNUMBER 01082008 extern double Lots = 1.0; extern double TakeProfit = 200; extern double StopLoss = 50; extern int FastMA = 8; extern int SlowMA = 14; extern int Signal = 2; extern int RSIperiod = 14; // ------------------------------------------------------------------ //| Count open positions | // ------------------------------------------------------------------ int CalculateCurrentOrders() int buys=0,sells=0; // Go through all orders for(int I=0;ilt;OrdersTotal();I ) // We're only interested in trades in the trading pool // Closed or canceled orders are not interesting for us if(OrderSelect(I,SELECT_BY_POS,MODE_TRADES)==false ) break; // Count positions that were opened by us for the current currency if(OrderSymbol()==Symbol() OrderMagicNumber()==MAGICNUMBER) if(OrderType()==OP_BUY) buys ; if(OrderType()==OP_SELL) sells ; // Return open positions if(buysgt;0) return(buys); else return(-sells); // ------------------------------------------------------------------ //| Calculate optimal lot size | // ------------------------------------------------------------------ double LotsOptimized() return(Lots); // ------------------------------------------------------------------ //| Check for bullish market conditions | // ------------------------------------------------------------------ bool isBullishMarket() // Calculate current and previous MACD and and current signal line double SignalCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,S ignal,PRICE_CLOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Sig nal,PRICE_CLOSE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Si gnal,PRICE_CLOSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,RSIperiod,PRICE_CLOSE,1); return ((RsiCurrent gt; 50.0) (MacdPrevious lt; MacdCurrent) (MacdCurrent gt; SignalCurrent)); // ------------------------------------------------------------------ //| Check for bearish market conditions | // ------------------------------------------------------------------ bool isBearishMarket() // Calculate current and previous MACD and and current signal line double SignalCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,S ignal,PRICE_CLOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Sig nal,PRICE_CLOSE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,FastMA,SlowMA,Si gnal,PRICE_CLOSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,RSIperiod,PRICE_CLOSE,1); return ((RsiCurrent lt; 50.0) (MacdPrevious gt; MacdCurrent) (MacdCurrent lt; SignalCurrent)); // ------------------------------------------------------------------ //| Check for open order conditions | // ------------------------------------------------------------------ void CheckForOpen() double TP, SL; // Only trade on beginning of a new bar if (Volume#91;0#93; gt; 1) return; // Check for buy condition if (isBullishMarket()) OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,As k-StopLoss*Point,Ask TakeProfit*Point,,MAGICNUMBER,0,Green); // Check for sell condition if (isBearishMarket()) OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,B id StopLoss*Point,Bid-TakeProfit*Point,,MAGICNUMBER,0,Red); // ------------------------------------------------------------------ //| Start function | // ------------------------------------------------------------------ void start() I have changed the following variables:TakeProfit: 200 StopLoss: 50 Lot size: 5.0 The outcome is nice: From 1st of january until today, the initial deposit of $10.000 would be almost $100.000 (see attached picture)

    Perhaps I need to add: if I do a backtest with exactly the very same values from january 2007 till today, then that EA would have halfed my bank account (discontinued out at 50 percent )
    Having a lot size of 3.0 it would have been almost $90.000 although...
    Please can you the EA together with the SL 50 and TP 200 as EA2? Thank you

  4. #14
    Junior Member Ibanes73's Avatar
    16
    Congratulation for the very simple but effective expert! I am quit beginner (forex and even more in programming), but watching the tester in visual mode with the chart at the same time, it seems for me that this system tends to loose when market is nor bearish nor bullish or if it's bearish (EURUSD March 2005 to Oct 2005). It performs the best when the markets moves bullish constantly. I was only thinking if a 3rd group (nor bullish nor bearish) can be made, where it would close the rankings earlier (with less accept profit). This would help throughout the change from bullish to bearish vica versa.
    Just an idea. What do you believe?
    Norbert

  5. #15
    Junior Member rucavi's Avatar
    20
    AUD/USD Aussie
    EUR/USD Euro or fiber
    GBP/JPY
    GBP/USD Cable
    NZD/USD Kiwi
    USD/CAD Loonie
    USD/CHF Swissy
    USD/JPY Gopher
    aud/nzd = crown
    eur/gbp = chunnel
    eur/jpy = yuppie
    gbp/jpy = godzila
    gbp/chf = gopher

  6. #16
    Junior Member Ivanpicr's Avatar
    24
    Very nice and informative thread
    thx Adamp
    I think many people will go back to this thread 4 benchmark

  7. #17
    Congratulation for its simple but effective expert! I am quit beginner (Currency Market and even more in programming), but watching the tester in visual mode with the chart at the same time, it seems for me that this system will loose when market is nor bearish nor bullish or if it is bearish (EURUSD March 2005 to Oct 2005). It performs the best when the markets goes really bullish constantly. I was only thinking if a 3rd group (nor bullish nor bearish) could be made, where it would shut the positions sooner (with less accept profit). This would help throughout the change from bullish to bearish vica versa.
    Only an idea. What do you think?
    Norbert
    I think you are right. The EA and the trading process is very basic and works well if we're in a strong fashion, bullish or bearish. The EA doesn't have any cash or risk manegement and fixed take profit and losses.
    A big advantage is if the machine would calculate values for TP and SL depending on closed positions or using trail stops.

    When I find the time, I'll try to think of how to apply this.

  8. #18
    very pleasant and informative thread
    thx Adamp
    I believe many people would return to the thread 4 benchmark
    Thanks. I hope this EA can be handy for those who begin with programming their particular EAs.

  9. #19
    Junior Member Ibanes73's Avatar
    16
    http://www.chompalov.com/GMACD.mq4
    This is a MACD indior of strong, medium and weak indications of buy and sell, maybe you can use the powerful trend lines from it, therefore it will enter whenever there is a strong trend whatsoever.

    File is connected today
    https://www.cliqforex.com/attachment...1245065484.mq4

  10. #20
    Junior Member piliolo's Avatar
    29
    http://www.chompalov.com/GMACD.mq4
    This really is a MACD indior of strong, medium and weak signs of buy and sell, perhaps you can use the strong fashion lines from it, therefore it will enter if there's a strong tendency whatsoever.
    Please note the indior here. Thanks

  •