Reply

How to add a time test when main variable is triggered

1 replies

westie01

Subscriber, bbp_participant, community, 1 replies.

Visit profile

10 years ago #111794

Apologies for the basic nature of this question

 

I have a trigger test that is linked to oversold/overbought stochastic.  I want to add a second test such that before entering a trade the EA checks to ensure that trade has not been opened in the last 3 hours.

 

My best guess of how to do this is:

 

Bars since order open > 3  

 

Any help appreciated

0

jimasks

Customer, bbp_participant, community, 45 replies.

Visit profile

10 years ago #123180

I think that is correct. The function does return the number of bars since a trade with magic number and on the current chart was last opened. 

 

If one is on an hourly chart then, it will return the number of hours. If one is not on an hourly chart one could try the function as in the attached file.

 

It uses the custom function to find out the current chart period. [Period()] The current chart period will be returned in minutes. So if one does a comparison it should be in minutes as well. For 3 hours that would be 3*60 = 180. 

 

 

So, the total thing would read something like;

(BarsSinceOrderOpen(MagicNumber) *Period() > 180)

 

Just as an example of the compound condition, I also included a comparison when the Stochs crosses below 80. 

 

I hope this helps.

 

0

Viewing 1 replies (of 1 total)