December 28

# A Simple Break Out Algorithm Demonstrating Time Optimization

By George Pruitt

December 28, 2020

# What is Better: 30, 60, or 120-Minute Break-Out on ES.D?

Here is a simple tutorial you can use as a foundation to build a potentially profitable day trading system. Here we wait N minutes after the open and then buy the high of the day or short the low of the day, and apply a protective stop and profit objective. The time increment can be optimized to see what time frame is best to use. You can also optimize the stop loss and profit objective – this system gets out at the end of the day. This system can be applied to any .D data stream in TradeStation or Multicharts.

## Logic Description

1. get open time
2. get close time
3. get N time increment
1. 15 – first 15-minute of day
2. 30 – first 30-minute of day
3. 60 – first hour of day
4. get High and Low of day
5. place stop orders at high and low of day – no entries late in day
6. calculate buy and short entries – only allow one each*
7. apply stop loss
8. apply profit objective
9. get out at end of day if no exits have occurred

## Simple Orbo EasyLanguage

I threw this together rather quickly in a response to a reader’s question. Let me know if you see a bug or two. Remember once you gather your stops you must allow the order to be issued on every subsequent bar of the trading day. The trading day is defined to be the time between timeIncrement and endTradeMinB4Close. Notice how I used the EL function calcTime to calculate time using either a +positive or -negative input. I want to sample the high/low of the day at timeIncrement and want to trade up until endTradeMinB4Close time. I use the HighD and LowD functions to extract the high and low of the day up to that point. Since I am using a tight stop relative to today’s volatility you will see more than 1 buy or 1 short occurring. This happens when entry/exit occurs on the same bar and MP is not updated accordingly. Somewhere  hidden in this tome of a blog you will see a solution for this. If you don’t want to search I will repost it tomorrow.

``````
//Optimizing Time to determine a simple break out
//Only works on .D data streams

firstBarTime = sessionStartTime(0,1);
lastBarTime = sessionEndTime(0,1);

calcStopTime = calcTime(firstBarTime,timeIncrement);

If time = calcStopTime then
begin
shortStop = LowD(0);
shortsToday = 0;
End;

if time >= calcStopTime and time < quitTradeTime then
begin
if shortsToday = 0 then Sell short next bar at shortStop stop;
end;

mp = marketPosition;

If mp = 1 then buysToday = 1;
If mp = -1 then shortsToday = 1;

SetStopLoss(stopLoss\$);
setProfitTarget(profTarg\$);
``````
Orbo EasyLanguage Code

George Pruitt