General EA problems

Your basic questions about running EA's
imamushroom
Posts: 6
Joined: Fri Oct 30, 2015 9:48 pm

General EA problems

Post by imamushroom »

Hello,

Thank you so much for letting this forum. It seems like it is full of knowledgeable and experienced trader/programmers and I’m so glad I found you all.

For a year and a half now my brother in law and I have been on our own battling with all the usual problems like how to detect acutely flat and trending markets etc. only to find that many that these problems have been already solved, here!!

Whilst, our ideas closely emulate techniques being used here, they weren’t as elegantly presented.

However, there are a few things which I’d like further ideas on how to resolve. Hopefully, someone can point me in the right direction or give me some alternative ideas.

These are the things we’ve been struggling with; some are really problems other as due to me losing confidence in my mathematics capability:
  • * Indicator bounce, how to eliminate this among with their false positives?

    * How to calculate the angle between a fast and slow moving average? We’ve been using simple moving averages but I see people favour TMAs as they are smoother.

    * For the same reason people seem to prefer a TMA over a simple ma (as previously mentioned as it is smoothed), is there an indicator where the Bollinger bands are smoothed? One of our problems is detecting the slope of the Bollinger bands that vary too much in order to define their tendency. If not, what would the formula be for me to create one?

    * How to calculate the slope of the moving averages in such a way that It is consistent and we can define various static levels for different stages of trend evolution therefore being able apply different position exit strategies and adding to positions.

    * How to calculate the angle of interception between a projected fast moving average and a projected upper or lower Bollinger band (smoothed)? Projections being based on averages of previous x values from the start of the movement (slope change of fast moving average from negative to positive for a buy position).
Thanks in advance for your advice.

imamushroom
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

General EA problems

Post by jjasper7 »

i have an ea, compiled and downloaded to my chart, but it does not seem to start and run. i have a smiley face and green autotrading button. what do i need to do to get it to run? i inserted an alert("init") as the first command, and do not see a nrintout of it. where will it apear?
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

General EA problems

Post by renexxxx »

Show us the code, Jasper. Without this we can keep on guessing forever about what is going on.

Rene,
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

General EA problems

Post by jjasper7 »

the program - raw

Code: Select all

// ============================================================
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
//int OnInit()
  {
//---
   Alert("Init");
   
      //  find pivot points and draw s/r lines
      i=0;upi=0;dni=0;
      for(n=500;n>2;n++)
         {  // find past pivot points
           
           PivotUp(upi)=FindPivotUp(n);  pui(upi);  PvtUT(upi++)=Time(n);
           PivotDn(dni)=FindPivotDn(n);  pdi(dni);  PvtDT(dni++)=Time(n);
         }
      
 
   return(INIT_SUCCEEDED);
  }
You do not have the required permissions to view the files attached to this post.
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

General EA problems

Post by jjasper7 »

the previous post contains a snippit of code from the program 'demo.mq4' (attachment) which i thought i compiled and had the non-start problem i was asking about. the snippit was to show the problem i was not understanding, but please check the demo.mq4 because it is not compiling now and gives no error alerts.
thanks for looking.
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

General EA problems

Post by renexxxx »

Jasper, I don't know where to start with the feedback on your demo.mq4. The "program" is a real dog's breakfast. There seem to be three sets of EAs concatenated in the code. The first one doesn't do anything(as the OnTick() function is empty) and the second and third are looking very similar copies of each other (taken from tradingexpert.mq4).

You need to start with an understanding of the program structure of an EA: There must be a:

Code: Select all

int OnInit() {

   // Do some initializations here.
   // This block is executed only once: when the EA is loaded.
   // Be aware that if you change a parameter of the EA, the EA is first unloaded and then reloaded.
   return(INIT_SUCCEEDED);
}
And there must be a:

Code: Select all

int OnTick() {

   // This function is executed each time a new tick is received.
   // A tick a price update of the currency pair onto which the EA is loaded.
   // Ticks arrive at variable time intervals: Sometimes there are 5 ticks in a second, and other times
   // there is no tick for 30 seconds. In the weekends there are of course no ticks either.
   
   // Do some logic here, eventually resulting in the BUYing or SELLing of currency pairs.
}
You can optionally have a:

Code: Select all

void OnDeinit(const int reason) {

   // This is run when the EA is unloaded.
   // This is where you clean up (delete) screen objects
   // and free (deallocate) dynamically allocated memory.
}
and a:

Code: Select all

void OnChartEvent(const int id, const long &lparam,const double &dparam,const string &sparam) {

   //This is where you handle screen and custom events   
}
See also the documentation on this.

You can't post a bunch of code as in demo.mq4, and expect anyone to produce a working program out of it. It is too far from anything that remotely resembles an EA. This is the same as getting some parts at the car wreckers and asking someone to build a ferrari out of it.

Good Luck!
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

General EA problems

Post by jjasper7 »

rene, many thanks, your comments are much appreciated. i did not find the documentation i should have read. i was adapting a sample i found, and have not been coding for 4 years (before Empty4 was given the on... functions and wasn't sure if the old format would still work, but assumed it would because they would probably want old programs (built before the change) to keep running. i'll look again for the description of the sections as you defined, and rearrange the code. thanks again, jim
andwen
Trader
Posts: 62
Joined: Tue Jun 03, 2014 4:07 am
Location: Melbourne, Aust

General EA problems

Post by andwen »

Cannot set timer.

I often make changes to the awesome VER 1R EA. However as a consequence the EA fails to initialise and spits back at me :-

2018.04.10 21:30:55.216 Awesome ver 1R EURNOK,Daily: cannot set timer (15)

EURNOK is just the currency chart i am using for the EA.

I have reset the timer to all different values without success and cannot find a ref on the SHF forum explaining what it means. Advice really welcomed as it has been happening for a long time..and is stopping me from making alterations to the EA. Often have to remove the EA and start again. Is this normal behaviour??

Cheers
User avatar
tomele
Administrator
Posts: 1208
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

General EA problems

Post by tomele »

Hi.

There can be only one timer per expert. Normally you set it in OnInit() and kill it in OnDeinit(). Inbetween, the OnTimer() reacts on the timing events. You are not supposed to repeatedly call EventSetTimer().

Cheers
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
andwen
Trader
Posts: 62
Joined: Tue Jun 03, 2014 4:07 am
Location: Melbourne, Aust

General EA problems

Post by andwen »

Hi Thomas.

Not being a programmer I struggle with the logic. Thats why i am here.

I have only reset timer to different values hoping it may solve the problem. I have no interest in it but it must be part of the core logic.....There is only one EA on chart.

If I remove EA from chart then reload EA it throws that error and wont initialise :arrrg: :arrrg:

Just curious as to how i fix it so the EA can load.

Cheers
Post Reply

Return to “Automated trading (Rookies)”