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
hi all
how i initialize a double value 1.7*e-107 in a variable definition;
double MyVar = ????;
regardsProbably this way:
double MyVar=1.7*MathExp(-107);
Probably this way: double MyVar=1.7*MathExp(-107);
Please guys i need some help on this EA...
the EA is meant to close half the lot when a condition is reached but unfortunately it , sometimes, closes half the remaining order continuously until it reaches a 0.01 Lot.
you will understand better when you look at the report Eg 'order' 15 and 35.
please assist on removing this manace.
sabri
EA using stochastics problem - help!
hi everyone
i'm trying to create a simple EA using stochastics with only a T/S and S/L
i don't know any coding, i'm using this:
Expert Advisor Builder for MetaTrader 4
when i use only a T/S it works great in every test i've made:
but to prevent some bad enterings i want to put a S/L
but when i use the S/L it doesn't work, it makes a error of some kind when testing...
is there anything wrong with the code?
plz help!!!
//+------------------------------------------------------------------+
//| This MQL is generated by Expert Advisor Builder |
//| Expert Advisor Builder for MetaTrader 4 |
//| |
//| In no event will author be liable for any damages whatsoever. |
//| Use at your own risk. |
//| |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"
extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.2;
extern int Slippage = 1;
extern bool UseStopLoss = True;
extern int StopLoss = 20;
extern bool UseTakeProfit = False;
extern int TakeProfit = 0;
extern bool UseTrailingStop = True;
extern int TrailingStop = 20;
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
double Var1 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, Current + 0);
double Var2 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, Current + 0);
double Buy1_1 = Var1 ;
double Buy1_2 = Var2 ;
double Sell1_1 = Var1 ;
double Sell1_2 = Var2 ;
//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+
//Check position
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| 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) |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| 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 (Buy1_1 > Buy1_2) Order = SIGNAL_BUY;
if (Sell1_1 < Sell1_2) Order = SIGNAL_SELL;
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * 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() < (1000 * 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);
}
//+------------------------------------------------------------------+
nevermind...
...thx anyway, but i seem to have solved the problem...and the EA is too flawed...just getting started in this automated trade thing lol
thx anyway...
best regards
...
If you experienced this and thought it was your mistake :
Since the last update (223) if you have indicators that use a lot of arrays (arrays, not indexes) and your terminal freezes (on my PC it goes to 95-96% of processor usage) when you change time frames or accounts, it is not your mistake ...
Also, since versions 220-221 terminal does not treat an empty date (0) as 01.01.1970 but as something mysterious (causing some indicators to crash completely) in a case like this we can read the line 1 of this post over and over, but...
_________________________________
PS: Also EA testing throws the computer in despair - simple MACD sample testing throws it to 97-98% processor time (my PC is not too strong (3GHz, 1.5 giga RAM), but not too slow either, so it is not up to the computer itself)
_________________________________
The problem is in me I guess : all the adds and commercial stuff is telling me that newer is better, and then ...
Deleting a Custom Indicator
Hi
I've just started learning/writing code for MT4 and have come up with a couple of poor but workable custom indicators that I find useful to have on my charts.
The problem I have at the moment is that it is a real pain when I want to delete one of them.
For example, I have an indicator that sounds an alarm where a set level is hit. But in order for me to turn off the alarm and remove the indicator, I need to go Charts (or Ctrl+I) > Indicators List. Then highlight the indicator I want to delete and then click on 'Delete'. I just think it would be quicker and easier if I could write some code started with a hot key that would delete a specified indicator from the list automatically.
The problem I have is that I can't find anything in the help files to do this. Is there a way to do it? Or am I looking for something that isn't there?
Any help would be much appreciated. Thanks in advance.
I don't recall seeing such a thing and to be honest it really wouldn't make much sense to have it as any kind of functionality in MQL.
Why don't you just recode the indicator to only sound X amount of times with Y delay inbetween?
Lux
EA wont execute trades! just alerts... HELP PLZ
Hi guys,
I have completed a EA from the EA builder from "sufx" and it is providing alerts (and therefore trading opportunities) but it is not executing the actual trade which makes it a useless EA.
Any ideas as to where to look to make it execute the trade??
HELP!!!!!
MASSIVE THANKS IN ADVANCE!
PS - Just so you know I have allowed "live trading"... and "disabled" ask for manual conformation...
Hi guys,
I have completed a EA from the EA builder from "sufx" and it is providing alerts (and therefore trading opportunities) but it is not executing the actual trade which makes it a useless EA.
Any ideas as to where to look to make it execute the trade??
HELP!!!!!
MASSIVE THANKS IN ADVANCE!
PS - Just so you know I have allowed "live trading"... and "disabled" ask for manual conformation...
Are you sure your code is ok?