# Only One Trade per Day

When it comes to coding your trading systems, allowing only one trade per day is by far the most frequent request.

In the example above, the session starts at 8:00 local time (see cursor) and the trading system produces three long trades during the day. In order to discard trades two and three, it is possible to use a very simple trick. When the system wants to trade, we count the number of bars to the last exit of this trade. In case of the second trade, there are ten bars to the last exit. The code would be:

`BarsSinceExit(@,0,All,ThisTradeOnly)`

Secondly, we count the bars since the start of the day:

`BarsSince( BarIx(@,StartOfDay)=0,1,999)`

If the number of bars since exit is greater than the number of bars since the start of the day, it has obviously not traded today.

`BarsSinceExit(@,0,All,ThisTradeOnly) > BarsSince( BarIx(@,StartOfDay)=0,1,400)`

If we were to use the above code directly in our trading signal, we would run into one little glitch. On the trading system's first ever trade, it cannot count the bars since the last exit because there is no trade before the first trade and the code would return a "none" value. Therefore, the condition will never result in "true." To prevent this problem, we can use a second little trick:

`IF(BarsSinceExit(@,0,All,ThisTradeOnly) > 0, BarsSinceExit(@,0,All,ThisTradeOnly), 1500)`

If bars since exit is greater than zero (i.e. a "proper value"), the if-then statement will return its true value. If the if-then statement is negative, it will return 1500 as a default value.

Now, using the AND statement, we can add the complete code into the trading system's signal portion of each trade as an additional rule:

`AND IF(BarsSinceExit(@,0,All,ThisTradeOnly) > 0, BarsSinceExit(@,0,All,ThisTradeOnly), 1500) > BarsSince( BarIx(@,StartOfDay)=0,1,400)`

As a result, the system trades only once per day:

Tags

#### Disclaimer

Trading and investment carry a high level of risk, and CQG, Inc. does not make any recommendations for buying or selling any financial instruments. We offer educational information on ways to use our sophisticated CQG trading tools, but it is up to our customers and other readers to make their own trading and investment decisions or to consult with a registered investment advisor. The opinions expressed here are solely those of the author and do not reflect the opinions of CQG, Inc. or its affiliates.