In our previous lesson we learned how to add a protective price order to our entry order.  Our protective exit order would only go active if our entry order was filled by the market.  Protective entry orders are designed to limit unfavorable price moves of a new position to the distance in points between the entry fill-price and the protective price, and they only protect if the market's price goes over the protective price using an On-Stop execution to close the position.

 

An On_Stop order execution is a buy or sell order that requires the order's On_Stop price to be touched or penetrated.  When an On_Stop price is enabled the order becomes a market order to be filled as soon as possible.  On_Stop prices are not guaranteed to be filled at the exact execution price.  When a fill price differs from the On_Stop price the difference is considered slippage.  How much slippage happens is based upon the volatility of the market, size of the order, and the volume of trades available after prices have triggered the On_Stop-trigger.

 

All Trading Blox orders are "Day" orders.

Definition:

Any order to buy or sell a share or a contract that automatically expires if the market does not enable the order on the day it was placed.  This means the order is only valid for one day.  If the order's execution type is not enabled by the market in the trading session on the day in which it was placed, the order is automatically canceled at the end of the trading session.

 

At the end of the entry session the protective exit order will be canceled when its protective On_Stop price is not enabled.  This means the trading system will need to create a new protective order for each of next trading sessions in which the position is open.  This might seem like a problem, but in trading it is the preferred method for most system traders.  It is preferred because orders that are not automatically canceled, must be manually canceled by the trader.  When they are not canceled they are able to create unwanted positions, and too often in the wrong direction.  

 

Trading Blox only creates "Day" orders, and the software makes it easy to keep protective price orders in place for as long as the position is open, but it does require rules be in the system rules to create an updated protective exit order.

 

Open Position Exit Orders:

Whenever an instrument has an active position the Exit Orders' script section executes so as to enable the trading system to place orders for a protective price to exit, remove a position quantity, reduce units, or to close a position.  Systems will occasionally place all of the above listed orders when the design of the system requires various methods for managing the position.  

 

Exit Orders Script Section:

Trading Blox Exit Orders script section will only executes when an instrument has an open position, so it is always available when a trade is active, and it is out of way when it isn't needed.  When more than one module has script section that other modules contain, all the script sections in all of the modules that contain scripted code will execute when script using the same name in other scripts is being executed.

 

By always executing script sections that have scripted system rules, the timing of when each of the scripts in each of the modules is executed can make a significant difference in how the system performs.  Script with the same name will always execute in the order of how each of the modules are displayed in the System Editor center display of system modules.

 

Trading Blox provides many Broker Exit Order Functions.  Prices applied to these exit functions are determined by the script code created specifically for this purpose.  In the next section we are going to limit this next step to only keeping the original protective price order active during the trade so the process can be kept simple and easy to understand.

 

Open our second Tutorial System and then click on the Exit Orders script section.  When it appears, type the following into the editor area on the left and save your work:

Exit Orders Script Code:

'  Enable Entry Protection Exit Order for life of position
broker.ExitAllUnitsOnStop( instrument.unitExitStop)

 

This simple broker statement shown above is all that it takes to keep the original entry order protective price active throughout the life of the trade.  It keeps the original protective price active because it is referencing the price value of the trade record so that it can be used with each new protective order.  It gets the position's previous entry protective price from the property: instrument.unitExitStop and it uses that value as the price when the Broker object function ExitAllUnitsOnStop creates a new protective order.  This Broker function will work with Long or Short position because the function knows which instrument is trading as well as the direction of its active trade.  

 

Trading Blox stores a lot of other information with its instrument and it is worth taking the time to review how much information is readily available.  Click on this link to browse through the Data Properties table where each property is listed with a brief example of what it contains.

 

Adding Protective Stop Indicator:

With the code in place above we now have a position that will be protected using the original protective price we used when the entry order was filled.  When Trading Blox displays trade information it won't show where the new protective price orders are located in relation to the price unless we add that ability to the trading system, which is very simple.  However, instead of adding a protective price indicator to our tutorial system, we are going to use one that is already available by adding the Plot Stop Price block module to our tutorial system.  

 

Go into the System Editor (F3), and be sure our tutorial system module is visible in the System Listing windows in the center of the System Editor.  Now locate the Auxiliary module shown in this image.  Once found, Right-Click on the module and it will appear in the bottom window where our other tutorial modules are listed.

System Editor Block Name Selection - Plot Stop Price

This module is a simple indicator that will place a red-dot above prices on short positions, and below prices on long positions indicating the the position's protective exit price.

 

Here is the code used in the Plot Stop Price indicator block.  It will only plot the value of the current unitExitStop[1] when this instrument has an active position.  

 

Plot Stop Price Indicator Code - ADJUST STOP Script Section:

'  Plots the current stop price for unit one when
'  position is active
If instrument.position <> OUT THEN
  '  Assign Positions Protective Price to Indicator
  currentStopPrice = instrument.unitExitStop[1]
ENDIF '  i.position <> OUT

 

This module knows when a position is active because it is referencing the instrument's position property.  This a position property can have any of these values:

1 for Long Positions

0 for Flat or No Active Positions

-1 for Short Positions

 

In the example above the variable currentStopPrice is an IPV Auto-Indexing Series.

Plot Stop Price Indicator DeclarationDialog

Take a few minutes to examine how this module is created so you'll have some reference on which to create a protective price indicator into your own system, and many other types of position indicators.  Also note that the option in the lower right corner of the dialog has enabled the "Offset Plot Ahead One Bar."  This option forces the indicator to place is chart information in the area where the next bar will display.  This done so the current protective price indicator mark will be placed at the price location where the price of the next bar will trigger the protective order action when the price touches the protective price.  

 

By placing the information ahead one bar for this type of indicator, the information on the screen becomes a little easier to understand that the price touched the protective exit price on the same bar the position was closed.

 

In operation the Plot Stop Price indicator will appear like this for a Short Position:

Click to Enlarge, Click to Reduce

Plot Stop Price Indicator Example

In our chart example the protective price doesn't change throughout the life of the trade.  This isn't always the best way to protect a trade because it doesn't provide any progressive price action that can preserve gains that favorable price moves may have provided.  We are also terminating the position when the price touches our protective price, so alternate protective logic methods that would terminate only when the close price touched or crossed the protective are not explored.

 

Keep in mind that one of the major issue in trading system design is the lack of finding and applying alternate ideas to see if what we currently have now can be improved by changing some of the methods or logic being used.  As you spend time with the various supplied systems that are installed when Trading Blox is installed, notice the various methods for handling entry, exits and protective price methods.  Also spend some time searching for various ideas in the Trader's Roundtable forum's Blox MarketPlace and Trading Blox Support sections.

 

Links:

Data Properties, Operator Reference, Position Properties, Script Section Type Details

 

This completes this topic.


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 114

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software