MT4 One-click Entry and Exit

Discussion in 'Forex Brokers' started by danger66, Mar 1, 2007.

  1. Does anyone know if one-click entries and exits are possible on MT4?

    I know that MT4 does not have this feature "out of the box," but I spoke to a trader once who told me that this was possible with some extra "tools" that are already available on the web.

    I looked them, but can't find anything and it would really help one of our traders.
     
  2. This Script to close all open position with one click.

    while open u can just open the trade window and adjust the currency and the amount and the buy or sell gonna be 1 click
    but if u found a script which could make it faster feel free to share it

    Regards
     
  3. 4X4Living, thanks.

    There's a way to open a position with one click though. I just don't know where to find it.
     
  4. danger66, to implement your request for entry all it takes is 2 essentially one-line MQL4 scripts and 2 hotkeys.


    //+------------------------------------------------------------------+
    //|1-Click Buy Order.mq4 |
    //+------------------------------------------------------------------+
    int start()
    {
    OrderSend(Symbol(), OP_BUY, 10, Ask, 3, Ask-15*Point, Ask+12*Point);
    return(0);
    }


    //+------------------------------------------------------------------+
    //|1-Click Sell Order.mq4 |
    //+------------------------------------------------------------------+
    int start()
    {
    OrderSend(Symbol(), OP_SELL, 10, Bid, 3, Bid+15*Point, Bid-12*Point);
    return(0);
    }


    (Spacing isn't rendered properly here on ET, unlike in the attached files.) Here Symbol() refers to the pair on the currently active chart, order size = 10 lots, slippage = 3, SL = 15, TP = 12. Feel free to edit any variables as needed, on the fly. Ctrl-s and F5 to save and compile after any edit, of course.

    Save these two files in the \Program Files\[MT4 dir]\experts\scripts folder. Open with MetaEditor and compile. In MT4 Navigator - Scripts, right-click on a script - Set hotkey, e.g.:

    Alt-b for 1-Click Buy Order
    Alt-s for 1-Click Sell Order.

    You're set to go, for entries.

    For exits, a script could be almost as simple or more involved. It depends on the trader's MO and therefore exactly what actions he needs to be able to execute with 1 click.
     
  5. Thanks 4X4Living and late_apex. That's exactly what I need.

    :)
     
  6. JeffNLisa

    JeffNLisa

    There are some brokers that do not allow scripted or EA orders that have the stop-loss and the take-profit included with the order. Some of those will execute the trade, but leave off the SL and the TP, others will not execute the order at all.

    In those cases, the script or the EA must place the order in one command, and then use another command to modify the position to add the SL and TP.

    So I edited the code to do just that.

    It places the trade, then goes in and puts on the SL and the TP.

    I also put the variables for the lot size and the stop and profit targets at the very top, so that anyone with virtually no programming experience can open it and change the values to what they want.

    To do this, with your Navigator window open, and the "Scripts" box expanded, just right click on the script, and click "Modify". It will open the code, and the first three lines of code (after the comments) are the lots and the stopsize and the profsize.


    For the BUY order it looks like:

    //+------------------------------------------------------------------+
    //|1-Click Buy Order.mq4 |
    //+------------------------------------------------------------------+

    double lots = 0.1;
    double stopsize = 100;
    double profsize = 100;

    int ticket;
    double stop;
    double prof;
    int start()
    {
    ticket=OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0);
    stop=(Ask-stopsize*Point);
    prof=(Ask+profsize*Point);
    OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Blue);
    return(0);
    }




    and for the SELL order it looks like:

    //+------------------------------------------------------------------+
    //|1-Click Sell Order.mq4 |
    //+------------------------------------------------------------------+

    double lots = 0.1;
    double stopsize = 100;
    double profsize = 100;

    int ticket;
    double stop;
    double prof;
    int start()
    {
    ticket=OrderSend(Symbol(), OP_SELL, 0.1, Bid, 3, 0, 0);
    stop=(Bid+stopsize*Point);
    prof=(Bid-profsize*Point);
    OrderModify( ticket, OrderOpenPrice(), stop, prof, 0, Red);
    return(0);
    }




    You just put in the lots you want, and the stop and profit targets you want.

    When finished, click the "Compile" button at the top, and it will save the changes.

    Also, many brokers are now using 5th decimal place (or 3rd for JPY pairs), and so if you want a 10-pip SL/TP, you need to enter 100.

    If you are using a broker that still is on 4th decimal, then you input 10 for a 10-pip SL/TP, or 100 for a 100-pip SL/TP.

    I am attaching the scripts in a zip file. In the attached files are several extra lines of code I was using to troubleshoot, but they will have no effect on you if you just leave them there if you see them.

    I hope someone finds this to be helpful! :)

    Jeff
     
  7. JeffNlisa is Alt-B and Alt-S to buy or sell with this script?
     
  8. Mabe

    Mabe

    The 1-Click buy, sell and close all open and pending orders works great.

    Is there a 1-Click script available that will close one open order at a time separately.

    (e.g., close the order for the pair that is showing on the screen and leave others open)

    Thanks
     
  9. stevewide

    stevewide

    Thanks for the scripts. Would you be so kind as to make this script to place a pending buy and sale oder at a price I insert with a set sl and tp?

    Thanks for considering this request.

    Steve
     
  10. Hi Jeff

    Have looked for this for a long time. works great, takes the risk out of the period between entry and setting stops for ECN market entries when scalping volatile periods

    Thanks John :)
     
    #10     Mar 30, 2010