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
quick EA modification
Hi,
Need some help, I tried to change the code below but the EA kept crashing MT4.
I want the order to close when the current bar (so the bar where the order was executed) closes. Basically trade one bar.
This is the original code, it trades from signal to signal.
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+
if (signaldown!=EMPTY_VALUE&&signaldown!=0) Order = SIGNAL_CLOSEBUY;
//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+
if (signalup!=EMPTY_VALUE&&signalup!=0) Order = SIGNAL_CLOSESELL;
//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+
//if (timeprev!=Time[0]){
// timeprev = Time[0];
if (signalup!=EMPTY_VALUE&&signalup!=0)
{
Order = SIGNAL_BUY;
}
if (signaldown!=EMPTY_VALUE&&signaldown!=0){
Order = SIGNAL_SELL;
}
// }
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (100 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
//Sell
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (100 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (!EachTickMode) BarCount = Bars;
return(0);
}
//+------------------------------------------------------------------+Can anyone help me out?
Please help!!!!!
I need an ea makes the following
at a certain time set 4pc buy or sell order
functions:
order open time (variable 00-24)
order1 sell or buy lot (0.01 .0,02... 1) TP (+ xx pips from oppen) SL (- xx pips from open)
order2 sell or buy lot (0.01 .0,02... 1) TP (+ xx pips from oppen) SL (- xx pips from open)
order3 sell or buy lot (0.01 .0,02... 1) TP (+ xx pips from oppen) SL (- xx pips from open)
order4 sell or buy lot (0.01 .0,02... 1) TP (+ xx pips from oppen) SL (- xx pips from open)
THANX
Need to add to my EA a code to disable it at certain price level
Hello,
I need to add to my Ea a code to disable and enable it at certain price levels.
I searched and found that I can do it with
# iclude<WinUser32mqh
extern bool Disable Ea = true // from X (examply1.4420) to Y(examply1.4380) and from Z (examply1.4480) to N(examply1.4520) //
extern bool Enable Ea = true // from R(examply -1.4420) to T(examply -1.4480)
Will appreciate help with translating these conditions into a code, so in the EA's dialog box I could just input the price level for disable / enable the EA.
After some search and study I found that writing in the EA's start function a code would start it at certain conditions.
So under expert start function I wrote following:
if(PRICE_MEDIAN (SellLevel-Point*BufferPips))
return (0)
------------------------------------------------------------------------------------------------------------------
BufferPips I added in the extern double so in dialog box I could change it's value.
I am not if PRICE_MEDIAN is a good choice.
I am getting compile error - unbalanced left parenthesis.
Help appreciated
help me auto trading
Hi, Mr. Guru!
i have auto trading but it don't run, please help me!
Hi Mario,
I think this condition if(current_shortEma == current_longEma)
is never true. usually to detect a cross you need to do this
if(current_shortEma > current_longEma && last_shortEma < last_longEma){
//cross from bottom
}
if(current_shortEma last_longEma){
//cross from top
}
More detailed info here:
https://www.mql5.com/en/forum/trading_systems
Thanks
MIkhail
I got a coding request too ---- need a coder (very simple task)
We know HA -- henki ashi seldom be wrong
during consolidation , or almost U-turn, it would get shorter and shorter
while when the trending is still strong, HA for that bar will be LONG
THEREFORE
would it be Neat if we have an indicator that tell us the trend strength
the idea is easy
--- first , it should be any HA will do (I enclose my ex4 only, but have to find one MQ4 -- for HA) and modify it (simple task I assume)
there is only 2 color for HA , one blue *up ---- + ---- and one pink/violet *down
-- second, when the HA have to draw the HA stuff in the chart, there is LENGTH -- length of that HA
--- third, when it is approaching U-turn, the HA bar will get shorter and shorter
let assume, when the LENGTH of the HA bar (by trial and error) shorter than 0.4 cm, then we draw it BLACK (i.e. not blue / pink)
it will warn us NOT TO ENTER and exit soon
This way, we just have to enter (with no fear) according to the HA trend strength --- just like my other idea, very SIMPLE, extremely helpful
coder -- please don't use the ex4 that I enclose, just hit [SEARCH] in the forum and type in henki ashi , search for some MQ4 with all the code
------
when you completed or after you change it to 3 to 4 color (could be 3 color , rather than 4 color)
please send a PM private message to me, with the LINK, so I can upload it, after you start, if you want, I could give you another indicator that will tell you what is the best timing to change color to BLACK too -- black is kind of warning color
----- i.e. you can DOWNLOAD the ex4 that I enclosed, but use another MQ4 pls ---
thanks, it will be good indicator for all of us, and the coding should be pretty simple, and straight forward
the code is in the beginning , similar to the above diagram
if my guess is correct, g_ibuf_## control the length of the HA bar
we just have to print out all the g_ibuf value with the function called "comment"
then run the chart for a few days, and take a look at the g_ibuf value, when it get small, and note the VALUE of that variable
then when we have a time slot to code, we just code 1 to 2 color -- let's say , black and dark grey into the coding, when the histogram g_ibuf is SMALLER THAN certain noted value
so it suppose to be simple -- otherwise, could try trial and error to find the best fit VALUE (to be SMALLER THAN)
sincerely
xx3xxx -- I upload my MQ4 for version 4 there, I guess you can use this one, this seem to be longer and thicker than the other HA that I've got
Trix indicator needs alert
Coder Guru or anyone else, can you program a sound,notification alert and t3_trix_x2roc_clr_nrp_mtf.mq4t3_trix_x2roc_clr_nrp_mtf.mq4e mail alert in this Trix indicator whenever either the long term or short term Trix line changes color from red to green or vice versa. Thanks