Converting Word Documents Into Posts

DRAFT - SUBJECT TO SUBSTANTIAL REVISION

OBJECTIVE

The objective for this tutorial is to show how to copy a Word document into Windows Live Writer (WLW) for uploading to the Users’ Knowledge Base (UKB).

INTRODUCTION

Copying Word documents into WLW  provides Authors with an additional option, and a user friendly way, for contributing to the UKB. It is recommended for those who have an archive of articles already written in Word or who prefer the familiarity of Word. It is also suitable for those who want to use the superior editing features that Word offers over Blog Editors. It is also useful for those who work collaboratively and want to use features like comments and revision tracking. Another benefit is that it provides a stable, and familiar local back-up. It is a method that does not have a long learning curve.

PREPARATION

It is recommended that the Word document to be copied has been written according to the guidelines at: Quick Posting Example - Word Attachment . The document should consist only of text, with basic formatting, images, tables, hyperlinks and AFL formulas. Tables need to have been converted to an image.

CONVERT

Copy and paste the document into WLW

1) Open a New post in WLW.

2) Enter a Title for the post.

3) Open the Word document that is to be copied.

4)

 

AFL formulas - add markers (plain text in AB pref)

TO BE CONTINUED

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Order Simulation using DebugView

The design of real-time automated trading systems involves two major design phases: 1) Designing the trading system and 2) Developing the trade-automation code. While you may be able to re-use some previously developed AT functions, you can rarely transport the entire automation section from one trading system to the next. Adjusting your AT code to work with a new system can be very time consuming; it can involve weeks of real-time testing and debugging. Using the code below you can test your new system ideas, in a tick environment, before you have written a single line of automation code.

Note that when testing this code with the Bar-Replay tool, the log will display the bar’s closing price instead of the Lastprice (tick data). When testing this code with your own trading system, you may want to add extra output to the _TRACE() statements. The code below substitutes DebugView output for orders that would have normally gone to the TWS:

dbvlog.jpg

1
2
3
4
5
6
//Dummy system to generate some signals (Do NOT trade!) 
Short=Cover=0; 
Buy = O>Ref(C,-1); 
Sell = O<Ref(C,-1); 
BuyPrice = O; 
SellPrice = O;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
InLong = Nz(StaticVarGet("InLong")); 
RTBuy = LastValue(Buy) AND NOT InLong; 
RTSell = LastValue(Sell) AND InLong; 
if( RTBuy )  
{ 
StaticVarSet("InLong",1); 
Plot(1,"",5,styleArea|styleOwnScale,0,20); 
StaticVarSet("BuyPrice",LastValue(BuyPrice)); 
BP = StaticVarGet("BuyPrice"); 
SP = StaticVarGet("SellPrice"); 
_TRACE("# ,"+NumToStr(DateTime(),formatDateTime)+", Buy, "+NumToStr(BP,1.2)+", Profit, "+NumToStr(SP-BP,1.2)); 
} 
else if( RTSell ) 
{ 
StaticVarSet("InLong",0); 
Plot(1,"",4,styleArea|styleOwnScale,0,20); 
StaticVarSet("SellPrice",LastValue(SellPrice)); 
BP = StaticVarGet("BuyPrice"); 
SP = StaticVarGet("SellPrice"); 
_TRACE("# ,"+NumToStr(DateTime(),formatDateTime)+", Sell, "+NumToStr(SP,1.2)+", Profit, "+NumToStr(SP-BP,1.2)); 
}

Edited by Al Venosa

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 3 out of 5)
Loading ... Loading ...

System-Design Pitfalls

When you are designing a real-time trading system, many things can go wrong. This post is intended to alert you to some of the potential pitfalls. However, that is all it can do. Only experience can teach you how to prevent them. Be aware that even the most experienced designers will make some of these mistakes repeatedly.

Since documenting all potential pitfalls with coding examples would consume too much time and space, they are, for now, only briefly commented on. Most of them will trigger a user response of “Oh yeah, that happened to me!”. If you need a more detailed explanation you can post questions in a comment to this post

No rules exist to prove that a trading system is free from coding or logical errors. However, two indicators are fairly reliable in suggesting you may have a problem:

1) Your profits are simply too good to be true. In this case you have no choice but to work through the code line by line, trying to find lines of code that look into the future. If that doesn’t reveal any errors, then you would have to inspect the plotted signals and trade list trade by trade.
2) Your system is very profitable trading Long but not Short, or Short buy not Long. When this happens, you may have an error in either the Long or Short parts of your code, and comparing the two sections will often reveal the problem (this only works for reversal systems). However, it could also be that your code is correct but that your trading principle is overly trend sensitive. This would almost certainly get you in trouble when the trend reverses. In this case no other cure exists than to re-think the basic system.

When designing high-frequency trading systems, i.e., those whose trade durations are in minutes, everything changes, and many traditional procedures fall apart. Internet delays, data delays, bad data (spikes), temporary system freezes (Windows sometimes has a mind of its own!), lagging status reports, TWS problems, etc., all become critical issues that will prevent you from obtaining a close match with the Backtester.

Many of these problems will only surface when you start trading real money. Hence, the final stages of developing a trading system should always involve trading real money. Here is where the Interactive Brokers account simulator (paper-trading account) may be an indispensable tool since you can test your system in real time without committing real dollars. But, since the market does not see your trades, even paper-trading results will differ from trading real money. In general, the faster you trade, the greater your real-trading results will deviate from your backtest results. You should also be aware that commissions play a much greater role on performance of high-frequency trading systems because trade profits are smaller.

No matter how you go about it, troubleshooting a complex trading system will almost always be a tedious and boring job that could keep you busy for several days or weeks. If you find that certain problems continue to resurface, they are likely related to your personal development style, and you may be able to write some code that checks for these specific problems. See the Debugging category for some ideas.

The list below, which is not exhaustive, is presented to caution you that many areas can lead to problems. Some are obvious, while others may be expanded on as needed and time allows.

- High/Low precedence (contrary to EOD where the Backtester is unable to determine which came first, the entry/exit or the high/low, in realtime there can be no ambiguity in price precedence).
- Data Delays (real-time data may be delayed for various reasons and time periods (Internet delays, lack of quotes, packets vs. ticks, etc.).
- Low Liquidity (there may be no-volume trading periods).
- Data Holes (bars with no trades).
- Data Spikes (high spikes without volume may trigger trades).
- Data Padding (a bar without data may be padded).
- Premature Padding (the last bar may be a padded bar).
- Data Accuracy (prices you receive aren’t always accurate).
- Random Slippage (you will rarely get the expected price).
- Breakout slippage (you will rarely get the Breakout price of your system).
- Survivorship Bias (companies that didn’t do well and stopped trading won’t be in your database, i.e., you are working above average stocks).
- Lucky Trades (a series of lucky trades may look like good performance).
- Parameter Over-Optimizing (optimized parameters are rarely stable over time).
- Design Over-Optimizing (frequent testing is like running an optimization and may be leading to false conclusions).
- Out–of-Bound Prices (with PriceBoundChecking turned ON, AmiBroker forces the trade price within the High-Low range, this may hide pricing errors).
- Price Rounding (prices may be rounded or truncated by the broker).
- Wrong Use of >= and <= (when using both <= and >= in the same statement, only the first equal condition will ever be seen).
- Comparing Floating Point Numbers (calculated values can have many decimal places, either round values or use the AlmostEqual()).
- Chart Justification (make sure you are looking at the Last bar!).
- System Mortality (no system will work forever).
- Sharing Trading Systems (sharing systems with other traders may result in over-trading a system).
- Being Duped by a Trend (a rallying ticker may make your system look like the HG (holy grail).
- Tricking AmiBroker (AmiBroker has its limits; it is possible to write esoteric code that will produce wrong results).
- Order Visibility (placing your order for every trader to see may influence the orders they place).
- Making the Market (extreme example: if you place a MKT order during a no-trading period you will change the chart).
- Window/Pane Execution Order (when passing variables between panes or windows do not assume that they execute in a fixed order, more).
- Trading at the Open (order execution at the start/end of day is different from midday because of volatility and data delays).
- IB Data Snap Shots (snapshots are only representative of prices traded).
- Trade Delays (make sure you understand your trade delays when backtesting).
- EOD and Intraday Gaps (There is no time interval in RT gaps).
- Time Zones (make sure your computer and database timezones are properly set).
- Very Short Time-Frames (prices jump and are less contiguous).
- Setting LMT Prices (consider rounding for faster order executions).
- 24-Hour vs. RTH (Regular Trading Hour) Backtesting (extended hours can rarely be traded like RTH due to huge bid/ask spreads and low volume).
- Static Variables Naming (use unique names for your static variables).
- Incorrect Computer Time (computer time offset from market time can cause real problems).
- Look-Ahead Problems (not all look-ahead coding problems are obvious).
- Buy/Sell Precedence in a Loop (be aware that AB and custom AFL loops enforce a Buy/Sell priority).
- RT Candle Discrepancies (RT Candles may be different from later backfills, especially in the opening print).
- Bars Loaded (consider bars-loaded with respect to execution speed and loops).
- Signal lifetime (signal strength quickly decays over bars in high frequency trading).
- SameBarExits (Sell signals may act as a qualifier for Buy signals).
- Designing systems based on High and Low triggers (these may fill in the Backtester but not in real trading). more…
- Using the wrong CommissionMode and/or CommissionAmount can make any system look good, or bad…
- Using zero TradeDelays is OK if you code the delays in your system’s code, else you may be looking into the future.

Edited by Al Venosa

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4.4 out of 5)
Loading ... Loading ...

Real-Time Delays

In real-time trading many situations arise when you want to delay action until a specific criterion is met. In AmiBroker you can base your delays in many different ways, the only requirement being that the delay variable increments or decrements. If the selected variable doesn’t revert towards your timeout value (target), your delay function would never time out. In this case you would have to add code to handle that condition. A few variables you might use are:

- RT TimeNumber (Now(4)).
- Elapsed Seconds (redrawaction).
- Real-time Data time-stamp (TimeNum()).
- Tick-count (New Data).
- Volume (Change in Volume).
- Price change (Change in Price).
- Chart Refresh (any AFL Execution).
- Indicator values.

Which of the above variables you would use for your delay depends on the requirements of your trading system. There may be times when you may need to combine several methods to get the required results. For example, if a delay were based on the data-timestamp, it might not time out during a data dropout or a no-trading period. In this case you need to back up your data-timestamp delay with a real-time (seconds) delay.

Delays play a critical role in real-time system design. For example, in real-time systems, signals may have a short lifetime. The signal is strongest when it triggers and than quickly decays until, perhaps after a few bars, it has lost all significance. Letting the order fill at the time when it has lost significance is pure gambling. To prevent this, you can cancel the order after a delay, or decrease the position size proportional to the perceived decay in signal strength (perhaps based on elapsed bars?)

Since in a real-time system the time-lapse between AFL executions can be significant, you should place your LMT price calculations ahead of the ordering code. Calculating the LMT price after the order has been placed postpones order placement until the next AFL execution occurs, i.e., when the next quote arrives; by then, the price has probably changed. Especially during periods of low volume, this could be significant. When these delays would be insignificant in EOD systems, they could make-or-break your system in fast-trading systems.

To ensure frequent AFL execution in the absence of quotes, you can place a RequestTimedRefresh(1) statement at the top of your code, where the variable ‘1′ refers to a 1-second refresh. This guarantees an AFL execution at least once per second.

If your code is lengthy and takes a significant amount of time to execute, you may have to check order status at several places in your code. If changed status demands immediate action, you can force an immediate AFL execution by calling the following function:

1
2
3
4
5
function RefreshAll() 
{ 
oAB = CreateObject("Broker.Application"); 
oAB.RefreshAll(); 
}

The highest rate that you can call this function is once per second.

Due to the lack of chart resolution and the static character of historical data in longer time frames (minutes and higher), you may only be able to optimize delays during live simulation or real trading. This is because only the last bar will show live changes.

If delay functions are used in different programs, they must use unique static variable names in each program. See the post on Keying Static Variables for more information on this.

The code below introduces a DelayManager() that can be used to implement most delay functions. The delay function uses the following variables:

1) DelayName is needed to allow its use for different delays.
2) DelayValue is used to set the DelayTarget, if set to zero the function returns the DelayRemaining.
3) DelayReference is the variable that is sampled when the delay is initialized.
4) DelayTarget is calculated as (DelayReference at initialization) + DelayValue.
5) DelayRemaining is the distance to the DelayTarget.

In your final system formula, you may want to use an in-line equivalent for better performance. The code below lists multiple choices for the DelayReference; you should comment out the ones not used or place the one to use in the last position.

When testing this code you can observe the DelayValue being initialized, and counting down to timeout, in the Title.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function getTickCount() 
{ 
LastVol = LastValue(Volume); 
PrevVol = Nz(StaticVarGet("PrevVol")); 
NewTick = PrevVol != LastVol; 
if( NewTick ) 
{ 
TickCount = Nz(StaticVarGet("TickCounter")); 
StaticVarSet("TickCounter",++TickCount); 
StaticVarSet("PrevVol",LastVol); 
} 
TickCount = StaticVarGet("TickCounter"); 
return TickCount; 
}

1
2
3
4
5
6
function getRefreshCount() 
{ 
RefreshCount = Nz(StaticVarGet("RefreshCounter")); 
StaticVarSet("RefreshCounter",++RefreshCount); 
return RefreshCount; 
}

1
2
3
4
5
6
7
8
9
function getElapsedSeconds() 
{ 
if( Status("redrawaction") ) 
{  
ElapsedSeconds = Nz(StaticVarGet("ElapsedSeconds")); 
StaticVarSet("ElapsedSeconds",++ElapsedSeconds); 
} 
return Nz(StaticVarGet("ElapsedSeconds")); 
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function DelayManager( DelayName, DelayValue, DelayReference ) 
{ 
if(DelayValue == 0 )  
{ 
DelayTarget = Nz(StaticVarGet(DelayName)); 
DelayRemaining = Max( 0, DelayTarget - DelayReference); 
} 
else 
{ 
DelayTarget = DelayReference + DelayValue; 
StaticVarSet(DelayName, DelayTarget ); 
DelayRemaining = DelayValue; 
} 
return DelayRemaining; 
} 
function GetSysSecondNum() 
{ 
Time = Now(4); 
Seconds = int(Time%100); 
Minutes = int(Time/100%100); 
Hours = int(Time/10000%100); 
SecondNum= int(Hours*60*60+Minutes*60+Seconds); 
return SecondNum; 
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RequestTimedRefresh(1);  
DelayName = ParamStr("DelayName","TestDelayName"); 
DelayValue = Param("Delay Value", 10,1,200,1); 
DelayTrigger = ParamTrigger("Initiate Delay","INIT"); 
ResetHRPC = ParamTrigger("Reset Performance Counter", "RESET HRPC"); 
if( ResetHRPC ) GetPerformanceCounter( True ); 
NewDay = DateNum() != Ref(DateNum(),-1); 
// Some of the many delay references you can use 
// The last defeinition for DelayReference is used 
DelayReference = TimeNum(); 
DelayReference = MA(C,10); 
DelayReference = C; 
DelayReference = Sum(V,BarsSince(NewDay)); // DailyVolume 
DelayReference = getTickCount(); 
DelayReference = getRefreshCount(); 
DelayReference = getElapsedSeconds(); 
DelayReference = GetSysSecondNum(); 
if( DelayTrigger ) DelayManager(DelayName, DelayValue, DelayReference ); 
else DelayManager(DelayName, 0, DelayReference ); 
DelayToGo = DelayManager( DelayName, 0, DelayReference ); 
Title = "\nDelay:"+NumToStr(DelayToGo,1.0);

Edited by Al Venosa

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.5 out of 5)
Loading ... Loading ...

Introduction To Windows Live Writer

DRAFT

OBJECTIVE

The objective of this tutorial is to demonstrate the basic skills required to write and upload a standard post to the User’s Knowledge Base (UKB), using Windows Live Writer. It does not cover advanced features and exceptions.

SPECIFICATION

Windows Live Writer (WLW) is a free blog editor developed by Microsoft. At the time of writing it is in beta and does not have a manual. The beta version can be downloaded from: http://get.live.com/betas/writer_betas

The file version available for download in July 2007 was:

WLW022

This tutorial was written using Beta version 1.0, installed on a computer with Windows XP Home as the operating system and Internet Explorer 7 as the browser.

Support is available via the link at the bottom of the download page or from: http://windowslivewriter.spaces.live.com/blog/

INSTALLATION

To install Windows Live Writer run the installer and enter inputs to the Setup Wizard as follows:

1) UKB authors already have a weblog (DO NOT create a Windows Live Spaces Account); click on Next >.

WLW203

2) Select Another weblog service then click on Next >.

WLW205

3) Enter the Weblog Homepage URL as shown and then enter your Username and Password as provided by support [at] amibroker.com then click on Next >.

WLW207

4) The installer will run through a series of tasks that synchronizes your installation to the UKB site including the Weblog Name, Capabilities, Formats, Categories and other settings.

WLW208

5) When the installer ‘asks’ for permission to upload a temporary post; click on Yes.

WLW209

6) The installer will make an ‘announcement’ when the configuration is complete; click on Finish.

WLW2101

7) Windows Live Writer will open on your desktop.

 WLW213

The Sidebar, which can be opened or closed by selecting View > Sidebar from the Menubar, is open by default after installation.

WLW079

The Properties option can also be selected from the same menu, or, toggled on or off by using the double arrows at the right side of the Properties Sub-panel.

WLW216

The blog site settings, as detected by WLW, can be found at Tools > Accounts > Edit> Capabilities > View Capabilities. They can also be refreshed by using the Update Account Configuration button at the same location as the Capabilities link.

WLW214 

OPTIONS

For this example the defaults, as installed, have been accepted, with only a few minor exceptions.

Refer to Tools > Options:

Tools > Options > Preferences

WLW005

 Tools > Options > Accounts

 WLW0010

 Tools > Options > Accounts > Edit > Account

 WLW0011

Tools > Options > Accounts > Edit > Images

WLW002

Tools > Options > Accounts > Edit > Editing

WLW003

Tools > Options > Accounts > Edit > Advanced

WLW004

 Tools > Options > Blog This

WLW0012

Tools > Options > Spelling

WLW0013

Tools > Options > Link Glossary

WLW0014

Tools > Options > Plugins

WLW302

Tools > Options > Web Proxy

WLW006

Tools > Options > Ping Servers

WLW007 

VIEW

WLW has four options that can be selected from the View menu; Normal, Web Layout, Web Preview and HTML Code.

WLW049

Whenever WLW is started it opens in Normal view, which is the default. In Normal view the main window is in editing mode and it functions in a similar manner to a word processing program.

The Web modes are for viewing only and they have little practical value. As well as that, some code might not render the same on the UKB site as it does in WLW e.g. AFL formulas are only ‘formatted’ after uploading.

Note: to preview a post the recommended method is to upload it as a draft and open it online from the Manage Panel. (For information on previewing draft posts refer to: Introduction To The Admin Center )

 In HTML view the underlying code can be read and edited if necessary.

WLW020

WRITING

By default, WLW opens with a new, or unsaved draft, in the Editing Window. (The status of the post is reported in the bar at the bottom of the screen.)

Enter the Title of the post.

WLW048

Enter text into the body of the post. (The text will wrap automatically with single line spacing. The Enter key will insert a new paragraph with a single line space.)

Limited formatting can be applied to the text by using the icons on the Toolbar.

WLW050

Additional formats can be applied from the Format menu.

WLW051

 A subset of the available formats can be accessed by right clicking inside the Editing Window and selecting from the context menu that appears.

WLW052 

EDITABLE ITEMS

The body of a post comprises formatted text plus editable items that can be inserted into the post.

There are five classes of editable items; Hyperlinks, Pictures, Tables, Maps and Tags (only the first three will be considered in this tutorial).  Each class has it’s own icon to distinguish it from the others. Any class can be inserted by selecting the relevant icon from anywhere in the program where it appears. There are four places where editable items can be selected.

To insert an editable item select the icon from:

1) The Insert menu.

WLW056

2)  The icon on the toolbar.

WLW058

3)  The Insert drop-down menu on the Toolbar.

WLW059

4) The Insert menu box on the Sidebar.

WLW060

Once inserted into a post each item has it’s own specific reaction to mouse input.

 

LEFT CLICK

RIGHT CLICK

Hyperlink opens the link opens a context menu
Picture selects the object for sizing and moving
plus opens the Properties Center  in the Sidebar
same as left click
plus opens a context menu
Table positions the cursor in the table opens a context menu

USING IMAGES

Images can be used to illustrate a point.

To insert images into a post:

1) Position the cursor in the Editing Window where the image is to be inserted.

2) Click on an Insert Picture icon,

3) Use the View menu in the Insert Picture Window to change to Thumbnail view. (This will make it easier to select the correct image.)

WLW027

 4) Hover the mouse over the image to be inserted and a message-box, that gives the Dimensions of the image, will appear. The image needs to be less than 700 - 800 pixels wide to fit into the post without adjustment. Re-sizing images should be avoided, if possible, as it will cause the images to lose quality.

WLW028

 

5) Pick the image required and click on the Insert button. (The selected image will be inserted into the Editing Window at the location of the cursor.)

 After an image has been inserted into the post the image defaults should be set.

To Set The Image Defaults:

1) Click on an image to select it. (The Image Properties Window will appear in the Sidebar.)

2) click on the Image tab and change the settings to Text wrapping - Inline, Margins - No Margins, Borders - None and Link To - None, then Save the settings as default (the link is at the bottom of the Image panel).

WLW030

(Note that this is a one-off requirement that should be set immediately after the first image is inserted. Thereafter the settings can be changed on an individual basis, as required, but it is not recommended to use Borders and Link To in any other way).

In the advanced panel images can be resized on an individual basis, although once again it is not recommended.

The size of an image can be changed manually by over-typing the Width or the Height into the input boxes. If the Width to Height ratio is locked it is only necessary to type in one of the dimensions and enter it. The second dimension will automatically change.

WLW025

There are also three pre-set options; Small, Medium and Large, that can be picked by from the Image size drop-down.

WLW037

The pre-set defaults can be changed by clicking on the protractor image at the side of the Image size box and ramping the Height or Width up or down in the Default Image Size window. Once changes have been made the new settings automatically become the default.

WLW029

The final panel allows users to apply special effects to images. Effects are not considered in this tutorial, which is restricted to basic procedures.

 WLW026  

 Tips and Tricks for Managing Images

1) Give the files a meaningful name on the local computer, and append a progressive number, to identify them. DO NOT enter an alternative text name. (This will synchronize the image ‘name’ in all places where it is used locally, and on the UKB site) :

  • the local filename will become the filename on the UKB server by default.
  • the local filename will become the Title on the UKB server, by default (the Title will be displayed if the mouse is hovered over the image in WordPress editing mode)
  • the local filename will become the Alternate text name for the image, by default (the alternate text will be displayed in posts, instead of the image, if the image has been deleted from the server and also if the mouse is hovered over the image in a post)

Synchronizing the image ‘names’ makes it much easier to track the files across the operations that occur, and between the local computer and the UKB server.

2) Images can be positioned by using the alignment commands:

  • position the cursor adjacent to the image (move the cursor ‘pointer’ until it is immediately to the left or right of the base of the image and click once)
  • right click in white space inside the Editing Window to open a context menu
  • select Align > Left, Center or Right as required

3) Images can be moved by cutting and pasting:

  • click on the image to select it
  • right click inside the image to open a context menu
  • select Cut from the context menu
  • position the cursor in the required spot for the image
  • right click in white space to open the context menu again and select Paste (the image will be pasted into the post at the location of the cursor).

4) Images can be moved by dragging them with the mouse:

  • hover the cursor ’pointer’ over an image (the cursor will change to a moving cursor ‘pointer’)
  • click and hold the left mouse button on the image (the moving cursor pointer will change to an arrow with an opaque rectangle attached)
  • drag the rectangle to where the image is to be inserted and release the mouse button to insert the image

 5) Images can be deleted:

  • click on the image to select it
  • hit delete on the keyboard to remove it from the post

6) Images can be replaced:

  • delete the image that is to be replaced from the post (captured images represent an investment in time so it is recommended that they are kept in case there is a need to reinstall them)
  • capture the new image that is needed to replace the old and give it a unique name (do not overwrite the original image, even if it is not required, as WLW will not upload an image, to the server, with the same name twice)
  • insert the replacement image

7) Images can be deleted or replaced after publishing:

  • download the post for editing (refer to instructions in a later section of this tutorial)
  • delete or replace the image (use the method described above)
  • re-publish the post
  • go online to the WordPress administration Center and manually delete the unwanted image file (refer to ‘Introduction To The Admin Center’ for instructions)

ENTERING AFL FORMULAS

To prevent conflict between AFL formulas, and the HTML code used to ‘write’ posts, a customized AFL tag has been provided by AmiBroker for use with Blog Editors. AFL tags, or markers, perform a similar function to the <code> tag, which is used in WordPress to distinguish operating code from example code.

To enter an AFL formula from AmiBroker:

1) Go to Tools > Preferences > Editor in AmiBroker and uncheck Copy as HTML by clicking in it.

WLW123

2) Open the AFL formula in Formula Editor and copy it to the clipboard.

3) Right click in white-space in the WLW Editing Window to open a context menu.

4) Select Paste from the context menu (the formula will be pasted into WLW with limited formatting).

WLW124 

5) Type AFL markers before and after the formula code.

1
2
3
4
5
6
7
8
/*P_BarsInYear*/ 
InYearFlag = IIf(DateNum() >= 1060101 AND DateNum() <= 1061231,1,0);
InYear = Cum(InYearFlag);
Plot(InYear,"BarsInYear",2,2|4); 
// Logic.
// line 3 returns one if a bar is within the calendar range, or zero if not, and assigns it to the InYearFlag variable;
// line 4 cumulates the ones from line 3 and assigns the result to InYear;
// line 5 plots the cumulated result in a chart;

Note: In WLW Web mode the appearance of the formula will be the same as in Normal view but on the UKB site the formula will be rendered in the standard format.

After entering a formula leave a one line space before continuing to enter text (this prevents the formula’s format from spilling over into subsequent entries).

 (Note that in HTML view <code></code> tags have automatically been added to the beginning and end of the formula).

 Inserting links

Links to web-sites can be established simply by typing in the URL to the relevant page. The link will be automatically generated once the text is entered e.g. 

www.amibroker.com

They can also be inserted by using the Insert Hyperlink command from the Insert menu box in the Sidebar:

1) Click on the Insert Hyperlink. (The Insert Hyperlink Window will open).- also at insert menu and toolbar

WLW042

2)  Type the web-page address into the URL input box, or, copy and paste it from a browser or other source. (When the address is entered WLW will synchronize with the recently viewed address list in Internet Explorer. Any address can be selected from the list if desired.)

WLW040

3) Type a name for the link into the Text input box. (The name will be used as the link text in the post.)

WLW041

4) Check the option boxes Open link in new window and Add to link glossary then click on OK (A link to the URL will be entered at the current location of the cursor e.g. AmiBroker homepage  )

The glossary provides a shortcut method to use the link again at a later date:

1) Open the Insert Hyperlink Window.

2) Click on Link To to open a drop-down menu and pick Glossary Entry. (The Select Link from Glossary Window will open.)

WLW043

3) Select the required link from the Glossary list by name or URL.

WLW044

a link can also be established to another UKB post, including a draft.

1) Open the Insert Hyperlink Window.

2) Click on Link To to open a drop-down menu and pick Previous Post. (The Link to Post Window will open.)

WLW047

 3) Select a file to link to from the Recently Posted list or the AmiBroker Users’ Knowledge Base list. (If the required post isn’t in the list increase the number of items to show and click on the refresh icon.)

WLW045

4) Enter a title for the link and check the boxes to Open link in new window and Add to link glossary, then click on OK

WLW046

 A link that opens the selected post in a new window, will be inserted at the current location of the cursor.

 

Inserting tables

 

 To insert a table:

1) Position the cursor in the Editing Window where the image is to be inserted.

2) Click on an Insert Table icon (the Insert Table window will open).

WLW061

3) Enter the required number of rows and Columns by over-typing into the input boxes. Set the width of the table in pixels (1000 is the maximum allowable) and click on OK. 

This will insert a ‘blank’ table into the post at the current position of the cursor.

 WLW066

To enter data into the table:

1) Hover the cursor pointer over a cell and click to position the cursor.

2) Type in the data and use the Tab or the Arrow keys to move between cells.

 WLW067

To format a table:

1) Right click anywhere inside the table to open a context menu.

WLW063

2) Select Table Properties to open the Table Properties window.

WLW064

3) Check Show table border set to 1 pixel to add a border to the table.

A B C D E F G H I J
1 2 3 4 5 6 7 8 9 0
2 3 4 5 6 7 8 9 0 1
3 4 5 6 7 8 9 0 1 2

4) Use the other commands listed in the context menu to ‘format’ the table as required:

  • position the cursor as a marker in any cell and Insert, or Move, the rows and columns around it
  • position the cursor as a marker in any cell and Delete the table, row or column
  • position the cursor as a marker in any cell and use Column Properties or Row Properties to customize the width or the height
  • select multiple cells by holding down the left mouse button and dragging the cursor across the required range
  • use the Clear Cell(s) command or the Delete key to remove data from selected cells
  • use the Cell Properties option to align data within selected cells

 

Tips and Tricks for Using Tables.

1) Tables can also be used, without a border, to create ‘tabulated’ rows and columns.

Note: the border ‘outline’ will show in the WLW Editing Window but not in Web view.

A B C D E F G H I J K L M N
1 2 3 4 5 6 7 8 9 0 1 2 3 4
2 3 4 5 6 7 8 9 0 1 2 3 4 5
3 4 5 6 7 8 9 0 1 2 3 4 5 6

2) To change the width of a column:

a) hover the cursor pointer over the border until a moving cursor appears,

WLW065

b) click and hold the left mouse key while dragging the border to the required position.

Note: dragging borders only works with with column width and not row height.

3) To delete a table select all cells and hit the Delete key.

4) To replicate a table select all the cells and copy the table. Then position the cursor where the table is to be inserted and paste.

5) Limited formatting can be applied to the data within cells be selecting them and using the available formatting tools e.g. clear, undo, redo, bold, italics, underline, color, copy and paste.

Attaching Files

 Files can be exchanged between users by attaching them to posts.

WLW does not provide a ‘graphical’ method to attach and upload files. A work around can be used.

To attach files to a post e.g. a plain text file:

1) give the file a meaningful name

2) save the file to a local drive,

3) Login to the WordPress Admin Center and upload the plain text file,

Note: refer to Introduction To The Admin Center for details, and TBA

4) after uploading select the URL, from the Upload Sub-panel input box, right click inside the selected area to open a context menu and copy the address,

WLW072

5) return to WLW and position the cursor in the post where the link to the attached file is going to be inserted,

6) click on an Insert Hyperlink icon

The Insert Hyperlink Window will open with http:// automatically selected.

Note: when selected it will be highlighted in blue.

WLW074

7) hit the Delete key to clear the URL input box and paste in the address copied from the UKB. Then type an identifying name into the Text input box and click OK.

WLW073

8) The Insert Hyperlink box will close and a link to the file on the server will be inserted.

 Example Attachment - Plain Text File

 Note: the link is valid for any Web view, including WLW Web Preview or UKB Viewing or Previewing.

 

A file can also be attached to an image.

To attach a file to an image:

1) insert the image into the post in the normal way,

 WLW075

2) right click on the image and select Hyperlink from the context menu that opens,

WLW076

 3) type or paste the URL of the file into the input box and click OK.

WLW077

The file will be attached to the image.

To change the ‘title’ of a ‘linked image’:

1) select the image,

2) open the Advanced panel from the Properties Center that opens in the Sidebar

3) type a meaningful description for the link into the Alternate text input box

 WLW078

When the mouse is hovered over the image readers will be able to see the Alternate text message.

 click to open an attached file

Note: that material within attachments will not be included if the post is searched or printed.

MANAGING POSTS

WLW has an integrated post management system.

At installation a My Weblog Posts folder is automatically setup in My Documents. The folder contains two sub-folders; Drafts and Recent Posts. When a new post is saved as a local draft it is stored in the draft folder. When it is posted to the Weblog as a draft, or published, it is moved from the Draft folder to the Recently Posted folder.

Files can be opened or deleted by using a post browser window.

To browse post lists:

1) click on the Open icon on the Toolbar,

WLW088

 2) or open the browser from the File menu,

WLW089

The browser will open.

The number of posts listed can be set by picking a number from the Show items drop-down.

The list can be refreshed by clicking on the refresh icon.

 

Drafts can be opened or deleted from the Draft Folder by selecting Drafts in the left panel to view the and picking the required post from the list presented.

WLW090

Drafts can be opened or deleted from the Recently Posted Folder by selecting it in the left panel and picking the required post from the updated list.

Note: posts deleted from the RP folder will also be deleted from the UKB site (can’t be reinstated).

WLW091

Author owned posts can also be opened from the AUKB list - posts by other Authors are listed bit can not be opened or edited.

WLW092

Saving drafts

As writing progresses a post can be Saved as a Local Draft from the File menu.

WLW053

 Drafts can also be saved using the Save Draft icon on the toolbar.

WLW083

 

(The icon drops down to provide three options for managing drafts.)

WLW054

The status bar description will change to show that the draft has been saved.

WLW055 

The post will be saved in My Documents/Drafts and a link to the file will appear in the Open menu-box in the Sidebar.

WLW080 

Thereafter the file can be opened directly from the Sidebar link or the File Management Center. - click the link in the sidebar (the post will open directly in WLW),

Interim backups

As an interim backup, between sessions, an incomplete post can be published as a draft. (Note that the copy uploaded to the UKB server will not be visible to the public and will not be distributed with RSS Feeds).

To publish as a draft:

1) Open the post from the Drafts link in the Sidebar menu or the File Management Center,

Open the drop-down list using the Save Draft icon on the Toolbar.

WLW083

2) Select Post Draft to Weblog from the menu list. 

WLW034

3) or select Post Draft to Weblog from the File menu

WLW086

3) If Check spelling before publishing is selected in Tools > Options > Spelling the Check Spelling Window will open, provided there are spelling mistakes in the document. If there are no spelling mistakes in the document the spell-check will be completed silently and the window will not open.

WLW039

When all spelling tasks are complete the Check Spelling Window will close and the upload will proceed automatically. A dialog box to confirm that the Draft is being published will open.

 WLW038

After uploading is complete the dialog box will automatically close and a copy of the post will remain in the Editing Window.

The status bar description will change to show that the post has been saved.

WLW082

The file will be moved from the Draft folder to the Recently Posted folder and the Open menu in the sidebar will change to reflect that.

 WLW081

 

 Editing Posts

 Posts can be downloaded from the UKB site for editing locally.

To download and edit a post:

  • 1) open the post from the Recently Posted link in the Sidebar menu or the File Management Center,
  • 2) edit the post,
  • 3) re-publish the post as a draft.

WLW will follow the same procedure used when publishing a draft the first time.

Publishing Posts

The status of a post can be changed from local draft or weblog draft to published from the local computer - The procedure is the same for local drafts and weblog drafts.

To publish a draft:

1) open the post from the Sidebar link or the File Management Center

2) click on the arrow in the Set categories input box at the bottom of the WLW screen (the categories list will open),

 WLW120

3) tick the checkbox to elect the Category that the post will be filed under,

WLW018

4) select Publish from the icon on the toolbar

WLW084 

 %) or select Publish To Weblog from the File menu

WLW085

WLW will follow the same procedure used when posting a draft except that the Post Status, in the WordPress Admin Center, will be changed to Published (for additional information on Post Status refer to Introduction To The Admin Center ).

Backup

All files uploaded to the UKB server are routinely backed-up by admin.

There are two ways to make a local back-ups for those who want to take additional precautions:

1) immediately after publishing, the local ‘master’ copy remains open in the WLW editing Window. Clicking on Save Local Draft will restore a duplicate to the Draft folder. The draft copy can be backed-up and restored in the normal way.

2) a copy of the post can be made at any stage and pasted into a Word file for saving. If it becomes necessary to restore a post backed up as a Word document to the server, it can be converted to an HTML post and uploaded in the usual way. (For information on copying Word documents into WLW refer to: Converting Word Documents To Posts).

 

 ACCESSING THE WEBLOG 

 The Admin Center can be directly accessed from within WLW provided that users remain logged in.

To remain logged in to the Admin Center:

1) obtain a Username and Password from support [at] amibroker.com

2) click on the Manage Weblog link in the WLW sidebar,

WLW116

3) or click on the Weblog icon on the Toolbar,

WLW115

4) select Manage Weblog from the Weblog menu (the Login Window will open),

 WLW117

5) enter your Username and Password,

6) check Remember me,

7) then click the Login button.

WLW118

Note: the sustained login stores the logged user in a ‘cookie’ on the local computer. It may not work for those who have disabled their ‘cookies’.

Once permanently logged in, the Manage Weblog link in the Weblog menu list will take users straight to the Dashboard.

WLW119

From there users can cross to the Manage sub-panel where files can be uploaded and attached to the post. (For information on working with the Admin Center refer to: Introduction To The Admin Center and for information on uploading and attaching files refer to Quick Posting).

The Weblog can also be viewed from links within WLW. Clicking on the View Weblog link in the Weblog menu lists will open the UKB at the homepage for viewing published posts.

 

EXCEPTIONS

There are some exceptions to the rule encountered when using WLW. Authors are encouraged to join the Authors Forum to report and discuss exceptions or log them via comments attached to the posts listed under Contributors.

Exceptions noted to date:

1)  The bulleted lists ‘format’, as applied in WLW, does not work in WordPress. Unordered lists will appear as indented bulleted lists in the WLW Preview but after uploading they lose the bullets and the indents.

2) Paragraphs markers can not be turned off in WLW. Lists can be entered, but each line will be spaced, which produces a post with a ‘gappy’ appearance.

Note: the spacing default in WordPress is also larger than the default in WLW so this exacerbates this tendency.

3) Special characters e.g. <>&” and      (spacebar) are automatically converted to their HTML named entity reference by WLW. One exception is the at symbol which can become a mail: to link. (For additional information on using special characters in HTML refer to: Introduction To Editing).

4) Using code as a <tag> is standard practice in HTML editing. It has been customized for use in UKB posts and it’s use is ‘reserved’ for entering AFL formulas. At the time of writing line-space and white-space are not preserved when viewed at the UKB site, although they appear as such in the WLW initial draft.

CONCLUSION

This concludes the Introduction To WLW tutorial in which the basic procedures required to upload a post were demonstrated. Advanced techniques were not included. Other exceptions, that have not been noted at this stage, might be found in the future. Authors are welcome to experiment with advanced techniques and workarounds etc and log the outcomes via the Authors Forum, comments to the Contributor posts or write additional posts if enough new material comes to hand.

Note: experimental posts can be uploaded as a Draft to the ~Test category.

 add - workaround for formula line space and whitespace

add - error messages - Internet unavailable - post deleted on line - no permissive to edit

add - use preview to check links

add - custom code - subscript superscript etc (or refer Code Editor)

add - copy and paste link directly into WLW editing window

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Introduction to AFL

The AmiBroker Programming Language (AFL) is a very unique and powerful programming language but to use it effectively you have to understand how it works and how to properly use the AFL functions. For the newcomer to programming, this may represent a steep learning curve and it may take a little persistence to find the answers to all your questions. To write documentation on any topic that leaves no questions unanswered is an impossible task, all help documentation assumes a minimum level of familiarity with the topic studied. The problem is that this prerequisite minimum level of understanding is set by the subjective judgment of the author. The results is that, for the individual user, some topics are covered excessively while others are skimmed over because the author assumed that everybody is basically familiar with the topic. Users on the other hand often assume that their lack of knowledge is shared by all beginners and, if the Help file inadequately explains something, claim that the documentation is badly written. Of course their view is just as relative and subjective as those of the author.

This situation exist in various degrees in all documentation and cannot be prevented. The way for you to cope with this is to stay calm (there have been some heated posts on the lists) and do your own research research. If you still can’t understand something and/or can’t find the answer to your specific question you can email AmiBroker Technical Support for help or post your question on one of the AmiBroker forums:

Amibroker Users’ Group
AmiBroker Automated-Trading
AmiBroker Trading Systems
AmiBroker AFL

There are some other Yahoo forums you may want to look at, especially if you are multilingual. For a more general search targeting groups in any language click here.

If you believe your question is of general interest you can ask your question using the comment field below. But please be specific; questions like ‘How do I use AFL’ would require a book to answer and is way beyond the scope of what volunteers can contribute.

Of course we welcome your solutions to specific AFL problems, either as an author with a post (requires registration) in this category, or in the comment field below.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Introduction to Trading Systems - Management

Over a period of years you may have designed and tested hundreds of trading ideas, some may have worked a little, some were traded for awhile, and some you chucked in the waste basket. While in the end you have one or two good systems to trade, you have spend thousands of hours in development time with very little to show for it: Hundreds of system ideas are either totally lost or are tucked deep into some database where they can’t be listed by trading idea or trading principle.

This topic discusses how you can manage your research, work, and ideas to create a valuable system development resource.

… under development …

You are invited to contribute to this topic as an author with a post (requires registration) or in the comment field below.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Brian_z

Hello All,

I became an Author because of the benefits that flow from community effort.
By sharing our knowledge we can take years off the AmiBroker learning curve.

I also wanted to say thank you to Tomasz, and the the many AmiBroker users, who through their community efforts over the years have made AmiBroker what it is today . Since talk is cheap I thought this was a much better way to do that.

I’m sorry, but at this stage I can’t guarantee that I will support my posts and I would rather not receive personal mail.
I hope my posts are self-explanatory.
Please do comment where you find any errors, or see room for improvement, as I do read the comments and might incorporate changes into future versions.
Better still, if you can take the subjects I am writing about to new places, or higher levels, please do so, either by comment or post.

Initially I am writing some tutorials to help new Authors move quickly up the ‘posting’ learning curve.

As well as that, I plan to contribute a series of articles on ‘Database Management’, using Yahoo as the data ‘provider’.
This particular series is mainly orientated towards new users.
I chose this topic because it provides a good introduction into some of AmiBroker’s core features.
I used Yahoo data because it is free and universal. That is not an endorsement of it’s suitability for trading applications. On the other hand I am not advising people not to use it either. Individuals should make up their own minds on extending it’s use beyond training!

I try to write so that anyone with limited AmiBroker experience can follow the tutorials, and quickly progress to being able to perform some useful tasks. While my procedures are simplified, I hope that they don’t stop there, and that more advanced users can find something stimulating in them on occasions.

What comes after that we will have to wait and see.

You never know; I might break into a little ‘trade talking’ somewhere along the line.

As for qualifications; I believe I am only as good as my last post.
Judge my opinions on their merits; no more, no less.

If you like my work the ultimate compliment would be for you to become an Author and reciprocate the ‘giving of knowledge’.

Happy publishing and trading,

Brian.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.5 out of 5)
Loading ... Loading ...

How to make Suggestions and ask Questions

If at all possible ask your questions in a comment to a closely related post, that way it will be read by someone who knows the topic and who is most likely able to answer your question. Note that some categories have introductory posts that are especially created to provide you with an easy way to ask questions. If you cannot find a related topic you can ask your question in a comment to this post.

Please use the same method when suggesting new topics or categories. If no related topics can be found you can suggest your topic in a comment to this post.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Herman

To help you put my posts in perspective I will tell you a little about the systems I like to work on and how I prefer to trade.

Developing trading systems is just a hobby for me; I am neither a professional trader nor a professional programmer. I enjoy coding more than trading and don’t trade very much. If/when I trade, it is mostly to test some new system idea. For as long as I can remember, all the way back to my MetaStock days, I have worked with one or more partners; it motivates me to find solutions, offers stimulating discussions, and facilitates problem solving. There is a definite benefit to working as a team; diversified skills and views stimulate innovation and facilitate problem solving, I highly recommend it.

Over the years my approach to system design has changed many times; this year I worked on short-term systems with trades lasting 1-2 bars. I prefer systems that work in all timeframes, from daily bars down to about 3-minute bars.

I am a contrarian trader: I always design systems that trade against price movement. This allows me to use LMT orders exclusively, which are waiting at the market when the signal triggers. This eliminates slippage, an important factor to control in high-frequency trading. Another reason for trading LMT orders is that this is the best and perhaps the only way to obtain a close match between Backtested and Real-Trading results. I may exit on a Profit Target or Pattern Failure but never on Maximum Loss Stop. If maximum loss stops are needed, I feel that my trading system isn’t working right, requiring me to go back to the drawing board. I believe that, if you can design an entry rule, you should be able to design an exit rule.

I prefer trading portfolios or scanning the market. If you can develop a system that trades a pattern giving you nice performance but producing only 3% annual profits with 3% exposure, you may be able to increase performance 20-fold or more by scanning the market. This is where real-time trade automation gives you the edge.

In brief, here are some typical patterns that I have looked at:

1. Rare events that usually result in a correction. This would include sudden extreme price movements (for example, a spike with volume). In the daily chart capture shown below, I would aim to buy on the retrace from the low, and exit on a target or pattern failure.

2. Two- to three-bar patterns that are usually followed by a correction. This would be a slower version of the above; for example, a price move over 1 to 3 1-minute bars that retraces over a longer period. Here I would try to design the system to go Short when the pattern reverses after the long bar, and take a profit a few bars later. Long bars are worth a bit study…

3. Use one of the popular band indicators and trade at saturation levels, i.e., buy when the price touches the bottom band and sell when it touches the upper band. The chart pattern below is an example using Percent bands (Minutes). Here I would try to design the system to go Short where the High crosses the Upper Band and take a profit a few bars later.

I prefer very simple trading rules that can be coded with a few lines of code and that do not contain any optimizable parameters. Of course, even though the trading rules may be simple, this doesn’t