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

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?

 

 

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

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

Assar V11

by bongs33

Trendline Idikator

by an84ma

very easy ea

by an84ma


[ Closed ]

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

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

Last Posts

  • 20/08: My Favorit EA Lifechanger
  • 19/08: 1-2-3 pattern, PZ Harmonic
  • 19/08: Choice of trading platform
  • 18/08: BEST TRENDLINE METHODS by Patrick Mikula
  • 17/08: Assar V11
  • 17/08: Guidance for beginner
  • 17/08: Broker selection is difficult today
  • 16/08: The assar v8 of bader alharbi is real?
  • 16/08: How do I connecto to a EuropeFX Demo Account
  • 16/08: credible broker
  • 16/08: Assar v8 1m eurusd the best forex my test ok good
  • 16/08: HIGH DRAWDOWN AND CONTINIOUS LOSS MAKING ROBOT
  • 16/08: Ubat 5.0
  • 16/08: Scalping EA Use on H1
  • 16/08: Selection of broker
  • 14/08: Trendline Idikator
  • 14/08: very easy ea
  • 14/08: BBMA indicators 1
  • 14/08: UPDATE: This robot now makes huge money! $24,512 profit in 10 days!
  • 13/08: Virtual Earning Platforms
  • 13/08: IceFX TraderAgent pro
  • 12/08: Trading as per rule
  • 12/08: PZ Harmonic Scanner
  • 12/08: HNAVHelios + V2.04 any member have this EA?
  • 11/08: This robot made me over $20,000.
  • 11/08: supertrend ea basic
  • 11/08: Forex Tips EA
  • 11/08: Very interesting free EA
  • 11/08: face great adversity
  • 11/08: PRO VSA EA
  • 10/08: Good broker or scam broker?
  • 10/08: Arbitrage Forex Software
  • 10/08: Hobbit v7
  • 10/08: Candle Stick Trading Bible by Homma
  • 10/08: Maintain systematic manner
  • 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 (450)
  • ASSAR V9 (Trend Breakout Edition) 2017 Expert Advisor (417)
  • spartan bolt V6 (414)
  • Assar_03_EA (389)
  • 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)
  • EA SmartAssTrade. (133)
  • Monster Profit Forex Robot (123)
  • WayGrow EA 1.7 (110)
  • scalperstarkpro downoad free (price 90 dollars) (92)
  • FX Magic Robot (91)
  • IceFX TraderAgent Pro EA v2.5.1 (86)
  • Profitable GBPJPY EA (true results) (85)
  • Unbelievable EA (75)
  • Hedge Expert Advisor (63)
  • Good EA 2017. Free !!! (63)
  • 100 pips profits trading (63)
  • Best Indicator That No Repaint!!! (61)
  • Magic Fx Formula indicator-V2 (61)
  • BAR EA V5.1 (60)
  • hello (60)

  •  

    NOTE: Hacked or 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: 21,464
    • Newest registered user: Fábio Magalhães
    • Total number of topics: 11,158
    • Total number of posts: 36,671

    Online users: 1,797 guests, 172 Members:

    1italy, 777legrand, adamvega, admin, Ahmet Barış Işıtan, akulah08, an84ma, Andreas Holz, anees, AnthonyT, axel7969, ay.smileplus, ba3093h2, Bandeauman Gjc RG, bbtt181, bestkid321, bongane, calimocho5, charity03, charlieraly, ChatChai Chatza Kanjanamala, colin, crizzmennn, customsveeraiah, cyrille1209, dado57, Daechopon J Khamhom, dante, Dany Dan, Darshana Samaraweera, davbene74, desmondtoxic, Dicky Wong, dongsan0617, Donnie Drajat, dsavse, duerghast1, dvorynen, eder_japan, edwardoppm, eliobatista, Fábio Magalhães, fflorezangel, forumes, Freddy Heyd, Gizmo79, gntgnt8, hadipurwanto, HappyForex, hendrikwong, hhh45, Hoooba14, Hyunki Choi, ihkpessii, Inderjeet Singh Sandhu, ivan.f.yin, jlhtrader, jmuntjan, Joe0013, Jorge Martinez, Jose Ferreira Nascimento, jplute, jvalenzuela.esp, Kamil Szeremet, kashif_raza, Kelvin Kabange Mwamba, krudr.tee, lehuyvu1972, Lelia Izy Seutloali, Leon, Limiter, Lucas Alonso, lydaravin6, lyoung4472, machs_nochmal, madanluhar, magallan09, Magdalena Kwiecińska, Marco Antonio Dorantes, martinesleonardo, Mas69, masm20, medemaray, mehullakhani92, miguefx, mozayyenifar, multicoms, m_peyman2000, n05p43, n111, nestor20038, nguyentrieuit, omama406, Oscar Sim Yik Chiang, palexis479, patblack2000, pathumjm123, Peakpond Pond, Phacharawatt Nissayant, pigman50, pintuis100, pirro, pisc.serv, pky2j2000, pooria.rahmati2, Prateek Khare, ptctodo, ptumde, rachidyouchi, rad1958, Rafael Ramos, Rati Robson Kaydee, rhwillms, romiekabelo, roshan5999, Roson Chea, rwmngt, sammie2kuk, sanjivam, sansar9193, sasastephe, seelan.043, seenuchennai, shiki_amber, slavadu, slmssk, sohailahm7, Sopon Seeon Live, srca7354, Sry Lai Sreang, starlimit, steveibiks1205, stonelove, sunwindside, Suzanne Abt, Takeme Toyoure Lazyboy, Tam Van Nguyen, tamaragist97, Tarek Almaremi, Thobib Herba Qaseh, tienhai, Titus Nomsure, topaz790, topbestfx, trade3925, trade4xxind, tradingralf, Trần Quốc Việt, transprint7, Uli333, urdivine, Varich Patchotchai, Victoriano, vieri, Vincent Yee, Virulh Jirathitikal, vishnupriyan, vodafone2066, waterfall, wellramos84, why, Wllie Bester, xzlllhs, yehudit_i, Youness Ettoumi, yusuphamries, Zdeněk Dvořák, ze2848, Zhao Fung, ZHOUBAO, zombi, 남궁환

     


    Copyright MT4talk.com Forum Rules - Privacy Policy.