#property copyright "Copyright 2018, Stein Investments" #property link "https://www.mql5.com/en/users/blueball" #property version "1.00" #property strict double Trend,Intensity,BuySL,SellSL,Range,LastSwitch; int fxTrendHandle; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- FX Trend handle fxTrendHandle=iCustom(NULL,PERIOD_M15,"Market\\FX Trend","",6,3.0,"",true); if(fxTrendHandle==INVALID_HANDLE) { Alert("Can't get a valid handle for FX Trend"); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- Comment(""); } //+------------------------------------------------------------------+ //| Get a buffer value | //+------------------------------------------------------------------+ double GetBufferValue(int indicatorHandle,int bufferIndex,int barIndex) { double data[1]; //--- if(CopyBuffer(indicatorHandle,bufferIndex,barIndex,1,data)!=1) return(EMPTY_VALUE); //--- return(data[0]); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- FX Trend code snippets Trend = GetBufferValue(fxTrendHandle,7,0); // Direction of a trend / 1=BUY / -1=SELL Intensity = GetBufferValue(fxTrendHandle,0,0); // Intensity of a trend BuySL = GetBufferValue(fxTrendHandle,1,0); // StopLoss for BUY trades-> This value is EMPTY during a SELL trend SellSL = GetBufferValue(fxTrendHandle,2,0); // StopLoss for SELL trades -> This value is EMPTY during a BUY trend Range = GetBufferValue(fxTrendHandle,3,0); // Range of the current valid trend from it's highest to it's lowest point LastSwitch = GetBufferValue(fxTrendHandle,4,0); // Timestamp of the last trend switch } //+------------------------------------------------------------------+