Jumat, 24 Februari 2012

Manual for TipsterTrendlines for MT4

Instead of keeping a PDF up to date, I decided to keep a blog post, its easier to update.

Files are available at these two forums;

Stevehopwoodforex.com

Forex Factory

Introduction

I wrote this EA to be able to place my manual trades easily, avoid errors, and let the computer do the repetitive tasks. If you enter trades manually this EA should help you.

I use EA robots as well, but mainly I enter manual trades based on price action. This EA can be used on the same platform as other robots, just make sure the Magic Numbers (MN) are different. This EA also used Magic Number to track, so ensure your broker let’s you use MN’s. Order comments are used but not required. Brokers such as Oanda do not let you use MN’s, and the comment field is filled out by them so be careful, run this on a demo account first to ensure it works as expected.

This document will only discuss the 2P version, the 1P is very similar.

image

Setup

Put the file into the experts folder and start (re-start) MT4. Drag it onto an open chart. At the first incoming tick the EA will draw all the lines you need to set-up your trade. There are no ticks on weekends so you may need a tick simulator for the EA to draw the lines.

The EA uses include files that are already on your system. (DLL’s were removed in version 10a).

· #include <stdlib.mqh>

· #include <stderror.mqh>

Functionality

To setup an order, you need to place the 5 lines on the chart to a valid location (Entry, Stop, Target 1, Target 2, BreakEven), then go to Expert Advisors Properties and set LimitOrder to true or false. The lines are initially drawn on the chart by the EA after the first tick is received, if you can’t see the lines then right click on the chart -> Object, and delete all of them. The EA will display the order type on the lower left of the chart, check it before you set “Live” to ‘true’ in EA Properties. Lines can be horizontal or sloped.

The EA determines the type of order based on the location of the lines relative to each other and current price. Note: If the ticket numbers (generate by MT4) are not sequential a pop up box will appear, you can select to delete the orders. If the order ticket numbers are not sequential, the EA cannot manage the trade properly.

Placing a Trade

Here’s a quick run through of how a typical trade set-up is accomplished once the EA is on the chart and MT4 is set up as described above.

1. Set up the lines.

2. Turn on the EA, EA properties à Live = “true”, LimitOrder = “true of false”

3. Price is not between the dashed blue buffer line and the blue entry line, the bottom left on the screen says “+LIVE+ …waiting. Sell Stop order set”.

4. Price is now between the two lines described above, two orders are sent to the broker (pending limit orders), and the only difference is the targets. The bottom left of the screen says “+LIVE+ <<PENDING ORDER>> Sell Stop order for 0.10 lots

5. The target for the second order is always closest to the entry, the EA takes care of this, even when you move the lines around when the trade is open. This is done so it can track the single remaining order once the first target is hit. When you have a pending order (not filled) you can drag the lines around. Note that the lines cannot be on top of each other, the EA keeps them slightly apart so you can grab them.

6. When price hits the entry line you are now in a position, you can drag the lines around. Be careful not to drag the targets or stops to close to current price or your position could be closed unexpectedly. Sometimes it’s a good idea to make Live = false and adjust the lines up, then turn it back on. You can also use the “Expert Advisor” button on the MT4 menu area.

7. A screen capture image is stored in /experts/files/ with the filename that shows the symbol, ticket number, etc so you can figure out what the trade setup was when you look at the picture in the future. Images are captured so you can review your trades later to see what you can improve upon.

8. After price hits a target one order is closed and the other is tracked by the EA as long as it is on and running. If you used horizontal lined you can turn the EA off. If you used sloping lines you need to leave it on so it will update the new order details as new bars open.

9. Once both positions are closed an image capture is stored in /experts/files/

10. To reset the EA you can just delete one of the lines, the line will be re-drawn and the EA will be ready to go again. The best method however, is to got o EA properties, “Reset”, then right click on the chart to “Objects”, CNTL A to select all, then “Delete”. Another way is to use the TipsterDelete script that will clear the screen.


LIMIT ORDERS (set in EA Properties LimitOrder true)

Buy Limit Order:

· Current price must be above the blue entry line.

· Both green target lines must be above the blue entry line.

· The red stop line must be below the blue entry line.

· The dashed red breakeven line must be above the blue entry line.

· The order will be sent when price is above the blue entry line and below the dashed blue buffer line.

· The distance between the blue entry line and the dashed blue buffer line can be set in EA Properties.

clip_image002[4]


STOP ORDERS (set in EA Properties LimitOrder false)

Sell Stop Order:

· Current price must above the blue entry line.

· Both green target lines must be below the blue entry line.

· The red stop line is above the blue entry line.

· The dashed red breakeven line is below the blue entry line

· The order will be sent when price is above the blue entry line and below the dashed blue buffer line.

· The distance between the blue entry line and the dashed blue buffer line can be set in EA Properties.

clip_image004[4]


The Break-Even Line

The BreakEven (BE) dashed red line is set to the price where you want the stop moved to breakeven, note there is an automatic breakeven offset in this EA, when price hits the dashed red line it takes the spread and doubles it. In the above chart, price needs to move up past the blue entry line and eventually to the dashed red line, at that time the orders stop will be moved to the entry price. If you don’t want to use the BE feature, put the dashed red line beyond the second target.

DANGER - Watch out for this scenario – a sell stop order is set up, looking for a break downwards. The price breaks through and we enter a position. Price climbs up then back down to the BE line. At this time the stop is moved to BE but BE is below current price, the trade is closed for a loss. I suggest always using a horizontal BE line that is placed away from any possibly entry on the current bar. Then you can walk away and check the trade progress at a later time.

clip_image006[4]

Using Magic Numbers to track your progress

The EA “out of the box” (OOTB) is set to use MagicNumber 900000 and 900001, 900000 for the first order and 900001 for the second. Whatever you choose for the MagicNumber, the next order will be MagicNumber + 1. MagicNumbers are required for this EA to function.

I use MyfxBook to track my trading progress. When I place orders on different types of set-ups I use a different MagicNumber. Here’s how I do it;

Default: 900000, if I see this on MyfxBook, I know I didn’t set the MagicNumber up and I would have to check my screen captures to see what kind of a trade it was.

1st Digit:

· 9 = TipsterTrendlines

· 8 = Tipster Trendlines straddle trade (use 9 for top line, 8 for bottom line)

2nd digit: At demand or a breakout.

· 0 = forgot to set it (default)

· 1 = Enter trade at a demand or supply level (limit order)

· 2 = Breakout trade (stop order)

3rd digit: # of take profits used, usually 2 but if I put them around the same area this would be a 1.

· 0 = forgot to set it (default)

· 1 = 1 target for both orders

· 2 = 2 target locations

4th digit: Breakeven location.

· 0 = forgot to set it (default)

· 1 = Entry, BE, Target, Target

· 2 = Entry, Target, BE, Target

· 3 = Entry, Target, Target, BE

5th digit: Sloped or horizontal lines.

· 0 = forgot to set it (default)

· 1 = horizontal

· 2 = sloped

· 3 = straddle trade horizontal

· 4 = straddle trade sloped

6th digit: Used by EA to track orders. Use zero (0).

Examples

· 900000 = forgot to set MagicNumber, don’t know what kind of trade or set-up it was, check screen captures

· 912110 = Demand/Supply, 2 targets, Entry | BE | Target | Target, horizontal lines

· 922220 = Breakout, 2 targets, Entry | Target | BE | Target, sloped lines

· 911310 = Demand/Supply, 1 target, Entry | Target | Target | BE, horizontal lines


EA Properties (F7)

This is what the properties box looks like

clip_image007[4]

Here is the code for the external user inputs. You can go into the code and set the user inputs to your defaults then press “compile”. In addition, you can remove the “extern” on any line and the user input will disappear from the properties pop up box.

clip_image008[4]

EA Properties Settings Explanation

Setting

Value

(default)

Explanation

Live

true

false

T = EA is running and will place orders and manage orders

F = EA will draw lines but will not place any new orders or manage any orders or positions

LimitOrder

true

false

T = Limit order will be placed

F = Stop order will be placed

EnterOnClose

true

false

Waits for the current candle to close before sending the order. Could help avoid false breakouts.

UseRiskManagement

true

false

Determines lot size based on account size and distance from entry to stop. This will determine the order size as if one order was being placed.

RiskPercent

Integar

(2)

Percent of account balance used in the UseRiskManagement calculation

ManualLots_Help

Note

This reminds you that the number of lots (ManualLots) will be doubled since 2 orders are being placed. So if you indicate 0.1 lots, two orders are placed at 0.1 lots, for a total for 0.2 lots.

ManualLots

Integar

(0.1)

Number of lots for each individual order.

MagicNumber

Integar

(900000)

Use a different magic number if you use the same symbol on different charts.

Place_Order_Buffer

Note

A note to remind you of the setting below

PlaceOrderBuffer

Integar

(500)

The distance from the blue entry line to the dashed blue buffer line

textcolor

Color black

Color of the on screen text.

OrderLineColor

Color blue

The color of the entry line.

Emailalert

true

false

If you set up email in options, you will get an email when an order is placed, filled, and closed.

DisableSTOPAndTARGET

true

false

Setting to true lets you place the order with just the entry line. You can also use entry and target, or entry and stop. This disables the check for the lines.

Slippage

Integar

(3)

Amount of slippage you will allow for your orders

Reset_Stop

note

If you press Q and P together on your keyboard the stop will go to the red line. This is helpful if the stop went to breakeven and you don’t want it at breakeven yet. You have to have dll’s enabled in EA properties Common tab for this to work.

ShowRiskInfo

true

false

This will show risk related information on the top left of the chart screen

ShowDebug

true

false

This will show debug messages in the experts tab

ShowInformation

true

false

This shows account information in the experts tab, such as point size, etc.

ShowInstructions

true

false

This will show brief instructions on using this EA on the screen

PrintMagicNumbers

true

false

This will print all the magicnumbers to the experts tab. Useful if your platform lost settings. For example, you can determine the magic number of specific trade by ticket number and symbol, set up TT2P and it will track the order for you.

CaptureScreenShot

true

false

When a position is entered a screen shot will be stored in /experts/files/ and again when the trade is closed. A screen shot is not saved at the first target, only at stop or second target.

TipsterDelete Script (TipsterDelete_v2.mq4)

Script Files

These files are optional; you don’t need it to run the main EA (TT1P or TT2P). Additional information is on the last page.

· TT2P_DeleteLines.mq4

This script will delete all the lines that TT2P created on the chart. Put the file in /experts/scripts/ and re-start MT4. To use it, open navigator and look for it under “scripts”, drag it onto the chart or double click it. In addition, you can right click on it, select “set hot keys” for using a keyboard shortcut, I recommend “ALT D”.

· TT2P_ALL_On_Off.mq4

Run tis script to turn the TT2P ON or OFF on all charts that it is loaded on. Be careful. I review all my charts first, for example on Sunday night after I re-boot and defrag, then turn them all on.

· TT2P_ResetStop.mq4

Run this script to reset the stop line and move the stop back to the red stop line. Under normal operation, the EA will only move the stop towards profit and won’t let you move it away unless you run this script. A pop up message will appear.

Straddles

You can set up a straddle trade using two charts with the same symbol. You need to use different magic numbers.

Back test

You can run this EA in back test mode to practice. Use visual mode and set the expert to live before you press start. Once it is started you need to slow it down or pause it to move your lines into place. You won’t have access to the expert properties during the back test. To set up the next trade, just right click on one of the lines and delete it, the expert will reset it-self.

Tick Simulator

The EA requires ticks to function so it doesn’t work very well on the weekends, the EA will only execute code when it receives an incoming tick. You can use a tick simulator such as “mt4ticker.exe”.

Definitions:

Buy Stop Order

A stop order that becomes a market order to buy a security if it rises above its current price. That is, a buy stop order is not executed so long as the security is at or below the price when the order was made, but is executed at the best available price when it rises above that order. An investor who makes a buy stop order operates on the premise that if a security rises, it will likely continue to rise. In other words, the maker of a buy stop order hopes to profit from a security's upward momentum.

Sell Stop Order

An order to a broker to sell a security if its price falls below a certain level. A sell stop order exists to stop the losses, should a security's price fall. That is, it protects against further losses. This is not a stop loss order, this order is used to enter the market.

Limit order

An order to buy a stock at or below a specified price, or to sell a stock at or above a specified price. For instance, you could tell a broker "buy me 100 shares of XYZ Corp at $8 or less" or "sell 100 shares of XYZ at $10 or better" The customer specifies a price, and the order can be executed only if the market reaches or betters that price.

Stop loss order

Used to protect your position from additional loss. For a long position, a stop order turns to a market order when price goes below the stop order value and the position is liquidated.

For further reading on order types, consult Google or your broker.

Related Posts Plugin for WordPress, Blogger...