Hello!
before i start... the disclaimer:
!!!!!! i'm really very new to coding so do not use these scripts without making very sure you are happy with the way they perform on a demo account. Test it on all of the pairs that you will ever need to use it on to make very sure for yourself that these are safe to use. They work fine on my Think Forex ECN account but i have no idea about any other brokers platforms. Use at your own discretion. !!!!!!!!!
These are my order sending scripts that i modified from another script and an indicator.
the original order script was writen by kenny hubbard and the original ADR indicator was written by Peter E.
My modded scripts send three orders with a stop loss for all three calculated as a percentage of Average Daily Range. The Stop Losses and Take Profits are added with Order Modify so these can be used with an ECN broker. the number of days ADR can be adjusted, as can the percentage of ADR for the SL.
The Total risk amount for all three orders is defined by the risk setting and is a percentage of equity.
the magnitude of order 1 accounts for 50% of the specified risk amount and orders 2 and 3 account for the other 25% and 25% respectively.
Take profit can be set as a percentage of average daily range individually for each order.
default setting=2% risk
SL = 20% of ADR(10)
TP1 = 40% of ADR(10)
TP2 = 100% of ADR(10)
TP3 = 200% of ADR(10)
if anybody with better programming chops than me can think of a way to improve these then by all means repost them in this thread.
MJL
MM Tripple-Order Scripts with ADR stops and TPs
- mlewis
- Trader
- Posts: 76
- Joined: Wed Mar 21, 2012 1:51 pm
- Location: London
MM Tripple-Order Scripts with ADR stops and TPs
You do not have the required permissions to view the files attached to this post.
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: MM Tripple-Order Scripts with ADR stops and TPs
You might want to change the tradesize test to make sure that it is at least 2*MinLot, since you later divide it by two for the second and third trades. It might also be worth making sure that in the cases where you have to go with MinLot (or 2*MinLot :>) that it isn't throwing your risk out of whack.mlewis wrote:Hello!
My modded scripts send three orders with a stop loss for all three calculated as a percentage of Average Daily Range. The Stop Losses and Take Profits are added with Order Modify so these can be used with an ECN criminal. the number of days ADR can be adjusted, as can the percentage of ADR for the SL.
The Total risk amount for all three orders is defined by the risk setting and is a percentage of equity.
the magnitude of order 1 accounts for 50% of the specified risk amount and orders 2 and 3 account for the other 25% and 25% respectively.
Take profit can be set as a percentage of average daily range individually for each order.
default setting=2% risk
SL = 20% of ADR(10)
TP1 = 40% of ADR(10)
TP2 = 100% of ADR(10)
TP3 = 200% of ADR(10)
if anybody with better programming chops than me can think of a way to improve these then by all means repost them in this thread.
MJL
I also don't understand the statement " if (i>0) {" near the beginning of the code. Since "i" is declared in the for loop earlier and set to 1, your statement will always evaluate to "true".
George
- mlewis
- Trader
- Posts: 76
- Joined: Wed Mar 21, 2012 1:51 pm
- Location: London
Re: MM Tripple-Order Scripts with ADR stops and TPs
Thanks George! I didn't think to alter the min trade size after i'd fettled with the original single order script, good idea. It's not a very neat way of dividing the risk up anyhow, bit of a bodge to make it a tripple order script but I couldn't quite work out how to do it the proper way.
I have checked how much equity is lost on numerous pairs when all three stops are hit and it does equal the risk setting, even if the lot sizes and stop distances are different. I'm also happy that it places stops where it should according to ADR.
I may have to digest the other comment a little longer since I'm not sure I understand it either.
I merely made some kind of three headed frankenstein out of a bunch of body parts with the copy&paste function, then debugged until it did what I wanted!
I really appreciate having a proper coder checking it though, thanks!
MJL
I have checked how much equity is lost on numerous pairs when all three stops are hit and it does equal the risk setting, even if the lot sizes and stop distances are different. I'm also happy that it places stops where it should according to ADR.
I may have to digest the other comment a little longer since I'm not sure I understand it either.
I merely made some kind of three headed frankenstein out of a bunch of body parts with the copy&paste function, then debugged until it did what I wanted!
I really appreciate having a proper coder checking it though, thanks!
MJL