Coding help - page 790

 
Jasin Oulad #: I want to convert an EA from mt4 to mt5, is this possible?
  1. Only if you have the code.
  2. Top of every page is Freelance.
 

PLEASE HELP ME SOLVE THIS PROBLEM IN MY MT5 EA 



i am trying to create an EA that utilizes 2 Bollinger Bands (one with 1 std and and another with 1.5 std)

and i enter a position with a close below the bb(1 std) and markets price with a sl at the larger bb and a tp at the middle line , i wanna automatically modify the oder such that it moves the sl and tp to the latest value of the bolllinger band and the middle line i.e. the current candle has an index of 0 and the previous candle has an index of 1, so the bb values at index 1 . i want this to happen until either sl/tp is hit. can someone please guide me into the right direction??? i am an amateur and just getting started with this EA stuff. i am aware i can get the position ticket and use that to modify sl/tp but i have a hard time extracting the 2 values from the bb , the initial tp/sl and the modified sl/tp with every candle. i can get the values from ibands function and use the copy buffer function to extract the values , but i am only successful doing so for the initial sl/tp how do i extract the values for the rolling sl/tp , please help me out , thank you for the help,appreciate it.

Bollinger Bands - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
Bollinger Bands (BB) are similar to Envelopes. The only difference is that the bands of Envelopes are plotted a fixed distance (%) away from the...
 

Coding Help needed in Mt5


When Average true range level reached trade should execute in next new candle, stop loos in pips, take profit in minutes.able to add martingale inputs.

Files:
nn.mq5  2 kb
 
Hi all, I tried to modify the ATR in pips indicator (original attached below) so to show/display tow different ATRs for two different periods on the chart (eg. ATR(10) for 10 days, and ATR (20) for 20 days). However my modification (code copied below) is not working- not showing the ATR values. Could someone please assist as to what I have done wrong/needs doing. Thank you.


#property copyright "Joshua Jones"
#property link      "http://www.forexfactory.com"
#property indicator_chart_window
#property indicator_buffers 1
//---- input parameters
extern int periods = 10;
extern int periods2 = 20;
extern double multiplier = 1.0;
extern int xDistance=120;
extern int yDistance=5;
extern int xDistance2=220;
extern int yDistance2=5;
extern int myFontSize  = 10 ;
extern color colorFont = Gold ;
extern string myFont   = "Arial" ;// "BRADDON"
int pipMult = 10000;
double buffer[];
double buffer2[];
string prefix = "";
string prefix2 = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if (StringFind(Symbol(),"JPY",0) != -1)
   {
      pipMult = 100;
   }
   if (multiplier != 1.0)
   {
      int percentage = multiplier*100;
      prefix = percentage + "% of ";
      prefix2 = percentage + "% of ";
   }
   
   SetIndexBuffer(0,buffer);
   SetIndexBuffer(0,buffer2);
   SetIndexLabel(0,"ATR (" + periods + ")");
   SetIndexLabel(0,"ATR2 (" + periods2 + ")");
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(0,DRAW_NONE);
   IndicatorShortName(prefix + "ATR (" + periods + ")");
   IndicatorShortName(prefix2 + "ATR2 (" + periods2 + ")");
   
   if(ObjectFind("label_ATRinPips")==-1 && ObjectFind("label_ATRinPips2")==-1)
     ObjectCreate("label_ATRinPips", OBJ_LABEL, 0, 0, 0);
     ObjectCreate("label_ATRinPips2", OBJ_LABEL, 0, 0, 0);
     
   ObjectSet("label_ATRinPips", OBJPROP_XDISTANCE, xDistance);
   ObjectSet("label_ATRinPips2", OBJPROP_XDISTANCE, xDistance2);
   ObjectSet("label_ATRinPips", OBJPROP_YDISTANCE, yDistance);
   ObjectSet("label_ATRinPips2", OBJPROP_YDISTANCE, yDistance2);
   
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   if(ObjectFind("label_ATRinPips")!=-1) ObjectDelete("label_ATRinPips");
   if(ObjectFind("label_ATRinPips2")!=-1) ObjectDelete("label_ATRinPips2");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;  
   int limit2;
   int counted_bars=IndicatorCounted(); 
//---- 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;
   limit2=Bars-counted_bars;

      for (int i = 0; i < limit; i++){
         double stopLoss = MathCeil(pipMult * multiplier * (iATR(NULL,0,periods,i)));
         //double stopLoss2 = MathCeil(pipMult * multiplier * (iATR(NULL,0,periods2,i)));
         buffer[i] = stopLoss;
         //buffer2[i] = stopLoss2;
      }
      
      for (int j = 0; j < limit2; j++){
         //double stopLoss = MathCeil(pipMult * multiplier * (iATR(NULL,0,periods,i)));
         double stopLoss2 = MathCeil(pipMult * multiplier * (iATR(NULL,0,periods2,i)));
         //buffer[i] = stopLoss;
         buffer2[i] = stopLoss2;
      }
      
      //Comment(prefix, "ATR (", periods, "): ", buffer[0], " pips");
      string text = prefix+ "ATR ("+ periods+ "): "+ DoubleToStr(buffer[0],0)+" pips";
      ObjectSetText("label_ATRinPips",text, myFontSize , myFont, colorFont);
      string text2 = prefix2+ "ATR2 ("+ periods2+ "): "+ DoubleToStr(buffer2[0],0)+" pips";
      ObjectSetText("label_ATRinPips2",text, myFontSize , myFont, colorFont);
      
      return(0);
  }
Files:
 
hi i need a coding for Mt5 multi time frame chart sync and all the drawing
 

This is my other suggestion (which came from tsd 2010 and from tsd 2008):

----------------

Just to remind:

Coders (any coder) are coding for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members of this forum.

----------------

and Freelance section of the forum should be used in most of the cases.

 
I am two EAs for MT5. I want to amend one of them, can any one help. Or, can anyone help me removing compile errors in second EA..  
 

Can anyone help me with this?

I want an indicator that draws an upward signal on the third candle if the previous two candles are up. It appears during the candle and disappears if it becomes red, and if it becomes green again, the signal appears again, as well as with bearish candles.

mt4

 
Comments that do not relate to this topic, have been moved to "Off-topic posts".
 
//+------------------------------------------------------------------+
//|                                                      ZZTrend.mq5 |
//|                                                      AmirHossein |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "AmirHossein"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#resource "\Indicators\Examples\ZigZag.ex5"
//--- input parameters
int      Depth=20;
int      Deviation=2;
int      Backstep=3;
int      collect_values=5;
double zz_values[];
datetime zz_times[];
int zz_handle;
double zzlow[];
double zzhigh[];
datetime zzlowtime[];
datetime zzhightime[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   zz_handle=iCustom(_Symbol,PERIOD_CURRENT,"::Indicators\Examples\ZigZag.ex5",Depth,Deviation,Backstep);
   ArrayResize(zz_values,collect_values,0);
   ArrayResize(zz_times,collect_values,0);
   ArrayResize(zzlow,collect_values,0);
   ArrayResize(zzlowtime,collect_values,0);
   ArrayResize(zzhigh,collect_values,0);
   ArrayResize(zzhightime,collect_values,0);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
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[])
  {
  
   collecting_zz_values();
   for(int a=0;a<collect_values;a++)
     {
      int b=a+1;
      if(zz_values[a]<zz_values[b])
        {
         zzlow[a]=zz_values[a];
         zzlowtime[a]=zz_times[a];
        }
      else
         if(zz_values[a]>zz_values[b])
           {
            zzhigh[a]=zz_values[a];
            zzhightime[a]=zz_times[a];
           }
     }
//----------------Low-----------------//
   for(int i=0;i!=ArraySize(zzlow);i++)
     {
      if((zzlow[i] == 0.0))
        {
         DellArrayElement(i,zzlow);
        }
     }
//----------------High-----------------//
   for(int h=0;h!=ArraySize(zzhigh);h++)
     {
      if((zzhigh[h] == 0.0))
        {
         DellArrayElement(h,zzhigh);
        }
     }
//------------------Trend Ditection--------------------//H,H|L,L
//    2 - Down trend
//    1 - Up trend
//    0 - trend is not defined
   int    trend;
   if(zzhigh[0]<zzhigh[1])
     {
      if(zzlow[0]<zzlow[1])
         trend=1;
      else
         trend=0;
     }
   if(zzlow[0]>zzlow[1])
     {
      if(zzhigh[0]>zzhigh[1])
         trend=2;
      else
         trend=0;
     }


//--- return value of prev_calculated for next call
   return(trend);
  }
//+------------------------------------------------------------------+
void collecting_zz_values()
  {
   int collected_values=0;
   int i=1;
   double zz_array[];
   while(collected_values<collect_values)
     {
      CopyBuffer(zz_handle,0,i,1,zz_array);
      if(zz_array[0]!=0.0)
        {
         zz_values[collected_values]=zz_array[0];
         // zz_times[collected_values]=iTime(_Symbol,PERIOD_CURRENT,i);
         collected_values++;
        }
      i++;
     }
  }
//+------------------------------------------------------------------+
void DellArrayElement(int shift, double &arr[])
  {
   int arrSize = ArraySize(arr);
   if(shift > arrSize)
      return;
   if(shift <= arrSize)
      ArrayCopy(arr, arr, shift, shift+1);
//arrSize=arrSize-2;
   ArrayResize(arr,arrSize-1);
  }
///+------------------------------------------------------------------+

//+------------------------------------------------------------------+

Hi!

I try to find the trend based on zigzag indicator.The code must return 2 for bearish ,1 for bullish and 0 for range.

But it returns only 10 or -1!!

whats the problem?

(plese ignor the times arrays.these are used for another code)