Guests cannot download files.
Log in or register an account!
ATR Trailing Stop.mq4 EA Source Code!
//+------------------------------------------------------------------+
//| ATR Trailing Stop.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright Team Aphid"
#property link ""
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- indicator parameters
extern int BackPeriod = 1000;
extern int ATRPeriod = 3;
extern double Factor = 3;
extern bool TypicalPrice = false;
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,EMPTY,2);
SetIndexDrawBegin(0,ATRPeriod);
SetIndexBuffer(0,ind_buffer1);
SetIndexStyle(1,DRAW_LINE,EMPTY,2);
SetIndexDrawBegin(1,ATRPeriod);
SetIndexBuffer(1,ind_buffer2);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ATR Trailing Stop("+ATRPeriod+" * "+Factor+")");
SetIndexLabel(0,"Support");
SetIndexLabel(1,"Resistance");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double PrevUp, PrevDn;
double CurrUp, CurrDn;
double PriceLvl;
double LvlUp = 0;
double LvlDn = 1000;
int Dir = 1;
int InitDir;
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- fill in buffervalues
InitDir = 0;
for(int i=BackPeriod; i>=0; i--)
{
if (TypicalPrice) PriceLvl = (High[i] + Low[i] + Close[i])/3;
else PriceLvl = Close[i];
if(InitDir == 0) {
CurrUp=Close[i] - (iATR(NULL,0,ATRPeriod,i) * Factor);
PrevUp=Close[i-1] - (iATR(NULL,0,ATRPeriod,i-1) * Factor);
CurrDn=Close[i] + (iATR(NULL,0,ATRPeriod,i) * Factor);
PrevDn=Close[i-1] + (iATR(NULL,0,ATRPeriod,i-1) * Factor);
if (CurrUp > PrevUp) Dir = 1;
LvlUp = CurrUp;
if (CurrDn < PrevDn) Dir = -1;
LvlDn = CurrDn;
InitDir = 1;
}
CurrUp=PriceLvl - (iATR(NULL,0,ATRPeriod,i) * Factor);
CurrDn=PriceLvl + (iATR(NULL,0,ATRPeriod,i) * Factor);
if (Dir == 1) {
if (CurrUp > LvlUp) {
ind_buffer1[i] = CurrUp;
LvlUp = CurrUp;
}
else {
ind_buffer1[i] = LvlUp;
}
ind_buffer2[i] = EMPTY_VALUE;
if (Low[i] < ind_buffer1[i]) {
Dir = -1;
LvlDn = 1000;
}
}
if (Dir == -1) {
if (CurrDn < LvlDn) {
ind_buffer2[i] = CurrDn;
LvlDn = CurrDn;
}
else {
ind_buffer2[i] = LvlDn;
}
ind_buffer1[i] = EMPTY_VALUE;
if (High[i] > ind_buffer2[i]) {
Dir = 1;
LvlUp = 0;
}
}
}
//---- done
return(0);
Tested Forex Robots with a lot of trades.
Average trades per month: 1068
https://mt4talk.com/viewtopic.php?pid=59450#p59450
Average trades per month: 536
https://mt4talk.com/viewtopic.php?pid=59459#p59459
Average trades per month: 325
https://mt4talk.com/viewtopic.php?pid=59468#p59468
Average trades per month: 260
https://mt4talk.com/viewtopic.php?pid=59469#p59469
Average trades per month: 426
https://mt4talk.com/viewtopic.php?pid=59470#p59470
Average trades per month: 198
https://mt4talk.com/viewtopic.php?pid=59525#p59525
Average trades per month: 253
https://mt4talk.com/viewtopic.php?pid=59580#p59580
Average trades per month: 251
https://mt4talk.com/viewtopic.php?pid=59602#p59602
Average trades per month: 603
https://mt4talk.com/viewtopic.php?pid=60192#p60192
Average trades per month: 479
https://mt4talk.com/viewtopic.php?pid=60208#p60208
Dear Admin,
Thank you, this trailing stop can it be use with an other EA ?
Second question : This code it be adding to an existing EA code ?
Thank you for your answer
Best
ATR = Average True Range
Developed by J. Welles Wilder, the Average True Range (ATR) is an indicator that measures volatility. As with most of his indicators, Wilder designed ATR with commodities and daily prices in mind. Commodities are frequently more volatile than stocks. They were are often subject to gaps and limit moves, which occur when a commodity opens up or down its maximum allowed move for the session. A volatility formula based only on the high-low range would fail to capture volatility from gap or limit moves. Wilder created Average True Range to capture this “missing” volatility. It is important to remember that ATR does not provide an indication of price direction, just volatility.
Wilder features ATR in his 1978 book, New Concepts in Technical Trading Systems. This book also includes the Parabolic SAR, RSI and the Directional Movement Concept (ADX). Despite being developed before the computer age, Wilder's indicators have stood the test of time and remain extremely popular.
510236872, admin, Adyjul, Afnan Al-mustafa, Agostino Visentini, Ahmad AA, Akash9902, alapia, alfie01, aryannellore, asty.yukiko, atta2020, avo2000, beta12, bidv461, Blackeagle, Breneo Rahaka, Chienusd, christianziegler1966, cyazhan, ddtrc, dhiru, EA Tester Team Manager, ekans1234, Elite12345, estreetinv, excelsaravana, faisal123, forextradr, frankljr, fxstockspro, Gerald Stan Bystander, gerencia, gntgnt8, grvFX, Hafizi Mohamed, halix4u, haoglueck, hw543, Imran Haider, Irfani666, janavas, jlotterer, JohnMhd, Jonny.cnstn, kamal5184, koongh, kreangkrai, kumpon68, kwameD, L'Incognito, Lala Lim, Leon Njoh Njoh, m1806, madcow, Marcodoz, Maxatheni, Mfinanga, mharckie07213, mift, MO.SALAHSAAD, Muhammet5068, NoTail, olympia836, Orobosa1, Paulo Pestana, Pieter Daud Satumalay, Poutax, prs10ce, rainer3770, Randray, RAPH, Raymond1983, Reginaldo Kellner, Reinhold.fbknamibia, richardkangning, Roycapz, Ruark, salo, Salum Akilimali Kirume, samhagin, Saqib Saeed, Senmoh, sky88, Solenya99, Supolchai, tadex, tamforex, tenton, tradingralf, tskabilan, Tulga Eroltu, Tumiso, Victor Farias, vybestar, walidshahbudin, wca1985, widadi, Wiljou, Will777iam, win520923, Wiseman, Wllie Bester, wongyewhien101, xiangjn99, Zethembe, ZoNiaina, Zul Fadzly, Максим Лиокумович, Середа Геннадий, דרור וסרמן
MT4talk is a User Generated Content website. All content uploaded to MT4talk by our users (MT4talk forum members) is User Generated Content. Please note that MT4talk doesn't sell Forex robots and does not provide support for the uploaded Forex robots. MT4talk only sells PRO membership. PRO membership is unlimited download access in every forum topic and forum posts.
CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members or the MT4talk EA Tester Team about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.
Affiliates Disclaimer - The site may contain links to affiliate websites, and we receive an affiliate commission for any sign up that trade by you on the affiliate website using such links. Our affiliate partners includes the following: FXOpen, FBS, LQDFX, MyForexVPS.
Copyright MT4talk.com Forum Rules - Privacy Policy.