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.
- 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.
- 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); }
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
whroeder1:
- 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.
- You also have a bogus recursive call in CheckForSignal
Your code Simplified
Thank you whroeder1. Would I just return zero? return(0);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.