Issue placing 1 trade per bar

Back to topics list To post a new topic, please log in or register
avatar
5
ligert123 2015.09.17 05: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


avatar
Moderator
3405
GumRai 2015.09.17 06: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? 

avatar
5
ligert123 2015.09.17 06: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
avatar
5
ligert123 2015.09.17 06:18 #
 
i believe i found the problem. Thanks for your help!
Back to topics list  

To add comments, please log in or register