creating an amazing hedging ea
-
Hi, could you help show how to create this simple strategy into an ea using your software?
The strategy would place ONLY pending orders (buystop and sellstop), modify TP upon certain conditions, and delete opposite orders on certain conditions too, also each subsequent order will have double the lot size of the previous (almost like a martingale).
Here are the constants:
Stop loss = 30
Take Profit = 10
Lot size = 0.01
Lot size multiplier = 2Strategy: (for easier clarity, i would tagged buystops as A1, A2, etc and sellstops as B1, B2, etc)
- check if no open trades, then...
- place 2 pending orders (A1 & B1), 10 pips away from current market price, with equal lotsize of 0.01
- If A1 activates, delete B1 and replace with 2 sellstop orders (B2=10pips from A1 entry price, and B3=20pips from A1 entry price)
- If TP of A1 is hit, then delete B2 and B3 and start from step one again.
Else, - If B2 activates, modify TP of A1 to entry price, then place 2 buystop orders (A2=10 pips from B2 entry price, and A3=20pips from B2 entry price)
- If TP of B2 is hit and B3 is activated, delete A2 and A3, replace with A4=10pips from B3, and A5=20pips from B3
- If TP of B3 is hit, delete A4 and A5
this goes on until a point when the stoploss of one order would be the takeprofit of the other, and when that hapens, there would be no open trades, so the lotsize is reset as it starts allover from step one again.
pls do assist me on this...if u need any information...do let me know.
P.S. presume that spread is zero(0). so u can use the bid price for all programing. thank you.
-
http://fxdreema.com/shared/Vd8ol5Bnc
To add this to your projects, save it as .mq4 and then import it.
I could not find some pattern of this strategy, something that repeats over and over again, and that's why the project is so big (every block is used for a single purpose). Well, still some blocks can be reused by using variables (trading blocks), but nevermind...
5 groups of trades are used, which basically means that this EA will put trades and orders with 5 different magic numbers (because magic number = magic start + group number, where magic start is an input parameter which exists in all fxDreema EAs)
"Modify Variables" blocks are to hold the value intil the end of the event. Otherwise, if "(on trade) ... Open Price" is used directly into the trading blocks there is a problem because meanwhile there are other events that occur. For example, between block 6 and 9 there is another event caused by the deletion of orders in block 9, so block 9 updates "(on trade) ... Open Price" value before you reach to block 10.
I could not understand the thing about lot size, so everywhere the same lot size is used. But you can add another constant and use different lot size in every step.
For debugging purposes I choosed to start new cycle after 00:00, and this is marked with vertical line and a price label.
-
wow! thanks admin. Never really thought it would be possible to even attempt it. You've actually gotten most of it working but Its a bit tricky and am sure you can get it perfectly right with these further inputs from me.
First lets make some useful assumptions:
- Lets assume NO SPREAD, so ask is equal to bid.
- Its a hedging EA, but with some martingale function as to the lot sizing.
Now to get it right, I'll explain the strategy to you so maybe you can then translate it better into the programming.
Strategy:
Imagine you are sitting in from of the PC ready to trade manually. Your constants are:TakeProfit = 10
Stoploss = 301.You place 2 pending orders (Buystop & Sellstop), 0.01 lot size 10 pips on either side of current market price (!this is because we do not know for sure which direction price would go & we don't care either).
-
When either one activates, you immediatly delete the other, that leaves you with just one open trade, but since we are also not certain for sure that price would go in our favor and hit the TP, we decide to place 2 pending orders of multiple lot sizes on the other side, one at 10pips from the entry price of the current open trade with 2X the lot size of the open trade (0.02), and the other at 20pips from the entry price of the current open trade with 4X the lot size of the open trade (0.04).
-
So incase price instead of going directly to hit the TP of the open trade, decides to go the negative way, upon 10pips below the open price of the current trade (say A1), our 0.02 lot size pending order would be activated and if keeps going that direction, it would hit TP after 10pips, at that point our 0.04 lotsize pending order would now be activated. And if price keeps going that way, then 10pips after, it would also hit the TP of our 0.04 lotsize trade which coincidentally is also the 30 pips stoploss of our very first trade to activate, which didnt go our way. When that happens, all trades are closed, so there wouldnt be any open trades left and we start allover again, this time from the initial lot size of 0.01 and 2 pending orders 10pips on either side of price.
In summary,
Imagine it was our BUYSTOP (A1) that had activated in the first place with lot size of 0.01, then we delete the other SELLSTOP (B1) and replace it with 2 other SELLSTOPS (B2 & B3), B2 is place at 10 pips from entry price of A1 with double the lot size of A1 which is 0.02, and B3 is placed 10 pips from B2, which is 20pips from A1, with double the lot size of B2 and quadripple the lot size of A1, which is 0.04.So if things go negative on us and price goes down, when we are 10pips negative on A1, B2 would activate, and when we are 20pips negative on A1, B2 would have hit its TP of 10pips, and B3 would activate, and when we are 30pips negative on A1 which is also the stoploss of A1, B3 would have hit its TP of 10pips and ALL trades would have closed. Then the cycle can repeat itself again.
So strategically we would have lost say maybe 30 cents on A1 cos of 0.01 lotsize, but gained 20 cents on B2 cos of 0.02 lotsize, and 40 cents on B3 cos of 0.04 lot size. So when we do the maths, (40 + 20)-30 = 30 cents profit.
So even when price didnt go our initial upwards direction and lock in 10 cents profit for our 0.01 trade, we even made more profit on the reverse.Remember all trades have same 10pips takeprofit and 30pips stoploss, its the LOT SIZING that does the MAGIC.
That is why it is SO IMPORTANT that if you can program it in such a way that before a new pending order is place, it checks what the lot size of the previously opened trade is and multiplies that by 2 to get the pending order placed at 10pips, and then by 4 to get the pending order placed at 20pips.
Conclusion.
You have already done a great job cos it places the orders as it should, you just need to modify it to place the right lotsizes, and also when you study the above strategy well, you would just realize clearly that the trades cycle does not carry on forever, cos even though on quite rangy markets, our lotsizes could grow large, there must be a point when there would be no open trades, that point where the stoploss of one trade equals the tp of the second opposing pending order, and thats when the cycle should start allover again from 0.01 lotsize.Please do add this current information into the already made program you've done and lets see what the end product would be like. Thanks sooo much. Pls do ask if you need any information or further clarification. Thank you.
P.S. rather than make new cycle start by 00:00hrs, make it start immediately upon attaching EA to chart. Thank you.
-
Well, after all I'm here to help people when they have problems with the site, but I don't myself as a personal programmer
Sometimes I can decide to make some request, that's how I can experience the tool and find missing functionality for example. With this project I found that something is missing when working with trading events and I will add this fix later. But I don't want to enter the cycle of "do that for me... ok... now do that.... well done! now I want you to do something more...".But I read the last post and I think something with lot size is still missing. If B3 is 0.04, what about A4 and A5 and A2 and A3? I tried this with 0.1, 0.2, 0.4, 0.8 and 1.6 lots (my broker starts with 0.1)... when 1.6 lose, the EA is on loss. Even with no spread. So it's something missing for me, but you can find it for yourself

http://fxdreema.com/shared/bmuZngP4e
And I don't think we can assume that there is no spread, because there is. And if there is no spread (some brokers), then we have commissions... which is basically the same with other words.
Once I tried something similar, which was interesting - pending orders in grid (for example 5 above, 5 below), and when you open a trade you move the opposite orders in it's direction. I don't remember all the details, I know that I tried to use the movement of the price itself to profit, and it was profitable... until certain price movement happens and everything goes wrong (it was range movement with specific amplitude). Also the spread was a biiiig factor.
So I think we can better assume that there are no really profitable strategies that uses only mathematics. I mean... open this, cover with this, cover again... Basically strategies with the idea to crack the market. There are tons of people trying strategies like this all the time with... you know what result

-
Thanks admin, and sorry for all the "do this, do that"
, since am new to your software, i was thinking if I could have you build up one of my strategies, it would prove the full capabilities of your software, so i could then spend my time to indulge in learning how to master it, for my other projects.Been trading for over 14yrs now, and am a strategy developer, and trust me, am used to doing the "impossible", and yes, after I have done it, I benefit a lot before it becomes viral and then leads to brokers banning the strategy. A good trader or strategy developer should take all aspects of forex into consideration (fundamentals, technicals, broker, platform, force majeur) and this strategy am working on does exactly that and thats why It sounds impossible.
I did something similar to spike trading in 2003 and now spike trading is seriously frowned upon when brokers realisez traders were raking in huge profits, when a mere $100 would become over $12,000 in just about 7 spike trades, and this usually happened in the 1st week of every month, of which there were usually about 13 highly spiky trades, so u can imagine...the terror that caused for especially the "bucket shop" brokers.
this is my second EA so far, and marks the 10 aniversary of my 1st also
, so am developing another "impossible" EA... Just thought I could speed things up with your software, buh I guess I might go the long way of manual programming all over again! 
Also, yes we do pay for spread, but it is taken like the commision thing, so that keeps our bid and ask price the same, and that is very useful in EA developments.
Would have loved you to work with me on this project, cos just as you've realised, it would also point out loopholes or extra functions you would need to add to your software to really make it "tick" and stand out among the rest. You win - I win, its all win-win.
All the same, no problems, thanks so far, and I'll alert you when I finally launch the EA...or better still, you'll find out years later when it has already gone viral and brokers start disallowing pending orders...
.FxBO$$
www.lrng.com.ng -
Well, personally I'm not interested in any strategy, what I like to do is to make this website better. And the website itself is a tool for people who wants to try to build some strategies for themselves or at least to build experience. I'm currently rewriting the whole thing and there are many pending things to do, and I also have ideas for other website, so it's not in my priority to help others to build their strategies directly. You are free to try this tool, you can actually export any-size projects (after make a shared copy of it), and I will answer to every question about how to work with it. But if you want someone to program strategies for you by description, I can suggest this: http://www.mql5.com/en/job or... Google... I think there are many freelancers out there
