News filter doesnt work....

To add comments, please log in or register
QuantCoder
127
QuantCoder  
I am trying to implement https://www.mql5.com/en/code/16308


So in my first function I do this,

void firstfunction{
int switch_action=99;

   if(compArray[0]=="buy")
      switch_action= 1;
   if(compArray[0] == "sell")
      switch_action= 0;
   if(compArray[0] == "close")
      switch_action= 4;
   if(compArray[0] == "data666")
      switch_action= 3;
double CheckNews=0;
   if(AfterNewsStop>0)
     {
      if(TimeCurrent()-LastUpd>=Upd){Comment("News Loading...");Print("News Loading...");UpdateNews();LastUpd=TimeCurrent();Comment("");}
      WindowRedraw();
      //---Draw a line on the chart news--------------------------------------------
      if(DrawLines)
        {
         for(int i=0;i<NomNews;i++)
           {
            string Name=StringSubstr(TimeToStr(TimeNewsFunck(i),TIME_MINUTES)+"_"+NewsArr[1][i]+"_"+NewsArr[3][i],0,63);
            if(NewsArr[3][i]!="")if(ObjectFind(Name)==0)continue;
            if(StringFind(str1,NewsArr[1][i])<0)continue;
            if(TimeNewsFunck(i)<TimeCurrent() && Next)continue;

            color clrf = clrNONE;
            if(Vhigh && StringFind(NewsArr[2][i],"High")>=0)clrf=highc;
            if(Vmedium && StringFind(NewsArr[2][i],"Moderate")>=0)clrf=mediumc;
            if(Vlow && StringFind(NewsArr[2][i],"Low")>=0)clrf=lowc;

            if(clrf==clrNONE)continue;

            if(NewsArr[3][i]!="")
              {
               ObjectCreate(Name,0,OBJ_VLINE,TimeNewsFunck(i),0);
               ObjectSet(Name,OBJPROP_COLOR,clrf);
               ObjectSet(Name,OBJPROP_STYLE,Style);
               ObjectSetInteger(0,Name,OBJPROP_BACK,true);
              }
           }
        }
      //---------------event Processing------------------------------------
      int i;
      CheckNews=0;
      for(i=0;i<NomNews;i++)
        {
         int power=0;
         if(Vhigh && StringFind(NewsArr[2][i],"High")>=0)power=1;
         if(Vmedium && StringFind(NewsArr[2][i],"Moderate")>=0)power=2;
         if(Vlow && StringFind(NewsArr[2][i],"Low")>=0)power=3;
         if(power==0)continue;
         if(TimeCurrent()+MinBefore*60>TimeNewsFunck(i) && TimeCurrent()-MinAfter*60<TimeNewsFunck(i) && StringFind(str1,NewsArr[1][i])>=0)
           {
            CheckNews=1;
            break;
           }
         else CheckNews=0;

        }
      if(CheckNews==1 && i!=Now && Signal) { Alert("In ",(int)(TimeNewsFunck(i)-TimeCurrent())/60," minutes released news ",NewsArr[1][i],"_",NewsArr[3][i]);Now=i;}
/***  ***/
     }


CHECKTRADE=second_function(switch_action, CheckNews);

}

In my second function I try to return a true value using,

int second_function(int &switch_action, double &CheckNews) 

{

if(NUMOPENTRADES==0 && PLACETRADE==FALSE && switch_action==1 && CheckNews==0) 
        {


            PLACETRADE=TRUE;



         
        }

But for whatever reason it never returns TRUE in the second function if I have CheckNews==0


What am I missing?


Or maybe somebody can suggest me a better news filter I can code in?

News EA Template without DLL
News EA Template without DLL
  • www.mql5.com
In essence, this is source code (template) of the Expert Advisor that downloads news from the investing.com, written in the MQL4 without the use of DLL. If you were looking for a way to do this in your product for the Market (use of DLL is not allowed there), then this is what you need. Now anyone can implement the feature of working according...
nicholi shen
2392
nicholi shen  
QuantCoder:
I am trying to implement https://www.mql5.com/en/code/16308


So in my first function I do this,


In my second function I try to return a true value using,

But for whatever reason it never returns TRUE in the second function if I have CheckNews==0


What am I missing?


Or maybe somebody can suggest me a better news filter I can code in?

https://bitbucket.org/nicholishen/mql4-ffevents/src/master/

README
  • bitbucket.org
This is a working demo of the FFEvents library. In order to test this in your MT4 terminal you will need to clone this entire repo into a subfolder in the ../MQL4/Scripts folder and compile with metaeditor. What is this repository for? How do I get set up? Clone repo to a subfolder in the ../MQL4/Scripts folder. Compile FFEvents_example...
QuantCoder
127
QuantCoder  
nicholi shen:

https://bitbucket.org/nicholishen/mql4-ffevents/src/master/

Sorry but I don't like the way you did your code. It makes it difficult to understand but feel free to share an implementation of your library with my code if you think you can improve my understanding :)

Flavio Jarabeck
76358
Flavio Jarabeck  
QuantCoder:

Sorry but I don't like the way you did your code. It makes it difficult to understand but feel free to share an implementation of your library with my code if you think you can improve my understanding :)

What about paying for some consultancy if you don't know how to do things in MQL?

Or at least have the decency and humility of accepting what is given to you for free...

Fernando Carreiro
4986
Fernando Carreiro  
QuantCoder:Sorry but I don't like the way you did your code. It makes it difficult to understand but feel free to share an implementation of your library with my code if you think you can improve my understanding :)

I guess we could say even worse of your code - it is sloppy, stringy, disorganised and extremely difficult to read or understand.

@nicholi shen may overemphasize the use of OOP, but his code is clean, well thought-out, logical and easy to read and understand.

Not only did you insult his code but you then had the gall to invite him to code your stuff for you for free?

Keith Watford
Moderator
20585
Keith Watford  
QuantCoder:

Sorry but I don't like the way you did your code. It makes it difficult to understand but feel free to share an implementation of your library with my code if you think you can improve my understanding :)

Your reply is unwarranted and ungrateful when somebody has tried to help you.

It is nobody else's fault that you cannot understand the code.

The replies to your post are, on the other hand warranted. 

I have deleted your last two posts as they are petulant and insulting.

Please be more humble when people are trying to help you.

nicholi shen
2392
nicholi shen  
Fernando Carreiro:

I guess we could say even worse of your code - it is sloppy, stringy, disorganised and extremely difficult to read or understand.

@nicholi shen may overemphasize the use of OOP, but his code is clean, well thought-out, logical and easy to read and understand.

Not only did you insult his code but you then had the gall to invite him to code your stuff for you for free?

Thanks Fernando, I appreciate the kind words. The emphasis on OOP comes from my background in python. I like to be able to make extremely complex and encapsulated programs with extremely simple interfaces, and it's just not possible to do that using the old C programming paradigm. It boils down to preference, and I prefer high-level interfaces, while others prefer low-level. So I think it's unfair to classify my style as "overemphasize the use of OOP" because that is a purely subjective opinion based on one's own preference. 

Fernando Carreiro
4986
Fernando Carreiro  
nicholi shen: Thanks Fernando, I appreciate the kind words. The emphasis on OOP comes from my background in python. I like to be able to make extremely complex and encapsulated programs with extremely simple interfaces, and it's just not possible to do that using the old C programming paradigm. It boils down to preference, and I prefer high-level interfaces, while others prefer low-level. So I think it's unfair to classify my style as "overemphasize the use of OOP" because that is a purely subjective opinion based on one's own preference. 

You are welcome, but classifying your code as overemphasized was not a criticism. It was neither "unfair" nor "fair", neither "bad" nor "good" - it was simply an observation, given that most MQL coders, especially newcomers, have a preference and an easier understanding of procedural coding.

To add comments, please log in or register