• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:06am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:06am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Help - any tools that can easily convert MQL4 code to Easy Language code? 7 replies

MQL4 Language Most Recent Version is it updated beyond the tutorial on the mql4 websi 6 replies

Code MQL4 Help 13 replies

Need some help with MQL4 code... 1 reply

  • Rookie Talk
  • /
  • Reply to Thread
  • Subscribe
  • 2
Attachments: MQL4 code help
Exit Attachments
Tags: MQL4 code help
Cancel

MQL4 code help

  • Post #1
  • Quote
  • First Post: Mar 18, 2006 6:04am Mar 18, 2006 6:04am
  •  satman
  • | Joined Mar 2006 | Status: Member | 14 Posts
Hi there,

New to FF & forex (only paper trading at the mo) and have to say I’m glad I found this site, excellent and very informative.

Recently installed MetaTrader 4 and getting to grips with it, I would like to overlay a trailing stop loss indicator for long & short positions just as a visual reference on the charts, is this possible and if so could someone please post the code.

Thanks in advance
  • Post #2
  • Quote
  • Mar 18, 2006 7:19am Mar 18, 2006 7:19am
  •  highway
  • Joined Sep 2005 | Status: Member | 1,352 Posts
Quoting satman
Disliked
Hi there,

New to FF & forex (only paper trading at the mo) and have to say I’m glad I found this site, excellent and very informative.

Recently installed MetaTrader 4 and getting to grips with it, I would like to overlay a trailing stop loss indicator for long & short positions just as a visual reference on the charts, is this possible and if so could someone please post the code.

Thanks in advance
Ignored

Go to metaqoutes or google trailling stop5.mq4

It's all there.
 
 
  • Post #3
  • Quote
  • Mar 18, 2006 8:02am Mar 18, 2006 8:02am
  •  satman
  • | Joined Mar 2006 | Status: Member | 14 Posts
Been searching, nothing found
Could you post a link
 
 
  • Post #4
  • Quote
  • Mar 18, 2006 9:34am Mar 18, 2006 9:34am
  •  MrMajik
  • | Joined Feb 2006 | Status: Member | 79 Posts
Satman,

I found a trailing stop file for MT4. The file is named, "ATR Trailing Stop.mq4". Not sure if it is the same stop5.mq4 file that highway3000 suggested as the attached file has a different name.

Hope this helps.
Attached File(s)
File Type: mq4 ATR Trailing Stop.mq4   4 KB | 1,880 downloads
 
 
  • Post #5
  • Quote
  • Mar 18, 2006 3:37pm Mar 18, 2006 3:37pm
  •  highway
  • Joined Sep 2005 | Status: Member | 1,352 Posts
Quoting satman
Disliked
Been searching, nothing found
Could you post a link
Ignored

Here it is.
Attached Image
 
 
  • Post #6
  • Quote
  • Mar 18, 2006 11:24pm Mar 18, 2006 11:24pm
  •  satman
  • | Joined Mar 2006 | Status: Member | 14 Posts
Thanks for the links,

Downloaded both and have tried to use the files without success.

Have got both files in the indicator window but when I click on them to use them nothing happens.

What is the procedure to save them to MT4 and use them?

Thanks
 
 
  • Post #7
  • Quote
  • Mar 19, 2006 9:22am Mar 19, 2006 9:22am
  •  Mike Jolley
  • | Joined Feb 2006 | Status: Member | 89 Posts
Normally I double click and get a popup window for setting options. If this doesn't happen you can try recompiling in the editor: Tools->MetaQuotes Language Editor.
 
 
  • Post #8
  • Quote
  • May 26, 2016 7:29am May 26, 2016 7:29am
  •  willthare
  • | Joined Jan 2015 | Status: Member | 13 Posts
http://www.forexfactory.com/showthread.php?t=318772
 
 
  • Post #9
  • Quote
  • Edited May 5, 2017 5:55am May 4, 2017 9:21pm | Edited May 5, 2017 5:55am
  •  huntraderGB
  • | Joined May 2014 | Status: Member | 2 Posts
Hi guys, please I need help to plug these two things together...

I have this EA (mql4), which is monitoring the account Balance, Equity and Profit. When the set profit or the set loss % is reached the robot closes all open trades.

I also want the Autotrade in Mt4 to be turned off to prevent the main EA to open new trades.

I have a Script for that, but I don't know how to plug it in to EA. Can somebody please help me?

Inserted Code
#include <WinUser32.mqh>
 
 
extern bool DisableAllEAs = TRUE;
 
void DisableEA() {
keybd_event(17, 0, 0, 0);
keybd_event(69, 0, 0, 0);
keybd_event(69, 0, 2, 0);
keybd_event(17, 0, 2, 0);
}
 
 
int start() {
 
if (DisableAllEAs == TRUE) {
DisableEA();
return (0);
}}

Inserted Code
//If sett loss or profit reached close all trades and stop EA
 
 
 
extern double equity_percent_from_balances=0.9;
extern int profit_target=200;
 
 
int start()
  {
  
   if(AccountEquity()<(AccountBalance()*equity_percent_from_balances) ||        (AccountProfit()>profit_target))
     {
      int total=OrdersTotal();
 
      for(int i=total-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS)==true)
           {
            int type=OrderType();
 
            bool result=false;
 
            switch(type)
              {
               case OP_BUY       : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red);
               break;
               case OP_SELL      : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Red);
              }
 
            if(result==false)
              {
               Sleep(0);
              }
           }
        }
     }
   return(0);
  }
 
 
  • Post #10
  • Quote
  • Sep 15, 2022 2:24pm Sep 15, 2022 2:24pm
  •  errosal
  • | Joined Feb 2022 | Status: Junior Member | 1 Post
Hey huntraderGB, did you found a solution to plug the two things together? I actually need something like this.
 
 
  • Post #11
  • Quote
  • Sep 21, 2022 8:02pm Sep 21, 2022 8:02pm
  •  Ptrader64
  • | Joined Sep 2022 | Status: Junior Member | 2 Posts
. My 2cents input, you should be able to make an indicator pretty easily that works with your EA, if not using the ones provided by the replies here.
Hi Sorry if I'm hijaking your thread, new member and cant start my own posts..

I have just started up MT4 strategy tester again on Pepperstone AU to see if I can get my old system up and running with a few tweaks.
However when I start a backtest it appears to work, but the results are just thousands of open and close trades from one candle to the next.
It seems to be ignoring my EA buy/sell signals completlely.

Is this a known issue with certain versions of broker mt4?
or is it an incompatibility with old mt4 code and newer versions?
Or is it the brokers fault that tester isnt working in their platform?

Any answers would be very welcome, pm me if you must.

Regards,

Ptrader
 
 
  • Post #12
  • Quote
  • Sep 29, 2022 3:05pm Sep 29, 2022 3:05pm
  •  forexmm
  • | Joined Dec 2010 | Status: Member | 5 Posts
I am considering programming my own indicators. Should I code for MT4 or MT5?
forexmm
 
 
  • Post #13
  • Quote
  • Last Post: Oct 3, 2022 4:54pm Oct 3, 2022 4:54pm
  •  pizd0s
  • | Joined Dec 2021 | Status: Member | 208 Posts
Quoting forexmm
Disliked
I am considering programming my own indicators. Should I code for MT4 or MT5?
Ignored
They both use MQL5 however I would suggest to create robots for MT5 because brokers are gradually moving towards MT5. It is also rule of thumb to steer clear from past versions of any app.
 
 
  • Rookie Talk
  • /
  • MQL4 code help
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023