Help adding MaxTradesPerBar to EA

 

I have no clue how to add an external variable or a hardcode to this EA that sets MaxTradesPerBar to 1. Since there is no MaxTradesPerBar setting in the code, when I test with every tick, I get tons of trades and orders on each bar that I don't want. I've read suggestions online but I don't know where to paste everything into the code (I'm new at coding). Your help is much appreciated!

https://www.mql5.com/en/code/8629

 
megamixx:

I have no clue how to add an external variable or a hardcode to this EA that sets MaxTradesPerBar to 1.

but I don't know where to paste everything into the code (I'm new at coding).

  1. Since there are no slaves here, there are only two choices: learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
  2. Scan the current open trades, find the latest one. Test if it was opened before or after the start of the current bar. If you need help with this, post your code attempt.
 

And I would recommend you learn how to code. I paid for some programming and immediately after testing the new program I want to make changes. That's how I got started. I could see that programming was going to drain my account faster than making a bunch of bad trades. If you are completely new to the whole idea of programming in MT4. Start by figuring out where to save the different file types: expert advisor, script, custom indicator. Find the terminal window (Ctrl+T) and the expert tab. Once you have all that figured out try your hand at writing a few lines of code. See if you can get this to do what you expect it to do -- no surprises.

int start()
  {
   int something = 99;
   Print (something);
   return(0);
  }

Remember the Print function is your friend! You can use it for debugging programs and to figure out what a function is really doing.

-- enjoy

 
WHRoeder:
  1. Since there are no slaves here, there are only two choices: learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
  2. Scan the current open trades, find the latest one. Test if it was opened before or after the start of the current bar. If you need help with this, post your code attempt.

Wow, that's pretty rude, I'd be happy to pay if it was building a code from scratch or performing a huge undertaking but this is inserting a couple lines into the right places. It would be something I'd be glad to do for someone if I knew code and much less than other help I've seen on this site. No worries though WH, I'll figure it out somehow. Hope you never need someone's help and they tell you to learn how to fix your own car, plumbing, electrical, etc.
 
megamixx: Wow, that's pretty rude,

Yes I consider it very rude that every day, one or usually more people ask 'code this for me' The world doesn't work that way.

If what you were asking for was "a couple of lines into the right places" then why couldn't you spend the effort to try to do it. You are just lazy and want things done FOR you.

Now had you tried and posted some code, then you would have gotten some help.

As it is I did help, I posted #2 what needed to be done. All you had to so was code it. Instead you became irate that you didn't get your way.

 
megamixx:

I'd be happy to pay if it was building a code from scratch or performing a huge undertaking but this is inserting a couple lines into the right places
I really hope u pay @ the grocery for thing u buy there, because, they r not the manufacturers of the products, and they have not built anything from scratch, according to what u r writing here, who hasn't built anything from scratch, you're not willing to pay him
 
qjol:
I really hope u pay @ the grocery for thing u buy there, because, they r not the manufacturers of the products, and they have not built anything from scratch, according to what u r writing here, who hasn't built anything from scratch, you're not willing to pay him

I'm sorry, I thought this was a site for help. I HAVE been trying to work in the code for a few days with no avail. I didn't realize the help on this site was mainly pay-only. Since the code is already in place, I thought inserting a few lines wouldn't evoke money hungry greediness or arrogance of being a programmer. I hope you both aren't treated the same next time you need help!
 
megamixx:

I'm sorry, I thought this was a site for help. I HAVE been trying to work in the code for a few days with no avail. I didn't realize the help on this site was mainly pay-only. Since the code is already in place, I thought inserting a few lines wouldn't evoke money hungry greediness or arrogance of being a programmer. I hope you both aren't treated the same next time you need help!

Most here are NOT programmers . . and nobody has asked you for money . . . you aren't asking for help to enable you to write code . . you are asking for someone to write the code for you. If you need that I suggest you go here: Jobs for MT4 & MT5 there are plenty of people that will write your code for you so you don't need to even try . . .

If you really have been trying to code this yourself why don't you show what you have tried so far . . . and explain in what way it isn't working.

 
RaptorUK:

Most here are NOT programmers . . and nobody has asked you for money . . . you aren't asking for help to enable you to write code . . you are asking for someone to write the code for you. If you need that I suggest you go here: Jobs for MT4 & MT5 there are plenty of people that will write your code for you so you don't need to even try . . .

If you really have been trying to code this yourself why don't you show what you have tried so far . . . and explain in what way it isn't working.


I honestly don't have the nerve to re-create my 20 or so attempts at inserting the code that all led to disaster. I thought I'd save everyone on the board a huge headache and spare my botched details. Just figured some brain out there could paste in the MaxTradesPerBar option into the existing program in a couple seconds and be done with it instead of dragging it out over post after post. Didn't realize my request was as big as it seems now. Thanks for your help though. Have a blessed day.
 
megamixx:

I honestly don't have the nerve to re-create my 20 or so attempts at inserting the code that all led to disaster. I thought I'd save everyone on the board a huge headache and spare my botched details. Just figured some brain out there could paste in the MaxTradesPerBar option into the existing program in a couple seconds and be done with it instead of dragging it out over post after post. Didn't realize my request was as big as it seems now. Thanks for your help though. Have a blessed day.

You are still missing the point. Had you posted some type of attempt, you would have gotten the answer. Your request is about 5 lines of code. Not big at all.

Instead you keep bitch'n. You had several people state the same thing. Still you didn't post any code. So now I put you in the troll catagory.

Please do not feed the troll.

When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.

 

megamixx,

If you are still out there, I can suggest a few code changes that will do what you're looking for. Let me know if you are still interested.

extern int SlowMA_AppliedPrice=0;     // 0=close, 1=open, 2=high, 3=low, 4=median((h+l/2)), 5=typical((h+l+c)/3), 6=weighted((h+l+c+c)/4)
extern double BreakOutLevel=45;       // Start trade after breakout is reached
extern int SignalCandle=1;
extern int MaxTradesPerCandle = 1;      // limit orders to one trade per candle <<== add this line after this line ^
Then recompile to make sure it is without error. Let me know when you have this and I'll paste the next change.
Reason: