Code Error generated by the coded copied into MQL4 editor are as follows..;' - unexpected end of program & unbalanced parentheses - Kindly see assist in fixing this errors - See detail source code below:
<Incorrectly posted code deleted>
Please read the topic. Your problem has probably already been addressed.
User has confessed in privte that the code was generated by ChatGPT.
',' - unexpected end of program7283
'{' - unbalanced parentheses661
can anyone tell me where is the error??
Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).
Finally, you also have the option to hire a programmer in the Freelance section.
@Wojujutari Kenni#: PLEASE i need help on unexpected end of programm and (for) expression are not allowed on a global scope. please how do i fixed this error
If your code was generated by ChatGPT, then we cannot help you! Learn to code or hire someone human to code it for you.
I am neew to coding and I decided to convert an indicator to a mqh file. I did about 98 percent but the error of '}' - unexpected end of programMySignal.mqh3023 was created.
Although, I try so many times to balance it and so on ... but the error is not fixed.
please help me out to sole this issue .
thanks in
Hi every one,
I am new to coding and I decided to convert an indicator to a mqh file. I did about 98 percent but the error of '}' - unexpected end of program MySignal.mqh 3023 was created.
Although, I try so many times to balance it and so on ... but the error is not fixed.
Please help me to solve this issue.
thanks, in advance.
//+------------------------------------------------------------------+//| MySignal.mqh |//| Copyright 2023, MetaQuotes Ltd. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2023, MetaQuotes Ltd."#property link"https://www.mql5.com"#include <Expert\ExpertSignal.mqh>
// wizard description start//+------------------------------------------------------------------+//| Description of the class |//| Title=Signal of the 'Custom Indicator' Detrended Price Oscillator| //| Type=SignalAdvanced |//| Name=DetrendedPriceOscillator |//| ShortName=DPO |//| Class=CSignalDetrendedPriceOscillator |//| Page=signal_ma |//| Parameter=PeriodMA,int,14,Period of averaging |//| Parameter=Shift,int,0,Time shift |//| Parameter=Method,ENUM_MA_METHOD,MODE_EMA,Method of averaging |//| Parameter=Applied,ENUM_APPLIED_PRICE,PRICE_CLOSE,Prices series |//| Parameter=Barstocount,int,400,Number of Bars to count |//| Parameter=TriggerCandle,int,Current,Previous,Candle to entry |//+------------------------------------------------------------------+// wizard description end//+------------------------------------------------------------------+//| Class CSignalDetrended Price Oscillator. |//| Purpose: Class of generator of trade signals based on |//| the 'Detrended Price Oscillator' indicator. |//| Is derived from the CExpertSignal class. |//+------------------------------------------------------------------+class CSignalMyCustInd : public CExpertSignal
{
protected:
CiCustom m_mci; // indicator object "MyCustomIndicator"//--- adjusted parametersint m_ma_period; // the "period of averaging" parameter of the indicatorint m_ma_shift; // the "time shift" parameter of the indicatorint m_DetrendedPriceOscillator_Barstocount; // the "Bars to count" parameter of the indicator int m_DetrendedPriceOscillator_TriggerCandle; // the "TriggerCandle" parameter of the indicatorENUM_MA_METHOD m_ma_method; // the "method of averaging" parameter of the indicatorENUM_APPLIED_PRICE m_ma_applied; // the "object of averaging" parameter of the indicator//--- "weights" of market models (0-100)int m_pattern_0; // model 0 "price is on the necessary side from the indicator"int m_pattern_1; // model 1 "price crossed the indicator with opposite direction"int m_pattern_2; // model 2 "price crossed the indicator with the same direction"int m_pattern_3; // model 3 "piercing"public:
CSignalMyCustInd(void);
~CSignalMyCustInd(void);
//--- methods of setting adjustable parametersvoid PeriodMA(int value) { m_ma_period=value; }
void Shift(int value) { m_ma_shift=value; }
void Method(ENUM_MA_METHOD value) { m_ma_method=value; }
void Applied(ENUM_APPLIED_PRICE value) { m_ma_applied=value; }
//--- methods of adjusting "weights" of market modelsvoid Pattern_0(int value) { m_pattern_0=value; }
void Pattern_1(int value) { m_pattern_1=value; }
void Pattern_2(int value) { m_pattern_2=value; }
void Pattern_3(int value) { m_pattern_3=value; }
//--- method of verification of settingsvirtualbool ValidationSettings(void);
//--- method of creating the indicator and time seriesvirtualbool InitIndicators(CIndicators *indicators);
//--- methods of checking if the market models are generatedvirtualint LongCondition(void);
virtualint ShortCondition(void);
protected:
//--- indicator initialization methodbool InitMyCustomIndicator(CIndicators *indicators);
//--- methods of getting data//- getting the indicator valuedouble Main(int ind) { return(m_mci.GetData(0,ind)); }
//- getting the signal line valuedouble Signal(int ind) { return(m_mci.GetData(1,ind)); }
//- difference between two successive indicator valuesdouble DiffMain(int ind) { return(Main(ind)-Main(ind+1)); }
int StateMain(int ind);
double State(int ind) { return(Main(ind)-Signal(ind)); }
//- preparing data for the searchbool ExtState(int ind);
//- searching the market model with the specified parametersbool CompareMaps(int map,int count,bool minimax=false,int start=0);
};
//+------------------------------------------------------------------+//| Constructor |//+------------------------------------------------------------------+
CSignalMyCustInd::CSignalMyCustInd(void) : m_ma_period(12),
m_ma_method(MODE_SMA),
m_ma_applied(PRICE_CLOSE),
m_pattern_0(0),
m_pattern_1(0)
{
//--- initialization of protected data
m_used_series=USE_SERIES_OPEN+USE_SERIES_HIGH+USE_SERIES_LOW+USE_SERIES_CLOSE;
}
//+------------------------------------------------------------------+//| Destructor |//+------------------------------------------------------------------+
CSignalMyCustInd::~CSignalMyCustInd(void)
{
}
//+------------------------------------------------------------------+//| Checking parameters of protected data |//+------------------------------------------------------------------+bool CSignalMyCustInd::ValidationSettings(void)
{
//--- validation settings of additional filtersif(!CExpertSignal::ValidationSettings())
return(false);
//--- initial data checksif(m_ma_period<=0)
{
printf(__FUNCTION__+": period must be greater than moving average value");
return(false);
}
//--- okreturn(true);
}
//+------------------------------------------------------------------+//| Create indicators. |//+------------------------------------------------------------------+bool CSignalMyCustInd::InitIndicators(CIndicators *indicators)
{
//--- check of pointer is performed in the method of the parent class//---//--- initialization of indicators and time series of additional filtersif(!CExpertSignal::InitIndicators(indicators))
return(false);
//--- creation and initialization of the custom indicatorif(!InitMyCustomIndicator(indicators))
return(false);
//--- okreturn(true);
}
//+------------------------------------------------------------------+//| Initialization of indicators. |//+------------------------------------------------------------------+bool CSignalMyCustInd::InitMyCustomIndicator(CIndicators *indicators)
{
//--- add an object to the collectionif(!indicators.Add(GetPointer(m_mci)))
{
printf(__FUNCTION__+": error adding object");
return(false);
}
//--- initialization of indicators and timeseries of additional filtersif(!CExpertSignal::InitIndicators(indicators))
{
return(false);
}
//--- create and initialize CSignalMyCustIndif(!InitMA(indicators))
return(false);
//--- set parameters of the indicatorMqlParam parameters[4];
//---
{
parameters[0].type=TYPE_STRING;
parameters[0].string_value="Include\\Detrended Price Oscillator.ex5";
parameters[1].type=TYPE_INT;
parameters[1].integer_value=m_ma_period;
}
//--- object initializationif(!m_ma.Create(m_symbol.Name(),m_period,m_ma_period,m_ma_shift,m_ma_method,m_ma_applied))
{
printf(__FUNCTION__+": error initializing object");
return(false);
}
//--- check pointerif(!m_mci.Create(m_symbol.Name(),0,IND_CUSTOM,4,parameters))
{
printf(__FUNCTION__+": error initializing object");
return(false);
}
//--- add object to collectionif(!indicators.Add(GetPointer(m_ma)))
return(false);
{
//--- number of buffersif(!m_mci.NumBuffers(4)) return(false);
//--- okreturn(true);
}
//+------------------------------------------------------------------+//| "Voting" that the price will grow. |//+------------------------------------------------------------------+int CSignalMyCustInd::LongCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed barif(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicatorif(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)>0.0 && DiffMA(idx)>0.0)
{
//--- the open price is above the indicator (i.e. there was an intersection), but the indicator is directed upwards
result=m_pattern_1;
//--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
else
{
//--- the close price is above the indicator (the indicator has no objections to buying)if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
//--- if the indicator is directed upwardsif(DiffMA(idx)>0.0)
{
if(DiffOpenMA(idx)<0.0)
{
//--- if the model 2 is usedif(IS_PATTERN_USAGE(2))
{
//--- the open price is below the indicator (i.e. there was an intersection)
result=m_pattern_2;
//--- suggest to enter the market at the "roll back"
m_base_price=m_symbol.NormalizePrice(MA(idx));
}
}
else
{
//--- if the model 3 is used and the open price is above the indicatorif(IS_PATTERN_USAGE(3) && DiffLowMA(idx)<0.0)
{
//--- the low price is below the indicator
result=m_pattern_3;
//--- consider that this is a formed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
}
}
//--- return the resultreturn(result);
}
//+------------------------------------------------------------------+//| "Voting" that price will fall. |//+------------------------------------------------------------------+int CSignalMyCustInd::LongCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed barif(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicatorif(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)<0.0 && DiffMA(idx)<0.0)
{
//--- the open price is below the indicator (i.e. there was an intersection), but the indicator is directed downwards
result=m_pattern_1;
//--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
else
{
//--- the close price is below the indicator (the indicator has no objections to buying)if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
//--- the indicator is directed downwardsif(DiffMA(idx)<0.0)
{
if(DiffOpenMA(idx)>0.0)
{
//--- if the model 2 is usedif(IS_PATTERN_USAGE(2))
{
//--- the open price is above the indicator (i.e. there was an intersection)
result=m_pattern_2;
//--- suggest to enter the market at the "roll back"
m_base_price=m_symbol.NormalizePrice(MA(idx));
}
}
else
{
//--- if the model 3 is used and the open price is below the indicatorif(IS_PATTERN_USAGE(3) && DiffHighMA(idx)>0.0)
{
//--- the high price is above the indicator
result=m_pattern_3;
//--- consider that this is a formed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
}
}
//--- return the resultreturn(result);
}
//+------------------------------------------------------------------+
Ali Mirzabagherian #: thanks for your response, sir. You know, I want to add the DPO oscillator to my EA. So, I have to convert the ex5 (mql) to mqh(custom indi). please guide me in more detail, if it is possible.
Why are you going to so much trouble? Just use the indicator via the iCustom() call, and if you want to embed the indicator inside the final ".ex5" file, then just declare it as a resource.
Code Error generated by the coded copied into MQL4 editor are as follows..;' - unexpected end of program & unbalanced parentheses - Kindly see assist in fixing this errors - See detail source code below:
<Incorrectly posted code deleted>
Please read the topic. Your problem has probably already been addressed.
See Fernando's post just a few above yours?
https://www.mql5.com/en/forum/291541/page3#comment_44043800
If you had read his post, you would know how to post code correctly!
Code was generated by ChatGPT
',' - unexpected end of program 72 83
'{' - unbalanced parentheses 66 1
can anyone tell me where is the error??
',' - unexpected end of program 72 83
'{' - unbalanced parentheses 66 1
can anyone tell me where is the error??
Code was generated by ChatGPT
can anyone tell me where is the error??
Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum (2023)
...
...
PLEASE i need help on unexpected end of programm and (for) expression are not allowed on a global scope. please how do i fixed this error
If your code was generated by ChatGPT, then we cannot help you! Learn to code or hire someone human to code it for you.
Hi every one,
I am neew to coding and I decided to convert an indicator to a mqh file. I did about 98 percent but the error of '}' - unexpected end of program MySignal.mqh 302 3 was created.
Although, I try so many times to balance it and so on ... but the error is not fixed.
please help me out to sole this issue .
thanks in
That is nonsense. You still have to include it into MQL4 file, so you still have an indicator. Right back where you started.
That is nonsense. You still have to include it into MQL4 file, so you still have an indicator. Right back where you started.
thanks for your response, sir. You know, I want to add the DPO oscillator to my EA. So, I have to convert the ex5 (mql) to mqh(custom indi).
please guide me in more detail, if it is possible.
thanks
Why are you going to so much trouble? Just use the indicator via the iCustom() call, and if you want to embed the indicator inside the final ".ex5" file, then just declare it as a resource.