# My new Universal EA, come check it out.

6272

I am an amateur coder and I am trying to make a good EA that is easy to use.

I'm trying to give back to the community since I have learned so much from this website and want to continue to learn.

Also I made some youtube tutorials on how to use them here

Patrick Cofflin,

p.a.cofflin@gmail.com

6272

Files:
Moderator
18027

pacofflin:

You should read these articles: What are Function return values ? How do I use them ? & Loops and Closing or Deleting Orders
6272

Thanks for the inputs Raptor, I am a new coder and learned from youtube videos and other EAs. My knowledge of loops is limited. I read your links and I learned some new things.

Is there some way I could make my loops better? Or maybe a more simple way to write the code?

You see I struggled a lot with the trade limiter because I tried using a time based loop and it just wouldn't work. My original code was this

```{for(int i = 0 ; i < OrdersTotal() ; i++ )
{if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break;

Where you could adjust the variable TradeTimer to however many seconds you wanted the trading window to be open.

I'm not sure why it wouldn't work so I switched it to a Stochastic based trade limiter which worked like a charm.

Thanks for the help.

6272

So I should change

`for(int i = 0 ; i < OrdersTotal() ; i++ )`

to

`for(int i = 0 ; i < OrdersTotal() - 1 ; i++ ) `
6272

No it should be

`for(int i =OrdersTotal() - 1 ; i >=0 ; i++ ) `
6384

pacofflin:
So I should change for(int i = 0 ; i < OrdersTotal() ; i++ ) to for(int i = 0 ; i < OrdersTotal() - 1 ; i++ ) ?

looking is not enough read it for(int i = 0 ; i < OrdersTotal() - 1 ; i++ ) is not correct

also select right Symbol() and right MagicNumber

also why do you need every tick so many loops checking your trades

6272

Is
`for(int i =OrdersTotal() - 1 ; i >=0 ; i++ )`

or

`for(int i =OrdersTotal() - 1 ; i >=0 ; i--)`

better for closing a loop?

15925

pacofflin: No it should be for(int i =OrdersTotal() - 1 ; i >=0 ; i++ )
 Play video Please edit your post. For large amounts of code, attach it.
6272

Well deVries I did read it but I'm still trying to figure out where I messed up at.

My loops contain bool functions so each one has a different function and can be turned on and off using true or false values.

I wanted to add many different functions to give people the option to choose how they wanted to close their trades so that they could customize the EA to their own trading strategy. I created an EA that has many different variables and inputs so that anyone could adjust the numbers. The EA is a template for any system that you can think of that uses the indicators provided. I am trying to make it better so that people who use it don't have to mess with the code at all.

6272

WHRoeder: