Great coders here. Pls could someone code a trailing stop ea that's based on this "bat atr stop". Preferably a hidden trailing stop with start trailing level option. I love this batatr stop because it's a way of pulling back a bit to wait for price pullback to complete and continue when price start moving again in your favour.
Thanks
Hi.
Great coders here. Pls could someone code a trailing stop ea that's based on this "bat atr stop". Preferably a hidden trailing stop with start trailing level option. I love this batatr stop because it's a way of pulling back a bit to wait for price pullback to complete and continue when price start moving again in your favour.
Thanks
Hi,
... Somehow it doesn't works. ...
- "Somehow it doesn't work" does not tell us where is the problem.
- Have you looked into the log?
- Have you tried to find the proble by using a) Comment(), b) Print(), c) Degugger?
- Your little code snippet is way too tiny...
Hi,
I'm trying to code a stochastic for M1 which take the data of M15. Somehow it doesn't works. been trying to figure out. Any senior could help me. thank you!!
Here's my code
Thank you!!!
You should describe what error are you getting or unexpected behavior. Writing "does not work" is like telling your doctor "I feeling unwell".
By looking your code, the only strange thing I see is this (int)sto_price
iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)<=sto_dn_level
This value should be 0 or 1 as explained in iStochastic description: https://docs.mql4.com/indicators/istochastic
price_field
[in] Price field parameter. Can be one of this values: 0 - Low/High or 1 - Close/Close.
- docs.mql4.com
iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)<=sto_dn_level && : {ArrUpBuffer[i]=You are mixing apples and oranges.
You should describe what error are you getting or unexpected behavior. Writing "does not work" is like telling your doctor "I feeling unwell".
By looking your code, the only strange thing I see is this (int)sto_price
This value should be 0 or 1 as explained in iStochastic description: https://docs.mql4.com/indicators/istochastic
Here is the M15. as you can see on the chart that the arrow appear here in M15. Stoch is at OB and MACD is below 0.
Here at M1, Stoch is at OB, but there isn't any arrow.
So i will put the indicator in M1 chart.
The indicator work this way, when M15 Stoch is at OB and MACD is Below 0 and M1 Stoch is at OB, arrow will appear on the chart(M1)
Here's my whole code
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- Arrow #property indicator_label1 "ArrUp" #property indicator_label2 "ArrDn" //--- input parameters enum eprice { s0 = 0,//LOW/HIGH s1 = 1 //CLOSE/CLOSE }; //---------------------------------------------------------------------------------------- input string __________1__________="xxxxxxxxxxxxxxxxxxxxx"; input string __________2__________="=ALERT=";//ALERT ARROW AND NOTIFICATIONS, input string __________3__________="xxxxxxxxxxxxxxxxxxxxx"; input bool ARROW = true;//SHOW ARROW input string __________4__________="xxxxxxxxxxxxxxxxxxxxx"; input string __________5__________="=ARROW CODE=";//ARROW DETAILS input string __________6__________="xxxxxxxxxxxxxxxxxxxxx"; input int ARROWUP =217;//ARROW CODE input int ARROWDN =218;//ARROW CODE input color ARROWUPc=clrWhite;//Arrow Up Color input color ARROWDNc=clrWhite;//Arrow Dn Color input string __________10__________="xxxxxxxxxxxxxxxxxxxxx"; input string __________11__________="=M15 OB OS=";//OB OS, input string __________12__________="xxxxxxxxxxxxxxxxxxxxx"; input double sto_dn_level = 20.0;//LEVEL Down input double sto_up_level = 80.0;//LEVEL Up input eprice sto_price=1;//PRICE FIELD //---------------------------------------------------------------------------------------- //--- indicator buffers double ArrUpBuffer[]; double ArrDnBuffer[]; //--- //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping IndicatorBuffers(2); SetIndexBuffer(0,ArrUpBuffer);SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1,ARROWUPc);SetIndexArrow(0,ARROWUP); SetIndexBuffer(1,ArrDnBuffer);SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1,ARROWDNc);SetIndexArrow(1,ARROWDN); //--- 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[]) { //--- int i,limit; limit=rates_total-prev_calculated; if(prev_calculated>0)limit=limit+2; for(i=limit-2;i>=0;i--) { if(ARROW && iMA(_Symbol,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,i)>iMA(_Symbol,PERIOD_M15,100,0,MODE_EMA,PRICE_CLOSE,i) && iMA(_Symbol,PERIOD_M15,100,0,MODE_EMA,PRICE_CLOSE,i)>iMA(_Symbol,PERIOD_M15,200,0,MODE_EMA,PRICE_CLOSE,i) && iMACD(_Symbol,PERIOD_M15,12,26,1,PRICE_CLOSE,MODE_MAIN,i)>0.0 && iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)<=sto_dn_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)<=sto_dn_level ) {ArrUpBuffer[i]=iLow(_Symbol,PERIOD_M1,i)-10*pix_y();} if(ARROW && iMA(_Symbol,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,i)<iMA(_Symbol,PERIOD_M15,100,0,MODE_EMA,PRICE_CLOSE,i) && iMA(_Symbol,PERIOD_M15,100,0,MODE_EMA,PRICE_CLOSE,i)<iMA(_Symbol,PERIOD_M15,200,0,MODE_EMA,PRICE_CLOSE,i) && iMACD(_Symbol,PERIOD_M15,12,26,1,PRICE_CLOSE,MODE_MAIN,i)<0.0 && iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)>=sto_up_level && iStochastic(_Symbol,PERIOD_M15,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)>=sto_up_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_MAIN,i)>=sto_up_level && iStochastic(_Symbol,PERIOD_M1,3,1,3,MODE_EMA,(int)sto_price,MODE_SIGNAL,i)>=sto_up_level ) {ArrDnBuffer[i]=iHigh(_Symbol,PERIOD_M1,i)+10*pix_y();} } return(rates_total); } //+------------------------------------------------------------------+ double pix_y() { return((ChartGetDouble(0,CHART_PRICE_MAX,0)-ChartGetDouble(0,CHART_PRICE_MIN,0))/ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0)); } //+------------------------------------------------------------------+
Hi Sire. what do you mean? i have send my whole code above.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I'm trying to code a stochastic for M1 which take the data of M15. Somehow it doesn't works. been trying to figure out. Any senior could help me. thank you!!
Here's my code
Thank you!!!