![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
thanks mladen .....![](https://c.mql5.com/forextsd/smiles/smile.png)
but not work ....![](https://c.mql5.com/forextsd/smiles/frown.png)
//+------------------------------------------------------------------+
//| text.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern int timeframe1 = PERIOD_H1;
extern int timeframe2 = PERIOD_D1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
string name1="";
string name2="";
color color1;
color color2;
double H1 = iClose(NULL,timeframe1,0);
double D1H = iHigh(NULL,timeframe2,1);
double D1L = iLow(NULL,timeframe2,1);
if(H1>D1H)
{
name1 = "up"; color1 = Blue;
}
if(H1<D1L)
{
name2 = "down"; color2 = Red;
}
ObjectCreate("signal",OBJ_LABEL,0,0,0,0,0);
ObjectSet("signal",OBJPROP_XDISTANCE,3);
ObjectSet("signal",OBJPROP_YDISTANCE,12);
ObjectSetText("signal",name1,12,"Tahoma",color1);
ObjectCreate("signal2",OBJ_LABEL,0,0,0,0,0);
ObjectSet("signal2",OBJPROP_XDISTANCE,59);
ObjectSet("signal2",OBJPROP_YDISTANCE,12);
ObjectSetText("signal2",name2,12,"Tahoma",color2);
//----
return(0);
}
//+------------------------------------------------------------------+
thanks mladen .....![](https://c.mql5.com/forextsd/smiles/smile.png)
but not work ....![](https://c.mql5.com/forextsd/smiles/frown.png)
I think that this peace of code could interest you.
Instead of using graphic object I used normal buffers.
This indi compares ALLWAYS H1 and D1
So, it wont mark prices above H1 timeframe, but it will
mark on equal or lower timeframes than H1. Sometimes
it looks wierd, on lower timeframes (like marking bars
too early) but if you look closer to hourly shift then it's
fine.
dhl_e.mq4
I think that this peace of code could interest you.
Instead of using graphic object I used normal buffers.
This indi compares ALLWAYS H1 and D1
So, it wont mark prices above H1 timeframe, but it will
mark on equal or lower timeframes than H1. Sometimes
it looks wierd, on lower timeframes (like marking bars
too early) but if you look closer to hourly shift then it's
fine.
![](https://c.mql5.com/forextsd/forum/120/gbpusdh1.png)
dhl_e.mq4thanks kalenzo ... will try this indi
thanks mladen .....![](https://c.mql5.com/forextsd/smiles/smile.png)
but not work ....![](https://c.mql5.com/forextsd/smiles/frown.png)
//+------------------------------------------------------------------+
//| text.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern int timeframe1 = PERIOD_H1;
extern int timeframe2 = PERIOD_D1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
string name1="";
string name2="";
color color1;
color color2;
double H1 = iClose(NULL,timeframe1,0);
double D1H = iHigh(NULL,timeframe2,1);
double D1L = iLow(NULL,timeframe2,1);
if(H1>D1H)
{
name1 = "up"; color1 = Blue;
}
if(H1<D1L)
{
name2 = "down"; color2 = Red;
}
ObjectCreate("signal",OBJ_LABEL,0,0,0,0,0);
ObjectSet("signal",OBJPROP_XDISTANCE,3);
ObjectSet("signal",OBJPROP_YDISTANCE,12);
ObjectSetText("signal",name1,12,"Tahoma",color1);
ObjectCreate("signal2",OBJ_LABEL,0,0,0,0,0);
ObjectSet("signal2",OBJPROP_XDISTANCE,59);
ObjectSet("signal2",OBJPROP_YDISTANCE,12);
ObjectSetText("signal2",name2,12,"Tahoma",color2);
//----
return(0);
}
//+------------------------------------------------------------------+
You are comparing two different time frames
If a current bar of a time frame 1 is higher or lower of a fisrt closed bar of time frame 2, then the message is going to be displayed. If the current bar of time frame 1 is not higher or lower of previous high and low of time frame 2 then nothing is going to be displayed. From the code you posted it seemed like that was your intention (in my tests it worked OK)
___________________
PS: it will not show text on historical data (previous data). If you want it to show on historical data then all needs to be written completely different as a classical indicator
EA for auto place stoploss And Take profit depend on Fibo Line
Hi
I want to create a EA that can place stop loss and take profit one every order!
The EA must see the sell price or buy price and for Example for buy price:
if opening order price between line 38.2 and 50 the ea automatically place stop loss on one line before fibo=23.6 and place take profit on one line after fibo=61.8
with this procedur EA do for sell position,for example if position is Sell stop@ X price and 38.2 fibo<x<50 fibo! EA automatically place take profit On 23.6 fibo and stop loss on 61.8 fibo line!!
any one can help me with code of this EA or tell me a similar code of this EA!!
****note:
fibo line is automatically calculated by Low And High of last Day!!!!
Tnx
You are comparing two different time frames
If a current bar of a time frame 1 is higher or lower of a fisrt closed bar of time frame 2, then the message is going to be displayed. If the current bar of time frame 1 is not higher or lower of previous high and low of time frame 2 then nothing is going to be displayed. From the code you posted it seemed like that was your intention (in my tests it worked OK)
___________________
PS: it will not show text on historical data (previous data). If you want it to show on historical data then all needs to be written completely different as a classical indicatorthank for you mladen ... if u have time please make it to show historical data ....
PS : this indi can help me to show me Trend UP or Trend Down
thank for you mladen ... if u have time please make it to show historical data .... PS : this indi can help me to show me Trend UP or Trend Down
rizkyd
Did you try using multi time frame donchian channel for that (for example to set the time frame of the donchian channel to daily and period to 1 and you would get almost exactly the same thing that you are looking for)
Newcomer wants advice/help![](https://c.mql5.com/forextsd/smiles/smile.png)
Hello there,
I'm new to forex, and at the moment interested about indicators and EAs. I have some understanding about mq4 code, but thats not enough yet to get what i want. So i would like to ask advice/help from experts or people who knows enough about mq4 coding.
My current task is add custom indicator to EA, and by the way i got a nice EA template (think) im going to share it with you![](https://c.mql5.com/forextsd/smiles/smile.png)
Ok so, my final buy/sell signals from indicator are these: g_ibuf_BUY[1] and g_ibuf_SELL[1]
here part of code when indicator playing sound, pop up, sending email.
string ls_ms = "MS PRO";
if (g_ibuf_BUY[1] == Low[1] - Arrow_Distance * Point && gi_flag_alert != Time[0]) {
if (Alert_PopUp_On) Alert(ls_ms + ": BUY | " + Symbol() + " " + TfToStr(Period()) + " | ", TimeToStr(TimeLocal(), TIME_SECONDS), " | " + DoubleToStr(Ask, 4));
PlaySound(ProcessBuySound(Buy_Sound));
gi_flag_alert = Time[0];
if (Send_Email) {
SendMail(ls_ms + " Alert! ", Symbol() + " " + TfToStr(Period()) + " - BUY signal issued at " + TimeToStr(TimeLocal(), TIME_SECONDS) + " on " + TimeToStr(TimeCurrent(),
TIME_DATE) + " (Last price: " + DoubleToStr(Ask, 4) + ")" + "\r\n \r\n Scalper PRO");
}
}
if (g_ibuf_SELL[1] == High[1] + Arrow_Distance * Point && gi_flag_alert != Time[0]) {
if (Alert_PopUp_On) Alert(ls_ms + ": SELL | " + Symbol() + " " + TfToStr(Period()) + " | ", TimeToStr(TimeLocal(), TIME_SECONDS), " | " + DoubleToStr(Ask, 4));
PlaySound(ProcessSellSound(Sell_Sound));
gi_flag_alert = Time[0];
if (Send_Email) {
SendMail(ls_ms + " Alert! ", Symbol() + " " + TfToStr(Period()) + " - SELL signal issued at " + TimeToStr(TimeLocal(), TIME_SECONDS) + " on " + TimeToStr(TimeCurrent(),
TIME_DATE) + " (Last price: " + DoubleToStr(Ask, 4) + ")" + "\r\n \r\n Scalper PRO");
}
}
}Next step would be add these signals to EA template? Mhm how... do i have to use iCustom function or something else needed add to indicator before i can use it? Any help will be appreciated. Thank you.
Hello there,
I'm new to forex, and at the moment interested about indicators and EAs. I have some understanding about mq4 code, but thats not enough yet to get what i want. So i would like to ask advice/help from experts or people who knows enough about mq4 coding.
My current task is add custom indicator to EA, and by the way i got a nice EA template (think) im going to share it with you
Ok so, my final buy/sell signals from indicator are these: g_ibuf_BUY[1] and g_ibuf_SELL[1]
here part of code when indicator playing sound, pop up, sending email.
string ls_ms = "MS PRO";
if (g_ibuf_BUY[1] == Low[1] - Arrow_Distance * Point && gi_flag_alert != Time[0]) {
if (Alert_PopUp_On) Alert(ls_ms + ": BUY | " + Symbol() + " " + TfToStr(Period()) + " | ", TimeToStr(TimeLocal(), TIME_SECONDS), " | " + DoubleToStr(Ask, 4));
PlaySound(ProcessBuySound(Buy_Sound));
gi_flag_alert = Time[0];
if (Send_Email) {
SendMail(ls_ms + " Alert! ", Symbol() + " " + TfToStr(Period()) + " - BUY signal issued at " + TimeToStr(TimeLocal(), TIME_SECONDS) + " on " + TimeToStr(TimeCurrent(),
TIME_DATE) + " (Last price: " + DoubleToStr(Ask, 4) + ")" + "\r\n \r\n Scalper PRO");
}
}
if (g_ibuf_SELL[1] == High[1] + Arrow_Distance * Point && gi_flag_alert != Time[0]) {
if (Alert_PopUp_On) Alert(ls_ms + ": SELL | " + Symbol() + " " + TfToStr(Period()) + " | ", TimeToStr(TimeLocal(), TIME_SECONDS), " | " + DoubleToStr(Ask, 4));
PlaySound(ProcessSellSound(Sell_Sound));
gi_flag_alert = Time[0];
if (Send_Email) {
SendMail(ls_ms + " Alert! ", Symbol() + " " + TfToStr(Period()) + " - SELL signal issued at " + TimeToStr(TimeLocal(), TIME_SECONDS) + " on " + TimeToStr(TimeCurrent(),
TIME_DATE) + " (Last price: " + DoubleToStr(Ask, 4) + ")" + "\r\n \r\n Scalper PRO");
}
}
}You can not import alerts into another peace of code (indicator, EA).
The cleanest way to do what you want is using iCustom()
Dear Mladen/MrTools,
Kind request to make an Indicator based on the below logic for 1 minute chart ... It should also alert with buy/sell arrows on chart ..
logic for buy entry :
one minute EMA(90) crossing over one minute EMA(390) ( meaning the previous minute ema 90 is less than ema 390) and the ema(90) should also be greater than ema(150)
logic for buy exit :
one minute EMA(90) > EMA(390) and the ema(90) < ema(150).
logic for sell entry :
one minute EMA(90) cutting down one minute EMA(390) ( meaning the previous minute ema 90 is greater than ema 390) and the ema(90) should also be less than ema(150)
logic for sell exit :
one minute EMA(90) ema(150).
*******************************************************
Nest code for the same logic is also shared below :
buy alert expression
EMA(CLOSE,90) > EMA(CLOSE,390) and REF(EMA(CLOSE,90),1) EMA(CLOSE,150)
buy exit expression
EMA(CLOSE,90) > EMA(CLOSE,390) and EMA(CLOSE,90) < EMA(CLOSE,150)
sell alert expression
EMA(CLOSE,90) REF(EMA(CLOSE,390),1) and EMA(CLOSE,90) < EMA(CLOSE,150)
sell exit expression
EMA(CLOSE,90) EMA(CLOSE,150)
Thanks
Thanks a lot