//+------------------------------------------------------------------+ //| MTF_BrainTrend2-all-in-one.mq4 | //| www.forex-tsd.com | //| Nick Bilak | //| Modified by Serge skhorouji@gmail.com| //+------------------------------------------------------------------+ /* Serge: This indicator includes 3 original BrainTrend2 indicators as I am 2 lazy to apply them all one by one on a chart: BrainTrend2Stop, BrainTrend2StopLine, BrainTrend2Sig Note: BrainTrend2 indicator is not included as we use BrainTrend1 indicator for trend direction It has customisable external variables that can be played with during optimisation Also I renamed variables, simplified & logically re-arranged the codes of the original indicators to make them more understandable (I mean for myself :-) */ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "www.forex-tsd.com" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Red #property indicator_color4 Blue #property indicator_color5 Red #property indicator_color6 Blue //---- input parameters extern int TimeFrame= 0; extern int NumBars=100; //If 0, all indicator will be drawn on the whole chart (from 1st bar) extern bool spread_eq_0=false; //if true, we will use spread=0 in all our calculations, if false we will use spread from the broker extern int AlertMode = 0; //0-off,1-warning mode,2-alert mode //---- buffers double sell_stop_dot_buf[]; //Sell stop dots, aka BrainTrend2Stop double buy_stop_dot_buf[]; //Buy stop dots double sell_stop_line_buf[]; //Sell stop line, aka BrainTrend2StopLine double buy_stop_line_buf[]; //Buy stop line double sell_signal_buf[]; //Sell signal dots, aka BrainTrend2Sig double buy_signal_buf[]; //Buy signal dots double spread; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,115); SetIndexBuffer(0,sell_stop_dot_buf); SetIndexLabel(0,"sell_stop_dot"); SetIndexEmptyValue(0, EMPTY_VALUE); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,115); SetIndexBuffer(1,buy_stop_dot_buf); SetIndexLabel(1,"buy_stop_dot"); SetIndexEmptyValue(1, EMPTY_VALUE); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,sell_stop_line_buf); SetIndexLabel(2,"sell_stop_line"); SetIndexEmptyValue(2, EMPTY_VALUE); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,buy_stop_line_buf); SetIndexLabel(3,"buy_stop_line"); SetIndexEmptyValue(3, EMPTY_VALUE); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234); SetIndexBuffer(4,sell_signal_buf); SetIndexLabel(4,"sell_signal"); SetIndexEmptyValue(4, EMPTY_VALUE); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,233); SetIndexBuffer(5,buy_signal_buf); SetIndexLabel(5,"buy_signal"); SetIndexEmptyValue(5, EMPTY_VALUE); if (spread_eq_0 == false) spread=MarketInfo(Symbol(),MODE_SPREAD)*Point; else spread=0; } int start() { datetime TimeArray[]; int shift,limit,y,counted_bars=IndicatorCounted(); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); limit=Bars-counted_bars+TimeFrame/Period(); for(shift=0,y=0;shift