Help - 1 trade per bar

 

Friends, hello.

 

I wish someone could help me.

I create the expert advisor in the file below.

But I would like the expert advisor to execute only one order per bar.

Can anyone help me with the code and where in the expert advisor I put these codes? 

Files:
 

... 

static datetime tlastbar=0;

datetime tnewbar=iTime(NULL,PERIOD_CURRENT,0);

bool isnewbar=tnewbar!=tlastbar;

tlastbar=tnewbar; 

if (!newbar)

   return;

 
@Doerk: Your heart is obviously in the right place, but unfortunately I don't think the OP is going to be able to use your code because he is using a Code Generator. He does not seem to know how to code in MQL4 at all, so I guess he will just have to follow one of those 3 options that WHRoeder usually lists (ie. To either Learn It, Search for It or Hire someone to Code it for him).
 
FMIC:
@Doerk: Your heart is obviously in the right place, but unfortunately I don't think the OP is going to be able to use your code because he is using a Code Generator. He does not seem to know how to code in MQL4 at all, so I guess he will just have to follow one of those 3 options that WHRoeder usually lists (ie. To either Learn It, Search for It or Hire someone to Code it for him).
Didnt recognize the code builder immediately. It was just copy and paste during a cup of coffee during a break on the terrace :) But I agree totally with the opinion about code generators. 
 
  • We hate EA builder
  • You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
  • There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
  • EA builder makes bad code counting up while closing multiple orders.
  • EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
  • EA builder makes bad code Not adjusting for 4/5 digit brokers
  • EA builder makes bad code not adjusting for ECN brokers.
  • EA builder makes bad code not checking return codes.
  • EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/reboot.)
Reason: