George pruitt – backtesting with [trade station, python, amibroker, excel]

In the Connors Raschke book, “Street Smarts – High Probability Short-Term Trading Strategies” published by M. Trailing stop strategy Gordon Publishing Group 1995, the authors describe a strategy that incorporates several ideas and functions that can be difficult to program into TradeStation. Trailing stop buy I highly suggest purchasing the book as it has some very interesting ideas and comes from the minds of two very accomplished traders.

The strategy is conceptually simple and uses the Taylor Buy/Sell day concept. Trailing stop loss software On buy days, buy on the penetration of the first hour high and use the extreme of the first hour as the stop.

Trailing stop limit fidelity If you get stopped out the system will allow you to re-enter once more on a re-penetration of the first hour high. Trailing stop sell If the trade is profitable at the close of the day session then exit on the open of the following day. What is a trailing stop order Selling short is just the opposite. How to set a trailing stop The Buy Day is defined when the three day RSI of the one day ROC (close[0] – close[1]) is below 30 and the Sell Day is defined when this indicator rises above 70. What does trailing stop mean As you can see, pretty simply.

The first problem when programming this strategy is the mixing of the 5 minute bars (for trade execution) and daily bars (calculating the indicator.) How do you calculate an RSI(c[0] – c[1],3) indicator value when looking at a 5 minute bar chart. Trailing stop limit buy This turns out to be pretty simple since TradeStation allows the mixing of different time frames on the same chart. How to use trailing stop loss First plot a 5 minute bar of the @ES.D as data 1 and then insert a daily bar of the @ES.D as data 2. Trailing stop on quote The first step in programming this strategy is setting up the indicator.

The buy/sell levels are the first hourly bar’s extreme +/- min. Buy trailing stop limit tick. What is a trailing stop limit These levels are used as protective stops as well as entry levels. Mt4 trailing stop loss If long then the first hourly bar’s low is the protective stop. Trailing stop in mt4 Notice how I check at 1510 if the trade is in a profit by examining the current openPositionProfit. Mql5 trailing stop I am checking five minutes prior to the close because I need to execute setExitOnClose if in a loss. Stock trailing stop I don’t think I can check at 15:15 (closing time) and then exit, but I will check and let you know.

The last little trick is to execute on the open tick the next morning. Define trailing stop I have explained in my books the different trading paradigms where you are either sitting on the prior bar when you place orders or sitting on the open of the current bar. What is a trailing stop loss EasyLanguage assumes the former so you always have to place an order for the next bar. Dynamic trailing stop If you wait until the open, then the earliest you can exit is 8:35. Trailing stop metatrader 4 So you have to issue the order on the last bar of the prior day to get the open tick, hence the test to see if the time stamp is 15:15.

This sample of EasyLanguage is a good example of some easy fixes to things that usually leave beginning EasyLanguage coders scratching their heads and groaning out loud.

Since Python doesn’t allow for a GOTO program flow structure I changed the inline trade entry/exit logic into function calls. Trailing stop vs trailing stop limit This allows for the call of these functions to be non-sequential. Trailing stop order example The original PSB order placement was sequential and would examine the entry/exit logic in TOP-DOWN fashion. Trailing stop example Meaning that if you put the Long Entry Logic first, the program would evaluate that logic first on every bar of data. Trailing stop buy order This was fine for the majority of trading systems out there. How trailing stop works However, systems that could enter multiple signals on the same bar require the orders to be placed in order of whichever was closest to the current market price. Trailing stop loss strategy Let’s say you have a trading algorithm that issues a stop to exit at a loss and a stop to reverse your current position. What is trailing stop limit If you examine the reversal logic prior to the stop loss and the stop loss is actually closer, then you will execute the wrong signal first. What is trailing stop By encapsulating the entry/exit logic into functions you can use decision constructs to flow through the correct logic in the correct order. Trailing stop indicator Here are the trade signals programmed as function calls:

As you can see there are six modules – Long Entry, Long Loss, Long Profit, Short Entry, Short Loss, and Short Profit (note non-necessary code was collapsed). Trailing stop loss limit I used the Sublime text editor to collapse the unnecessary lines of code. Best trailing stop You can download a trail version from their website. Trailing stop limit I am no longer using the IDLE as my go to IDE – I have fallen deeply in love with PyScripter. Trailing stop forex I will delve into this subject later.

Now that you have all your trade signals programmed as functions you can utilize if-thens to determine what order they are called. Ctrader trailing stop Here is the code that calls these functions

If you are flat and you can buy or sell on the same day then you call both functions. Stop loss trailing This back tester will allow you to buy and sell on the same day – the only problem is it doesn’t know which occurred first: the buy or the sell. Forex trailing stop strategy This can cause a problem because you need to know the correct position by the end of the day. Trailing stop loss beispiel Since we can peak into the future (be very, very careful) we can look at the close of the day and compare it with the long and short entry prices. Trailing stop buy order example Here is some code that might make your entries more accurate on those occasions where both orders could be filled.