This code does not compile correctly any more. Complied with the December 2018 build, but not on any build after.
'RegressionCalc' - unexpected token, probably type is missing? Regression.mqh 48 13
'RegressionCalc' - function already defined and has different type Regression.mqh 48 13
Suggestions?
//+------------------------------------------------------------------+ //| Regression.mqh | //| Copyright © 2011, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ class Regression { private: double LeftMost; double RightMost; double Slope; int StartBar; double TestValue; public: //Regression(double &population[],int _start,double _testvalue); Regression(); ~Regression(); void Recalculate(); void RegressionCalc(double &population[],int _start, int _end); double GetLeftMost(){return LeftMost;} double GetRightMost(){return RightMost;} bool SlopePositive(){return (LeftMost < RightMost);} bool SlopeNegative(){return (LeftMost > RightMost);} double GetSlope(){return Slope;} }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ Regression::~Regression() { } //+------------------------------------------------------------------+ Regression::Regression() { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ Regression::RegressionCalc(double &population[],int _start, int _end) { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //int RegressionLine() //LinearSingle(_start,0,PRICE_CLOSE); //Print("L:",left," ",GBL_RegressionLeft," R:",right," ",GBL_RegressionRight); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //double LinearSingle(int __startbar,int __endbar,int __price) //--- // MqlRates rates[]; // ArraySetAsSeries(rates,true); // int copied=CopyRates(NULL,0,0,12,rates); double x[1000] = {0}; double y[1000] = {0}; // ArraySetAsSeries(population,true); ArraySetAsSeries(x,true); ArraySetAsSeries(y,true); int __endbar=0; double SUMxy; double SUM_x2; double SUMx; double SUMy; double a; double b; int n; // double Sxy; // double Sxx; // // double Xbar; // double Ybar; int i; SUMx=0; SUMy=0; // int copied=CopyRates(NULL,0,0,__startbar+1,rates); n=_start-_end+1; // Print(n," ",__startbar," ",__endbar); for(i=0; i<n; i++) { // Print(i," ",i-EndBar," "); x[i]=i; //StartBar-EndBar; //Print(i," ",x[i]); } // for(i=0;i<n;i++) // Print(i, " ", x[i]); // return; for(i=0; i<n; i++) { // y[i]=rates[__startbar-i].close; // y[i]=COGPrice(__price,_start-i); //rates[__startbar-i].close; y[i]=population[_start-i]; // Print(i," ",y[i]); } // for(i=0;i<n;i++) // PrintFormat("i=%g, x=%g, y=%g",i,x[i],y[i]); // return; SUMxy=0; SUM_x2=0; for(i=0; i<n; i++) { SUMx+=x[i]; SUMy+=y[i]; SUMxy+=x[i]*y[i]; SUM_x2+=x[i]*x[i]; } // Sxy = SUMxy - ((SUMx*SUMy)/n); // Sxx = SUM_x2 -((SUMx*SUMx)/n); // // Xbar = SUMx/n; // Ybar = SUMy/n; // // b=Sxy/Sxx; // a=Ybar-b*Xbar; a=((SUMy)*(SUM_x2)-(SUMx)*(SUMxy)) / ((n)*(SUM_x2)-(SUMx*SUMx)); b=((n)*(SUMxy)-(SUMx)*(SUMy)) / ((n)*(SUM_x2)-(SUMx*SUMx)); // Print("Intercept: ",a," Slope: ",b); for(i=0;i<n;i++) { // if(i==0 || i==n-1) //PrintFormat("%d, x=%.2f, y=%.2f, Ny=%.2f",i,x[i],y[i],b*x[i]+a); } // ObjectSetInteger(0,"PGMRG",OBJPROP_TIME,0,rates[__startbar].time); // ObjectSetInteger(0,"PGMRG",OBJPROP_TIME,1,rates[__endbar].time); // ChartRedraw(); // PrintFormat("RGC L: %g R: %g",ObjectGetValueByTime(0,"PGMRG",rates[__startbar].time,0),ObjectGetValueByTime(0,"PGMRG",rates[__endbar].time,0)); // PrintFormat("RGH L: %g R: %g",ObjectGetValueByTime(0,"PGMRG",rates[11].time,1),ObjectGetValueByTime(0,"PGMRG",rates[0].time,1)); // PrintFormat("RGL L: %g R: %g",ObjectGetValueByTime(0,"PGMRG",rates[11].time,2),ObjectGetValueByTime(0,"PGMRG",rates[0].time,2)); // Print(" "); LeftMost=(1)*b*x[0]+a; RightMost=(1)*b*x[n-1]+a; Slope=b; // rrv.slope=b; // rrv.pricestart=(1)*b*x[0]+a; // rrv.priceend=(1)*b*x[n-1]+a; //weird, but we have to reverse the start/end here - just accept it // rrv.datestart=rates[__startbar].time; // rrv.dateend=rates[__endbar].time; return; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double COGPrice(int __price,int __bar) { if(__price==PRICE_CLOSE) { return(Close[__bar]); } if(__price==PRICE_OPEN) { return(Open[__bar]); } if(__price==PRICE_HIGH) { return(High[__bar]); } if(__price==PRICE_LOW) { return(Low[__bar]); } return(Close[__bar]); } //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| RegressionSignal.mqh | //+------------------------------------------------------------------+ #property link "https://enterboldly.com" #property version "1.00" #property strict #include <UserClass\Regression.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class RegressionSignal : public Regression { private: public: datetime last_time; bool TraceEnabled; RegressionSignal(); int Signal(int _left_bar); bool NewBar(); bool PlacePriceLine(int _chart,int _frombar,double _fromprice,int _tobar,double _toprice,int _color,int _left_bar); ~RegressionSignal(); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ RegressionSignal::RegressionSignal() { TraceEnabled=false; last_time=0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int RegressionSignal::Signal(int _left_bar) { int left_bar=_left_bar; //this is 10 x M15 int right_bar=1; double price_array_close[]; ArrayResize(price_array_close,left_bar+1,0); //assume we are sending from 100 to 0 therefore 101 //ArraySetAsSeries(price_array_close,true); if(NewBar()) { for(int i=0;i<=left_bar;i++) { price_array_close[i]=Close[i]; //Print(i,",",Close[i]); } RegressionCalc(price_array_close,left_bar,1); if (TraceEnabled) Print("left: ",left_bar," slope: ",GetSlope()," left: ",GetLeftMost()," right: ",GetRightMost() ); PlacePriceLine(0,left_bar,GetLeftMost(),1,GetRightMost(),Gray+left_bar*13,left_bar); } if(GetSlope()>0) return (1); if(GetSlope()<0) return (-1); return (0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool RegressionSignal::NewBar() /* add this to the front end still */ { if(Time[0]!=last_time) { last_time=Time[0]; return(true); } else { return(false); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool RegressionSignal::PlacePriceLine(int _chart,int _frombar,double _fromprice,int _tobar,double _toprice,int _color,int _left_bar) { string object_name="RegressionLineSignal-"+IntegerToString(_left_bar,4,'~'); ObjectDelete(object_name); ObjectCreate(0,object_name,OBJ_TREND,_chart,Time[_frombar],_fromprice,Time[_tobar],_toprice); ObjectSet(object_name,OBJPROP_RAY,false); ObjectSetInteger(0,object_name,OBJPROP_COLOR,_color); return true; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ RegressionSignal::~RegressionSignal() { } //+------------------------------------------------------------------+
This code does not compile correctly any more. Complied with the December 2018 build, but not on any build after.
'RegressionCalc' - unexpected token, probably type is missing? Regression.mqh 48 13
'RegressionCalc' - function already defined and has different type Regression.mqh 48 13
Suggestions?
thank you.
That must have change with a recent release, because I have been running that code for some time.
Will make the changes and carry on.
I'm using build 1220, and now the "//" comment can't use for showing the input :
input string S1 = ""; // --- Searah Trend --- input bool UseTrend = true; // Pakai OP Searah input double TrendGap1 = 20; // Jarak 1 dalam point (Searah) input double TrendLot1 = 0.15; // Lot 1 (Searah)
Also when using same variable outside the { }, it will show error when compile the code :
#property strict
You're right, I'm so stupid, I forgot this :)
Been there, done that...LOL
Did you see that the new version of Terminal.exe (MetaTrader 4 Client Terminal build 1220) gives the following windows errors:
Nom du journal :Application Source : SideBySide
Date : 17/09/2019 13:19:19 ID de l’événement :80
Catégorie de la tâche :Aucun Niveau : Erreur Mots clés : Classique Utilisateur : N/A
Description : La création du contexte d’activation a échoué pour « L:\Applis_Autonomes\Forex\AaaFx Réel\terminal.exe ».
Erreur dans le fichier de manifeste ou de stratégie « » à la ligne . Une version de composant nécessaire à l’application est en conflit avec une autre version de composant déjà active. Les composants en conflit sont :
Composant 1 : C:\Windows\WinSxS\manifests\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24483_none_e372d88f30fbb845.manifest.
Composant 2 : C:\Windows\WinSxS\manifests\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24483_none_2b200f664577e14b.manifest.
XML de l’événement : <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="SideBySide" /> <EventID Qualifiers="49409">80</EventID> <Level>2</Level> <Task>0</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2019-09-17T11:19:19.000000000Z" /> <EventRecordID>32468</EventRecordID> <Channel>Application</Channel> <Computer>W764-5</Computer> <Security /> </System> <EventData> <Data>C:\Windows\WinSxS\manifests\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24483_none_e372d88f30fbb845.manifest</Data> <Data>C:\Windows\WinSxS\manifests\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24483_none_2b200f664577e14b.manifest</Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data>L:\Applis_Autonomes\Forex\AaaFx Réel\terminal.exe</Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> <Data> </Data> </EventData> </Event>
these error messages did not occur with the previous version of terminal but my broker impose the new version!
Do you have a solution ? thank you
I saw on another forum an explanation of this error:
"This error is caused by a wrong manifest embedded in the FormDesigner application. If you open the application in Visual Studio and extract the manifest you will see two references to the common controls dll - one processor-agnostic (*) version and one version requiring x86. On a 64-bit machine processor-agnostic references will appearantly resolve to the 64-bit version. The error in the event log is legitimate since imports are already defined from whatever version was process first. To test just try removing the processor-agnostic reference from the manifest and resave the app in Visual Studio. When you rerun the app the errors are gone."
but it is impossible to modify terminal.exe !!!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The MetaTrader 4 platform update will be released on Friday, September 13, 2019. The new build features the following changes:
MetaTrader 4 Client Terminal build 1220
The update will be available through the LiveUpdate system.