i am trying to create an EA that utilizes 2Bollinger 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.
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.
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);
}
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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.
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.
This is my other suggestion (which came from tsd 2010 and from tsd 2008):
----------------
Just to remind:
Coders (any coder) are coding for free:
----------------
and Freelance section of the forum should be used in most of the cases.
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
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)