Download MetaTrader 5
To add comments, please log in or register
Use MQL5 Cloud Network. It is secure!
Connor Fitz
15
Connor Fitz 2015.09.17 03:54 

Hello, this is my first post on this forum.

I have been having an issue with getting only 1 trade per bar happening, i searched the forums and used similar code to what others suggested but it still places many bars on certain spots. Can anyone explain why this is occurring and how to fix it?

My code: 

     if(lastBar < Bars){
        canTrade = true;
        lastBar = Bars;
      }

What happens


Keith Watford
Moderator
7979
Keith Watford 2015.09.17 04:13  

It is generally accepted that Time[0] is better to detect new bars.

 

Do you set cantrade to false anywhere in your code?

Do you check cantrade before opening trades? 

Connor Fitz
15
Connor Fitz 2015.09.17 04:16  
canTrade is checked before trades are placed and it is changed to false after a trade, ill modify my code to see if Time[0] will have a better effect
Connor Fitz
15
Connor Fitz 2015.09.17 04:18  
i believe i found the problem. Thanks for your help!
/
To add comments, please log in or register