Results 1 to 6 of 6
 0 Attachment(s)    

Thread: How to build an EA

  1. #1

    Default How to build an EA

    hy funnyoo
    I ask for advice about base rule
    how to build ea where :

    1. open trade when first condition is true- trade A(only one)
    2.close A (no matter how)
    3. open second trade B(it will be only one) when A was close with profit and condition for second is true.
    3. close B
    4. and now waiting untill signal for A will be true and repeat all

    tp,sl.ts should be different for A and B

    point 1,2 is obvious but next ?

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by przem81621 View Post
    hy funnyoo
    I ask for advice about base rule
    how to build ea where :

    1. open trade when first condition is true- trade A(only one)
    2.close A (no matter how)
    3. open second trade B(it will be only one) when A was close with profit and condition for second is true.
    3. close B
    4. and now waiting untill signal for A will be true and repeat all

    tp,sl.ts should be different for A and B

    point 1,2 is obvious but next ?
    Hi przem81621,

    It can be complicated to explain this as the way to code can be different depending on the system.

    What I suggest you, is to study the small codes included in Metatrader like "Moving Average" and "MACD Sample", try to modify them a little and see the results in visual backtesting. You will understand quickly how it works. Then add simple features, ... and with the time you will achive a template that you will fully understand.

  3. #3

    Default

    Quote Originally Posted by funyoo View Post
    Hi przem81621,

    It can be complicated to explain this as the way to code can be different depending on the system.

    What I suggest you, is to study the small codes included in Metatrader like "Moving Average" and "MACD Sample", try to modify them a little and see the results in visual backtesting. You will understand quickly how it works. Then add simple features, ... and with the time you will achive a template that you will fully understand.
    aha, ok
    i'll see,thanks for showing the way

  4. #4
    Member Denoiser's Avatar
    Join Date
    Jan 2009
    Location
    Hungary
    Posts
    88

    Default

    Hi,

    Forex Smart S System EA

    in this expert have 3 orders different tp-sl

  5. #5

    Default

    I found that is OrderCloseBy() function in mq4, but how to write in ea?
    look
    open position :
    if(OS==1){if(TP==0)TPI=0;else TPI=Bid-TP*Point;if(SL==0)SLI=0;else SLI=Bid+SL*Point;if(Time0!=Time[0]){TK=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,SLI, TPI,OrSt,Magic,0,Red);OS=0;Time0=Time[0];if(TK>0)TradePerBar++;return(0);}}
    close position
    if(OrderType()==OP_SELL&&OrderSymbol()==Symbol()&& ((OrderMagicNumber()==Magic)||Magic==0)){if(CB==1) {OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red );return(0);}}

    and now if CB==1 and oposit==true i want close first by open next in opposite direction
    {if(CB==1&&oposit==true"){OrderCloseBy((OrderTicke t(),OrderLots(),Bid,Slip,Red);(what here );return(0);} else{if(CB==1){OrderClose(OrderTicket(),OrderLots( ),Bid,Slip,Red);return(0);}

    Please help

  6. #6

    Default

    probably it,s for nothing.
    it,s working if two orders are open opposite and one will be close by second when use this function. Am i wright?

Similar Threads

  1. Download MT4 Build 509
    By fxtester in forum MQL programming
    Replies: 0
    Last Post: 08-11-2014, 11:17
  2. Build EA without MQL indicators
    By sayed in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-30-2010, 17:33
  3. Clippers v4 Beta build
    By fxtester in forum Commercial expert advisors
    Replies: 1
    Last Post: 01-12-2010, 23:37
  4. Lets Build A Real Profitable EA !
    By knacky in forum Ideas for expert advisors
    Replies: 2
    Last Post: 11-01-2009, 14:49

Tags for this Thread

average, backtesting, color, expert, how to, macd, magic, metatrader, moving average, mq4, profit, sample, signal, simple, study, system, time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •