Forex Factory (https://www.forexfactory.com/forum.php)
-   Platform Tech (https://www.forexfactory.com/forumdisplay.php?f=69)
-   -   MT4 Order Plugin: Trade by lines with risk based lot sizing (https://www.forexfactory.com/showthread.php?t=281772)

sangmane Feb 22, 2011 11:55am | Post# 1

MT4 Order Plugin: Trade by lines with risk based lot sizing
 
6 Attachment(s)
This plugin inspired by some great scripts / tools available on FF that make trading easier.

I made this simple tool to give me the ability to specify sl/tp for new order by using mouse (dragging line object). Input sl/tp manually is a boring task, especially for lazy trader.

It also monitor existing trade sl/tp, which means it will modify existing sl/tp and open price (for pending order) when it detected a different value between order's sl/tp and the corresponding sl/tp line object.

Other feature :
- lot size calculated automatically based on the specified risk.
- a simple popup menu that allows you to quickly close an order based on ticket number

Unlike most line object based trading tools, this program doesn't use EA for monitoring lines object every tick, or a script which uses continuous looping with certain delay. It detects mouse dragging activities (hence why it uses dll) and fire the necessary script. All script will return once its job (opening new order / modifying existing orders) finished.

To use:
- download attached zip file. this zip contains 5 scripts (EasyOrder...mq4) and one EasyOrder.dll
- extract mq4 files to scripts folder, dll file to libraries folder
- attach EasyOrder to chart where you want to open new order or modifying exisiting orders
- you should only attach / run EasyOrder.mq4 scripts. Other scripts named EasyOrder_Draw, EasyOrder_Submit, EasyOrder_XXXX is companion scripts that will be run by

dll, not to be run manually

New Order
- to prepare new order, click combo box that has text "New Order", choose Buy Stop (for example)
- program will draw three lines, each of them are sl (red), open price (gold) and tp (blue). drag them to the required position.
- click submit, read progress on alert window

Modify SL/TP
- drag SL/TP line

Close Order
- click Close button, you will see a popup showing the list of order's ticket

Remove Window
- Right click on any part of the order window, on the popup menu, choose remove.

Let me know your experience with this baby

Update
2011.02.24:
- Add notification if program failed to get market watch handle
- When user drag SL/TP line, lines of closed order will be deleted
2011.02.25:
- Add new popup menu item to refresh lines (dll)
- Risk lot is editable, you can type any lot size (dll)
- Files are listed separately
2011.07.10:
- Put latest update (March 16, 2011) on the front page
2014.02.07
- Update for Build 602
2015.04.8
- Remove unused Price/SL/TP lines after script is executed.
- Add confirmation dialog
- To make sure all Easy Order script are updated properly, make sure that you remove all previous EasyOrder_XXX.xxx in script folders before installing this update.
2015.04.22
- Add option for removing confirmation dialog
- Add option for specifying number of orders
- See http://www.forexfactory.com/showthre...31#post8221631
2015.04.23
- Update EasyOrder_Draw.ex4. Now the order related lines are thinner and are already selected, thus you don't need to double click to move them.
- Add EasyOrderInd.ex4 indicator to automatically adjust TP line based on a defined Risk / Reward ratio
2015.05.01
- Update EasyOrderInd.ex4 to refresh TP line when price changed
EasyOrder_2015.04.08.zip
Click to Enlarge

Name: EasyOrderConfirmation.png
Size: 34 KB
EasyOrder_2015.04.22.zip
EasyOrder_Draw.ex4
Name:  EO_GlobalVariables.PNG
Views: 42995
Size:  10 KB
EasyOrderInd.ex4

hanover Feb 22, 2011 8:59pm | Post# 2

Let me know your experience with this baby
Nice work.

It seems that everybody is writing these visual order managers now.

sangmane Feb 23, 2011 1:26pm | Post# 3

hi hanover, thank you for your comment

newark18 Feb 23, 2011 1:29pm | Post# 4

I have been looking for this exact script. Really, this is great. I love how it calculates risk size based on SL. One less thing that i have to do. Thanks!

What does it mean when it says "invalid lot size"?

sangmane Feb 23, 2011 1:57pm | Post# 5

1 Attachment(s)
hi newark,

that's an imperfect code in my dll. you got that message if market watch window is floating. try put market watch such that it sit on navigator window. you don't have to keep it open. once market watch sit on navigator, you can close it.

let me know if it solve your problems
Click to Enlarge

Name: market watch.gif
Size: 62 KB

newark18 Feb 23, 2011 2:33pm | Post# 6

unfortunately that did not help. I tried to set it and close it but I still get that error.

sangmane Feb 23, 2011 2:38pm | Post# 7

i will try to solve that issue by adding logging function.

Natali Feb 24, 2011 3:54am | Post# 8

1 Attachment(s)
Hi sangmane,

Thanks for the great tool!
Initially it worked, but now each time it returns this error:
Name:  error.PNG
Views: 100752
Size:  14 KB
Could you please also explain how the lot size is calculated? As I see it should depend on the stop/loss level specified. What does the risk field (1.0, 1.1 etc.) mean?

Piet411 Feb 24, 2011 10:56am | Post# 9

Order lines not deleted
 
Hi Sangmane,

Thank you sharing this create tool. I have been working with it since yesterday and it saves me a lot of time. There is only thing that I would like to ask to have a look at. After the order closed by SL or TP the lines are not deleted. Can you please see if you could fix this?

Thanks in advance!

Regards,
Piet

pilotui Feb 24, 2011 11:17am | Post# 10

Very Cool
 
Nice work again!

Ok, so I already have a pre-defined way of entering trades...but I LOVE using this for moving my SL/TP's on the PENDING Orders I set in advance..instead of clunkily typing in each TP/SL for each order I can just drag and drop my pending order script with generic 20/20 SL/TP and then with your new script I can move the SL/TP easily. Also, I have always hated using the hot keys to drop the CLOSE order script onto the chart...now I just click the Close button on your awesome creation.

WAY TO GO!!

sangmane Feb 24, 2011 11:55am | Post# 11

hi pilot and piet,

finally i got positive response

btw, have you ever got error (invalid lot size, submit return error?) do you notice significant increase of cpu / memory consumption? your feedback is really appreciated.

@piet: currently there is no function to automatically delete lines belong to closed order. i'll add a new item in popup menu to update sl/tp lines

newark18 Feb 24, 2011 12:18pm | Post# 12

I love the idea and was going to pay someone to make it for me. So you saved me some time and money. Thank you!

Please let me know if you ever get to fixing that logging issue.

Piet411 Feb 24, 2011 12:52pm | Post# 13

Hi Sangemane,

I had the error 'invalid lotsize' once, but couldn't reproduce it.

Thanks for looking into the line deletion function!

Regards,
Piet

sangmane Feb 24, 2011 2:03pm | Post# 14

files updated on post #1.

@piet: to refresh lines including deleting lines that corresponding to closed order, simply drag one of the remaining lines in the chart

Piet411 Feb 24, 2011 11:00pm | Post# 15

Hi Sangmane,

Thank you for the update. I am testing it and will give my feedback.

Regards,
Piet

newark18 Feb 24, 2011 11:10pm | Post# 16

Is there a way to change the risk percentages that are provided in the drop down box? Sorry if this is a newbie question but I didn't see it in the code.

sangmane Feb 24, 2011 11:39pm | Post# 17

Is there a way to change the risk percentages that are provided in the drop down box? Sorry if this is a newbie question but I didn't see it in the code.
Risk percentage list is coded in dll, not in mq4.

Please update your dll file. If you have run EasyOrder script, you need to close MT4 to release dll file locking by MT4, and then replacing it with updated dll on post #1.

I have change drop down box style such that the risk is editable. Now you can type, for example 0.7 instead of having to choose 1.0 - 2.0 from the list.

newark18 Feb 24, 2011 11:44pm | Post# 18

Sangmane,

I truly love this contribution. This is so practical. Thank you very much.

sangmane Feb 24, 2011 11:55pm | Post# 19

Hi sangmane,

Thanks for the great tool!
Initially it worked, but now each time it returns this error:
Attachment 647917
Could you please also explain how the lot size is calculated? As I see it should depend on the stop/loss level specified. What does the risk field (1.0, 1.1 etc.) mean?
Hi natali,

I'm sorry I missed your question. Risk field means percentage of ratio of money risked to account balance. It depend on the distance between open price and sl. Currently it is assumed that your account currency is USD

Risk calculation for XXX/USD:
risk ($) = (open price - sl) x lot x 100,000
risk (%) = 100 x risk ($) / account balance
notes: sl means the price level (ie: 1.38275) not in pips distance

Risk calculation (for USD/XXX):
risk ($) = (open price - sl) x lot x 100,000 / sl
risk (%) = 100 x risk ($) / account balance

Risk calculation (for YYY/XXX):
Imo, it is impossible to accurately predict risk in advanced for crosses that are not paired vs USD. The following calc is approximation:
- There exists USD/XXX, such as USD/JPY
risk ($) = (open price - sl) x lot x 100,000 / (USD/XXX)
- There exists XXX/USD, such as GBP/USD
risk ($) = (open price - sl) x lot x 100,000 x (XXX/USD)

sangmane Feb 25, 2011 12:05am | Post# 20

Sangmane,

I truly love this contribution. This is so practical. Thank you very much.
Glad to know that
What about "invalid lot size" error? Do you still see it?


© Forex Factory