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.

Reason: