Hi Scriptor
can you add SendNotification when the trend changes, please
It would be perfect for me
Thanks
Mario
Hi Scriptor
Is it possible you check the code, something strange ( see image ) . Thks vm in advance. Neuch
Files:
Capture.JPG
149 kb
neuch:
Hi Scriptor
Is it possible you check the code, something strange ( see image ) . Thks vm in advance. Neuch
// Trailing_Stop_Level_m03.mq5
***

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Other Constants
- www.mql5.com
The CLR_NONE constant is used to outline the absence of color, it means that the graphical object or graphical series of an indicator will not be plotted. This constant was not included into the Web-color constants list, but it can be applied everywhere where the color arguments are required. The EMPTY_VALUE constant usually corresponds to the...
Mario Trinchero :
// Trailing_Stop_Level_m03.mq5
***
Use the button
neuch:
Hi Scriptor
Is it possible you check the code, something strange ( see image ) . Thks vm in advance. Neuch
// Trailing_Stop_Level_mod1.mq5 #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 2 #property indicator_label1 "Level for short" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_label2 "Level for long" #property indicator_type2 DRAW_LINE #property indicator_color2 clrGreen #property indicator_style2 STYLE_SOLID #property indicator_width2 1 input double InpPercent = 0.5; double BufferLevUP[],BufferLevDN[],BufferData[]; string IndicatorName, ShortName; int OnInit() { SetIndexBuffer(0,BufferLevUP,INDICATOR_DATA); SetIndexBuffer(1,BufferLevDN,INDICATOR_DATA); SetIndexBuffer(2,BufferData,INDICATOR_CALCULATIONS); IndicatorName=MQL5InfoString(MQL5_PROGRAM_NAME); ShortName =IndicatorName+"("+DoubleToString(InpPercent,2)+")"; IndicatorSetString(INDICATOR_SHORTNAME,ShortName); IndicatorSetInteger(INDICATOR_DIGITS,Digits()); ArraySetAsSeries(BufferLevUP,true); ArraySetAsSeries(BufferLevDN,true); ArraySetAsSeries(BufferData,true); return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(rates_total<4) return 0; ArraySetAsSeries(close,true); int limit=rates_total-prev_calculated; if(limit>1) { limit=rates_total-2; ArrayInitialize(BufferLevUP,EMPTY_VALUE); ArrayInitialize(BufferLevDN,EMPTY_VALUE); ArrayInitialize(BufferData,0); } for(int i=limit; i>=0 && !IsStopped(); i--) { double loss=close[i]*InpPercent/100; if(close[i]>BufferData[i+1] && close[i+1]>BufferData[i+1]) { BufferData[i]=fmax(BufferData[i+1],close[i]-loss); BufferLevDN[i]=BufferData[i]; BufferLevUP[i]=EMPTY_VALUE; } else { if(close[i]<BufferData[i+1] && close[i+1]<BufferData[i+1]) { BufferData[i]=fmin(BufferData[i+1],close[i]+loss); BufferLevUP[i]=BufferData[i]; BufferLevDN[i]=EMPTY_VALUE; } else { if(close[i]>BufferData[i+1]) { BufferData[i]=close[i]-loss; BufferLevDN[i]=BufferData[i]; BufferLevUP[i]=EMPTY_VALUE; } else { BufferData[i]=close[i]+loss; BufferLevUP[i]=BufferData[i]; BufferLevDN[i]=EMPTY_VALUE; } } } } return(rates_total); }
Vladimir Karputov:
Use the button
Thanks Vladimir

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Trailing_Stop_Level:
The indicator displays possible StopLoss levels on the price chart. Levels are shown separately for Long and Short positions. The indicator is similar to Mod_ATR_Trailing_Stop, but has a different calculation basis - in percentage.
It has one input parameter:
Author: Scriptor