Placing more than one trade per Bar

To add comments, please log in or register
SirFency
173
SirFency  

I built this EA and I thought I put in the code to only make one trade per bar but it dont seem to be working. Sometimes it places more than one trade per bar. Could someone please help me figure out why? I'm checking with datetime and storing it in time.

Files:
Konstantin Nikitin
8339
Konstantin Nikitin  
Check. I did not look at all the code. Check in OnTick
Files:
whroeder1
17943
whroeder1  
SirFency: I built this EA and I thought I put in the code to only make one trade per bar but it dont seem to be working. Sometimes it places more than one trade per bar. Could someone please help me figure out why? I'm checking with datetime and storing it in time.
  1. In CheckForSignal, you have new bar code around your (many) tests. Each test could call EnterTrade. Thus your problem. After each EnterTrade add a return so you don't open more.

  2. You also have a bogus recursive call in CheckForSignal
          //Enters a buy trade if the conditions are met
          if(perGBP > perEUR && GbpEurDiff > gap && previousK < previousD && currentK > currentD && currentD < 20)
            {
            CheckForSignal();
            EnterTrade(OP_BUY);
            }
    

  3. Your code
       double GbpEurDiff = perGBP - perEUR;  //Check to see if the difference is below zero
          if(GbpEurDiff < 0)
          {     
          GbpEurDiff = -GbpEurDiff; //if its below zero invert the negative to positive 
          }
    
    Simplified
       double GbpEurDiff = MathAbs(perGBP - perEUR);  //Check to see if the difference is below zero
    


SirFency
173
SirFency  
whroeder1:
  1. In CheckForSignal, you have new bar code around your (many) tests. Each test could call EnterTrade. Thus your problem. After each EnterTrade add a return so you don't open more.

  2. You also have a bogus recursive call in CheckForSignal

  3. Your code
    Simplified


Thank you whroeder1. Would I just return zero? return(0);

To add comments, please log in or register