Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code :
-------------------------------------------------------------+
//| ProjectName |//| Copyright 2020, CompanyName |//| http://www.companyname.net |//+------------------------------------------------------------------+#property copyright"Copyright 2023, DAVID BUTA"#include <Trade/Trade.mqh>
CTrade trade;
inputENUM_TIMEFRAMES tf = PERIOD_CURRENT;
inputint periods = 20;
inputdouble dev = 2.0;
inputstring expire = "03:00";
inputENUM_APPLIED_PRICE pr = PRICE_CLOSE;
int handlebb;
/// add values hereintOnInit()
{
handlebb = iBands(_Symbol,tf,periods,0,dev,pr);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnTick()
{
double upper[],lower[],middle[];
CopyBuffer(handlebb,BASE_LINE,1,2,middle);
CopyBuffer(handlebb,UPPER_BAND,1,2,upper);
CopyBuffer(handlebb,LOWER_BAND,1,2,lower);
double bbupper = upper[1];
double bblower = lower[1];
double bbmiddle = middle[1];
double low1 = iLow(_Symbol,tf,1);
double low2 = iLow(_Symbol,tf,2);
double high1 = iHigh(_Symbol,tf,1);
double high2 = iHigh(_Symbol,tf,2);
double close1 = iClose(_Symbol,tf,1);
double open1 = iOpen(_Symbol,tf,1);
double low_index = iLowest(_Symbol,tf,MODE_LOW,10,1);
double high_index = iHighest(_Symbol,tf,MODE_HIGH,10,1);
double range = high1 - low1;
double kt = high1 - (0.3 * range);
double kt1 = low1 + (0.3 * range);
double range_value = range / 2;
datetimeexp = StringToTime(expire);
if(close1 > open1 || close1 < open1) // bullish or bearish
{
double body = close1 > open1 ? close1 - open1 : open1 - close1; // bullish ? then body is that valueif(low1 < low2 && high1 > high2) // engulfs
{
if(body > range_value) // not a weakie
{
if(low_index == 1 && at_zone(high1,low1)) // highest low value of the previous 10 candles, starting from
{ // position 1if(at_bands(high1,low1,bbupper,bblower) == "buy") // bands function signals a buy
{ double tp = high1 + range *1.5;
tp = NormalizeDouble(tp,3);
trade.BuyStop(1.0,high1,_Symbol,low1,tp,ORDER_TIME_GTC,exp,"me");
}
}
elseif(high_index == 1 && at_zone(high1,low1))
{
if(at_bands(high1,low1,bbupper,bblower) =="sell")
{ double tp1 = low1 - range * 1.5;
tp1 = NormalizeDouble(tp1,3);
trade.SellStop(1.0,high1,_Symbol,low1,tp1,ORDER_TIME_GTC,exp,"me");
}
}
}
}
}
elseif((close1 >= kt && open1 >= kt) ||(close1 <= kt1 && open1 <= kt1)) // bullish or bearish kt
{
if(low_index == 1 && at_zone(high1,low1))
{
if(at_bands(high1,low1,bbupper,bblower) == "buy")
{
trade.BuyStop(1.0,high1,_Symbol,low1,high1 + range * 1.2,ORDER_TIME_GTC,exp,"me");
}
}
elseif(high_index == 1 && at_zone(high1,low1))
{
if(at_bands(high1,low1,bbupper,bblower) == "sell")
{
trade.SellStop(1.0,high1,_Symbol,low1,low1 - range * 1.2,ORDER_TIME_GTC,exp,"me");
}
}
}
}
//+------------------------------------------------------------------+bool at_zone(double high,double low)// this function proves whether the setup is on a support and resistance zone or not
{
int v = 0;
double zones [] = {102.839,134.560,126.212,119.395,122.873,110.074,105.622,108.462,107.042,115.933,111.364,
112.043,124.640,121.182,117.662,132.729,123.775,128.715,114.053,104.511,109.226,116.932,120.298,118.628,
127.912,131.377};
for(int i=0; i< ArraySize(zones); i++)
{
if(high > zones[i] && low < zones[i]) // INCLUDE THE PIPS FOR SLIPPAGE, as well as the indication values
{
v +=1;
}
}
if(v == 1)
{
returntrue;
}
elsereturnfalse;
}
string at_bands(double high, double low,double ub,double lb) // this function proves that the setup is either in
{ // one of the upper and lower bands or above or below themif((high >= lb && low <= lb) || high < lb)
{
return"buy";
}
elseif((high >= ub && low <= ub) || low > ub)
{
return"sell";
}
elsereturn"false";
}
I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.
Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code :
If your program compiles without error but doesn't do what it should use the debugger:
I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.
A product from the MetaTrader Market can be purchased on the MQL5.com website or straight from the MetaTrader 4 and MetaTrader 5 trading platforms. Choose a desired product that suits your trading style, pay for it using your preferred payment method, and activate the product.
Javier Santiago Gaston De Iriarte Cabrera: no errors, but no trades are done while testing ... why?
Please can some one help me I created an EA but it's not uploading on the chart and not opening trade during testing. I compiled it and no error on it.
@Michael Dede#: Please can some one help me I created an EA but it's not uploading on the chart and not opening trade during testing. I compiled it and no error on it.
If you need help with your code, then you will need to show your code.
Remember to also check your "Experts" log and "Journal" log for any related messages.
Also, please don't hijack other users threads for your unrelated issue.
Faster is to use _Symbol because it is a definition.
Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.
Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.
Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable ;)
Hi, I have a problem when try to check order at market. I'd like put two parameters into the function as magic and symbol but symbol optional.
If I write "findPos("right magic") doesn't work because it wants the second parameter _Symbol compulsorily...
I have Creat a Expert Adviser Based on Moving Average. I want to Modify my SL ,TP and Pending Order Price to the Moving Average Price.I have a problim With Trade Modefication Function I have Geting 4756 ERROR.Some one Please Help me with the Example. I am send A pending Buyy and Sell Limit.
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.
Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code :
I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.
Idont have a broker idownload metatrader5
Windows: https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe?utm_source=www.mql5.com&utm_campaign=download
Like the one for Linux, Mac, .. at the bottom of the page.
Hi guys , I just built my first EA using the trade class. The code compiles without errors but during the strategy testing in the strategy tester , the EA does not open any trades. In the journal tab , there are no error messages . Please help . Below is my code :
If your program compiles without error but doesn't do what it should use the debugger:
Code debugging: https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5: https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272
I've been trying to purchase a utility program with no success. I can't even get a reasonable response, or email with an explanation as to why I can't make a purchase. Who is the seller here? m I dealing with MQL or the owner of the program? If I have a valid credit card and bank account why can't I do business with the owner and not the robot of MQL. My ticket was closed with no action taken or action taken to resolve an issue unknown to me. As you may have guessed, I'm very frustrated dealing with a site that has no humans on duty during my working hours.
This might help:
https://www.mql5.com/en/articles/498
https://www.mql5.com/en/articles/1776
If you need help with your code, then you will need to show your code.
Remember to also check your "Experts" log and "Journal" log for any related messages.
Also, please don't hijack other users threads for your unrelated issue.
Faster is to use _Symbol because it is a definition.
Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.
Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.
Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable ;)
Hi, I have a problem when try to check order at market. I'd like put two parameters into the function as magic and symbol but symbol optional.
If I write "findPos("right magic") doesn't work because it wants the second parameter _Symbol compulsorily...
I'm currently looking for an ECN broker that has good spreads and proper regulation from either ASIC or FCA. Any recommendations?
Broker spread comparison tool.
Hello,
I have Creat a Expert Adviser Based on Moving Average. I want to Modify my SL ,TP and Pending Order Price to the Moving Average Price.I have a problim With Trade Modefication Function I have Geting 4756 ERROR.Some one Please Help me with the Example. I am send A pending Buyy and Sell Limit.
Best Regards.
Thank You !