My First Tradingsystem and EA
Page 1 of 503 1 2 3 LastLast
Results 1 to 10 of 24

Thread: My First Tradingsystem and EA

  1. #1

    My First Tradingsystem and EA

    Hey guys!

    This is my first post in this forum. I am new into Foreign Exchange trading - about 2 months maybe.

    I study computer science so I've got some skills in programming - at least, I must have
    When I read that it is likely to programm the MT4 with a C-style such as syntax, I wished to give it a try - so I started studying the MQL-API and analyzed those EAs that came together with MT4.

    . . .that was yesterday. Today I wish to present my first EA.
    Maybe it is usefull for some of you. Any feedback is welcome - wether it's coding conversation or style of the trading system.

    So here's my first EA - very simple, very basic:

    Inserted Code // ------------------------------------------------------------------ //| EA #1 | //| ===== | //| Date: 02.08.2008 | //| Author: AdamP | // ------------------------------------------------------------------ #define MAGICNUMBER 01082008 extern double Lots = 1.0; extern double TakeProfit = 80; extern double StopLoss = 60; // ------------------------------------------------------------------ //| 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 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,12,26,9,PRICE_C LOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CLO SE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CL OSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,14,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,12,26,9,PRICE_C LOSE,MODE_SIGNAL,0); double MacdCurrent=iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CLO SE,MODE_MAIN,0); double MacdPrevious=iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CL OSE,MODE_MAIN,1); double RsiCurrent = iRSI(Symbol(),PERIOD_W1,14,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(); Some keynotes:Optimized for EURUSD Using daily charts and weekly charts
    Only 1 Position opened at the Exact Same time Fixed TakeProfit and StopLoss
    I have backtested it to the year 2008 and 2007 on the EURUSD chart.
    But it's also feasible to use it together with other charts - in that case, you should change the TakeProfit and StopLoss variables.

    The idea is quite simple. The following two indiors are used:MACD (12,26,9)
    RSI (14) The following algorithm (oh, you call it trading system, right? ) Is used:Check if has opened? quit! Check if we are at the start of a new bar (daily chart) no? quit! Check wether we are in a bullish or a bearish trend A bullish fashion is indied that way:The RSI sign of the current week's bar has to be greater than 50, and the MACD daily value has to be smaller than the current MACD daily value, and the current MACD daily value has to be higher than the current MACD daily sign A bearish trend is indied the contrary direction:RSI sign of the current week Has to Be smaller than 50, and the precvious MACD daily value Has to Be higher than the current MACD daily value, and the current MACD daily value Has to Be smaller than the current MACD daily sign If we are in a bullish fashion, buy with TakeProfit 80 and StopLoss 60, in a bearish trend sell with same TakeProfit and StopLoss First attached picture is a backtest of the EURUSD out of 1st of january 2008 until today with a starting budget of $10.000 and a lot size of 1.0, TP 80 and SL 60.

    Second pictures demones a buying and a selling signal. But this isn't 100% correct, since the RSI is on a daily basis, although this EA checks the worth.

    Edit: I'm using a fixed lot size without any cash or risk management right now.

    Any comments welcome!


    https://www.cliqforex.com/attachment...1850390684.ex4

  2. #2

  3. #3
    Cable?
    I have tested it in my demo account only so far - Varengold Bank FX.
    What do you mean with cable?

    Actualy it was only a test for me if I can code a system which will make a little profit on a backtest - that is all.
    I don't recommend to apply this simple EA at a live account - but feel free to do so and tell me that the results!

  4. #4
    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

  5. #5
    Thank you, stopman

    I have tested it on the cable for this season using a TakeProfit of 20 plus also a StopLoss of 60.

    That is the result:

  6. #6
    I will attempt to add cash and risk management (is not this the same btw. ?) And a trailing stop, also. Let's see if this will give some better outcomes.

  7. #7
    Quote Originally Posted by ;
    Hey guys!

    Some keynotes:Optimized for EURUSD Utilizing daily charts and weekly charts
    Just 1 Position opened in the Exact Same time Fixed TakeProfit and StopLoss
    I've backtested it to the year 2008 and 2007 on the EURUSD chart.
    But it's also possible to use it with different charts - in that case, you need to change the TakeProfit and StopLoss factors.

    The idea is quite straightforward. The next two indiors are utilized:MACD (12,26,9)
    RSI (14) The next algorithm (oh, you call it trading system, right? ) Is utilized:Check if has already a position opened? quit! Check if we're in the start of a new bar (daily chart) no? quit! Check wether we're in a bullish or even a bearish trend A bullish fashion is indied like that:The RSI sign of the current week's bar has to be greater than 50, and the MACD daily value has to be smaller than the current MACD daily price, and the current MACD daily value has to be higher than the current MACD daily sign A bearish trend is indied the opposite direction:RSI sign of the current week Has to Be smaller than 50, and the precvious MACD daily value Has to Be higher than the current MACD daily worth, and the current MACD daily value Has to Be smaller than the current MACD daily sign If we are in a bullish fashion, buy with TakeProfit 80 and StopLoss 60, at a bearish trend sell with same TakeProfit and StopLoss First attached picture is a backtest of this EURUSD out of 1st of january 2008 until today with a starting budget of $10.000 and a lot size of 1.0, TP 80 and SL 60.

    Second pictures demones a buying and a selling signal. But this isn't 100% right, because the RSI is on a daily basis, although this EA checks the weekly worth.

    Edit: I am with a fixed lot size and no cash or risk management at the moment.

    Any comments welcome!
    Damn man!
    If you will post all of your EA's this way, you alredy are my buddy.
    I've alredy downloaded MQL classes and gonna become programmer . So your all explanation are briliant for me [would be...]

    Thanks.

  8. #8
    Hey Kaligula, thank you. Nice to hear that it may assist you!

  9. #9
    Hi Adam,

    Good to hear one more EA programmer here.

    Yes, we need simple idea but consistent results.

    Let us attempt join the championship 2008.

    I would love to join too and attempting develop one EA for that now...

  10. #10
    Joining the MetaTrader Championship?
    To me, this sounds like beeing a middle-weighted beginner in his second month of coaching - then fighting a heavy weight professional

    I think I need more practise in programming EAs... and much more practise in trading Currency Market!
    This is simply a very fundamental EA, which was performed primarily for analyzing and getting a positive feedback of a backtest.
    No cash or risk management is coded, fixed stop losses and take profits.
    I doubt this simple EA can beat any highly optimized, well coded EA of the former participiants.

    When is your deadline?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. Read more.