You didn't post a topic yet. Let us show you how to make your first topic and upload your favorite forex robot. Guide me

Skip to forum content

Hide

IMPORTANT: We've updated our Privacy & Cookies Policy! MT4talk is Committed to Protecting the Data Privacy of its Users!

We've updated our privacy policies to make it easier for you to understand what data we collect and how we use it, as well as to better comply with the requirements of GDPR.

You can find the new Privacy & Cookies Policy at https://mt4talk.com/privacy_policy.php  

If you are a forum member and you need to update your profile, you can go to Profile / Identity.  

You can also update newsletter settings and other settings by going to Profile / Settings.

If you have any problem or a question, please contact: mt4talk@gmail.com

The latest topics with attached files (Forex robots, Forex Indicators, etc..)

Forums in this category with details of Replies, Views, last post

Very good indicator

by jake.hell09

GrinderEA. 2nd page

by fxor4719a

forex grinder EA

by fxor4719a


[ Closed ]

Log-In or Register to get unlimited download access of Forex Robots!

Login with Facebook!

Login with Facebook

Login with Username and Password!

     Username:       Password:  Login

Register  |  Forgot Password?

 

Pages 1

You must login or register to post a reply

RSS

Posts: 3
Please rate this topic
Current rating: 0
Votes: 0

Embed topic to your site

ATR Trailing Stop.mq4 EA Source Code!

Topic: ATR Trailing Stop.mq4 EA Source Code!

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);

Share

Copy Successful Forex Traders and earn big profit! Its really works! $200, $500 or even $1000+ profit per day! Click here for more info...

Re: ATR Trailing Stop.mq4 EA Source Code!

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

Share

3 (edited by sonychen59 08-11-15 07:48:53)

Re: ATR Trailing Stop.mq4 EA Source Code!

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.

Share

Posts: 3

Pages 1

You must login or register to post a reply

Forex Trade Copy

Copy Successful Forex Traders and earn big profit! Its really works!

$200, $500 or even $1000+ profit per day! Its depends on your trading balance. Click here for more info...

Last Posts

  • 27/05: Very good indicator
  • 26/05: for beginners
  • 26/05: Daily Technical Strategy On Currencies & Commodities
  • 26/05: good work ea trading scapler four month 100$ to 1000000$ good work ea
  • 25/05: $$$ The Best Forex Trade Copier! Earn $200, $500 or even $1000+ daily!
  • 25/05: Opportunities through broker.
  • 25/05: safe Forex Robot
  • 25/05: Forex Discipline
  • 25/05: Proper Analysis
  • 24/05: Demo can not teach you everything
  • 24/05: BBMA extreme momentum indicator
  • 24/05: forex grinder EA
  • 23/05: How to select good brokers?
  • 23/05: Low risk strategy works in real account.
  • 23/05: General Trading Knowledge.
  • 23/05: Currencies are available.
  • 23/05: GrinderEA. 2nd page
  • 22/05: What is your trading objective?
  • 22/05: INFINITY FOREX ROBOT
  • 22/05: Sure hedging EA
  • Hot Topics

  • ASSAR v8 (1042)
  • Scalper_v5 (free) (720)
  • A highly profitable Ea (465)
  • FX Magic Robot - Verified Live Working 3/13/17 (458)
  • 2000 pips daily (451)
  • ASSAR V9 (Trend Breakout Edition) 2017 Expert Advisor (417)
  • spartan bolt V6 (414)
  • Assar_03_EA (391)
  • ASSARV11 [EXCLUSIVE] ACTIVE MEMBERS ONLY! (274)
  • Forex Earth Robot (249)
  • Trade-Arbitrage EA (248)
  • xmt scalper (227)
  • Forex Math EA free for Mt4 (180)
  • Super Signal Scalping Profit Statement (178)
  • Rabbit3 £100 start Zero to Hero Updated EA (167)
  • Fracture 7.4.0 (156)
  • high profit EA (151)
  • SCALPER PALING JOSS EA is a Holy Grail (150)
  • New to forex? (148)
  • Ilan Expert Advisor for Metatrader 4 (136)

  • NOTE: Hacked or other illegal versions of copyrighted forex robots are highly prohibited on MT4talk.com. If you upload any illegal version of any copyrighted forex robot, your forum account will be banned. No exceptions.

     

    Forum statistics

    • Total number of registered users: 18,835
    • Newest registered user: cofferic
    • Total number of topics: 10,925
    • Total number of posts: 36,218

    Copyright MT4talk.com Forum Rules - Privacy & Cookies Policy.