• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:51am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:51am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Oanda "Order triggered but could not be completed..." 5 replies

EA that cancels non-triggered pending orders 3 replies

script to "close open orders" and "open opposite orders" 3 replies

Close other pending order when one is triggered 0 replies

Trailing Open Order triggered EA 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 44
Attachments: Change "Open Order TP(target)" if other pending order triggered
Exit Attachments
Tags: Change "Open Order TP(target)" if other pending order triggered
Cancel

Change "Open Order TP(target)" if other pending order triggered

  • Last Post
  •  
  • 1 Page 23456 9
  • 1 Page 234 9
  •  
  • Post #21
  • Quote
  • Jul 2, 2013 6:46am Jul 2, 2013 6:46am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
{quote} Usually no more than 5, because they are separated by 100 pips,so tp is hit before 5. You can put doubling the Lot size and droping Tp X%(manual) to all a open position atm..
Ignored
OK
I am working on it, Give me some time
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #22
  • Quote
  • Jul 2, 2013 8:36am Jul 2, 2013 8:36am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
{quote} OK I am working on it, Give me some time
Ignored
hehehe!! no worries bro, we have time to put this machine rolling..itīs better to have everything clarify, so you donīt waste time coding..today Iīll put here my strategye regarding this type of scaling, you know it almost.

The perfect thing, to do it right, and since I donīt open so many pending (max 5), so the ticket itīs not a problem, the perfecti thing should be as the 1st EA you made, where we can choose the LOT Size to all the pending orders, and also we can choose the TP for the pending orders, and when:
1st pending is triggered, all TP of all the open positions at that moment changes to the TP of that pending triggered
when 2nd pending is triggered, all TP of open position ATM changes to the TP of that Pending triggered
when 3rd pending is triggered, all TP of open position ATM changes to the TP of that Pending triggered...
... you got it?

and in that way we have liberty to choose also LOT as the TP we want, other way our system is going to be rigid...

this is the perfect thing...and not forgetting that when TP is hit all the orders are cancelled!!

tell me if you have doubts!..itīs similar to your 1st EA but with the following steps, more related orders...

a grateful thanks to you Gumrai, you are preety near a Genius to me
 
 
  • Post #23
  • Quote
  • Jul 4, 2013 10:39am Jul 4, 2013 10:39am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
So here's another version. Be warned though, I have hardly been able to do any testing. Problem is when trying to test in real time, market doesn't seem to want to trigger the pending orders
So if you and maybe a few others test it on demo any problems may come to light that much quicker.

This one will open up to 5 pending orders automatically and you can input the Lot size for each pending order If Lotsize is left at zero a pending order will not be opened.
So if you only want to open 3 pending orders then you input values for LotSizePT1 to LotSizePT3 and leave LotSizePT4 and LotSizePT5 at zero

Same as before
As each pending order is triggered it will adjust the SL, TP or both of the original order and any previously triggered orders so they will all be the same, depending on whether you have set AdjustSL and AdjustTP to true or false.
It will only open pending orders in the same direction as the original trade, either stops to add to a winning position or limits to average down.
When SL or TP is hit all trades will close, and all untriggered pending orders will be deleted.

Input parameters are
AdjustSL=true or false - if true a triggered pending order will modify the SL on the original trade and all previously triggered pending orders to be the same as the triggered order
AdjustTP=true or false - if true a triggered pending order will modify the TP on the original trade and all previously triggered pending orders to be the same as the triggered order

OpenTicket is the ticket number of the original trade that you have already opened manually

Step This is the distance above or below the original trade that you want the pending orders set at. This is input as a decimal. Ie if you want ..................the distance to be 100 pips on EURUSD, you will input 0.0100
StopOrLimit enter Stop or Limit, it will accept Stop, stop, S or s and Limit, limit, L or l.
MagicLetter this enables the EA to keep track of its own orders. Make sure that the letters unique, I advise using EU or EURUSD for EURUSD or UJ or USDJPY for USDJPY, easier to keep track if you are running this EA on more than one chart. Og course, if you are using the EA more than once with a particular pair, you will have to make sure that each instance has its own unique MagicLetter.

When the pending orders are opened they will have their SL and TP at the same distance from entry as the original trade. So if the trade has a 50 pip SL, all the pending orders will have a 50 pip SL. Same with TP.
If the original buy trade entry is 1,3000 with a SL at 1,2900 and TP at 1.3100 and you set Limit with a step of 0.0050
the first pending order be set at 1.2950 with a SL at 1,2850 and TP at 1.3050. If triggered it will modify the original trade to the same SL and TP.
You can adjust entry SL and SL after they have been set.

You may get a message asking if you want to place new pending orders, only click yes if the ea has not already set pending orders.
You may get this if you change timeframes on the chart or if your platform has shut down due to a power cut or something like that.

As always, make sure that you test this properly on demo before thinking of using it on a live account.

The next thing that I will look at is giving the option to delete opened pending orders if you have made a mistake in entering the parameters. Ie, set the step at 1000 pips instead of 100 or set the Lot size at 10 instead of 0.10
Attached File(s)
File Type: ex4 Add Pending and Modify Open Trades.ex4   8 KB | 426 downloads
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #24
  • Quote
  • Jul 6, 2013 6:44am Jul 6, 2013 6:44am
  •  dinofx
  • | Joined Dec 2008 | Status: Member | 247 Posts
Thanks Gumrai,

im trying to tweak my eas to mimic your ea above; but i get a bunch of errors (im not a coder, yet). So im asking, by any chance, you will post the mq4 file ?
 
 
  • Post #25
  • Quote
  • Jul 6, 2013 8:04am Jul 6, 2013 8:04am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting dinofx
Disliked
Thanks Gumrai, im trying to tweak my eas to mimic your ea above; but i get a bunch of errors (im not a coder, yet). So im asking, by any chance, you will post the mq4 file ?
Ignored
Hi DinoFX
I wouldn't exactly call myself a coder yet. I;m trying to learn by setting myself challenges. It's made harder by the fact that I seem to have 10 thumbs and constantly looking for where I made mistakes when trying to compile the code.
The Mq4 file is very messy and has stuff like labels that are no longer used as they have been replaced with messagebox. I really need to clean it up.
Anyway, I have attached the file as it stands at the moment. I hope that you are able to follow it. Apologies as it is so messy
Attached File(s)
File Type: mq4 Add Pending and Modify Open Trades.mq4   11 KB | 583 downloads
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #26
  • Quote
  • Jul 13, 2013 9:13am Jul 13, 2013 9:13am
  •  4xPIPAHOLIC
  • Joined Aug 2009 | Status: Member | 2,576 Posts
Gumrai,

You have done an amazing job on these EA's......we are all grateful for your time, they would work perfectly on some of my strategies.

I would like to ask you something that you might even mentioned somewhere in the posts but I missed.....during the operation of the "add pending orders" ea am I able to run trades of the same pair manually that will not interact with the orders that the ea is running?
Like the ea has 6 trades opened of EURUSD and me on my side have another 2-3 manual trades opened of the same pair....let's say hedged....in the opposite direction that I will eventually close manually when I see fit? Will the "magic letter" input allow me to do that?
I hope that I am clear in my explanation....if not please do not hesitate to tell me and I will rephrase it....

Thank you
4x
 
 
  • Post #27
  • Quote
  • Jul 13, 2013 2:54pm Jul 13, 2013 2:54pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting 4xPIPAHOLIC
Disliked
Gumrai, You have done an amazing job on these EA's......we are all grateful for your time, they would work perfectly on some of my strategies. I would like to ask you something that you might even mentioned somewhere in the posts but I missed.....during the operation of the "add pending orders" ea am I able to run trades of the same pair manually that will not interact with the orders that the ea is running? Like the ea has 6 trades opened of EURUSD and me on my side have another 2-3 manual trades opened of the same pair....let's say hedged....in...
Ignored
Hi,
yes the magic letter allows the EA to keep track of its own trades and it will ignore all other trades.
Obviously give it a good test on demo and get back to me with any thoughts on how to make it better.
I will probably replace the magic letter with the more normal magic number. When I have the time I will look through it again and see if it can be improved. I was concentrating more on the other version that Xandi wanted with variable lot sizes and so this one got pushed out of mind.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #28
  • Quote
  • Jul 13, 2013 2:55pm Jul 13, 2013 2:55pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
So here's another version. Be warned though, I have hardly been able to do any testing. Problem is when trying to test in real time, market doesn't seem to want to trigger the pending orders So if you and maybe a few others test it on demo any problems may come to light that much quicker. This one will open up to 5 pending orders automatically and you can input the Lot size for each pending order If Lotsize is left at zero a pending order will not be opened. So if you only want to open 3 pending orders then you input values for LotSizePT1 to...
Ignored
bro only now I will have time to test this version and read your updates!!!! Iīll give you feedback sunday at asia session!!! you code the asked EA in 1 day, and you donīt consider as a coder!?! you are brilliant!! thanks for everything bro!

ps: i can tell you I am using the 1st you coded with many charts opened, and it works!
 
 
  • Post #29
  • Quote
  • Edited 4:04pm Jul 13, 2013 2:57pm | Edited 4:04pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
{quote} Hi, yes the magic letter allows the EA to keep track of its own trades and it will ignore all other trades. Obviously give it a good test on demo and get back to me with any thoughts on how to make it better. I will probably replace the magic letter with the more normal magic number. When I have the time I will look through it again and see if it can be improved. I was concentrating more on the other version that Xandi wanted with variable lot sizes and so this one got pushed out of mind.
Ignored
and you are right my friend!! Iīm a friend of 4xpip, he doesnīt mind to wait we finish to focus on this beautiful EA you/we are making!
 
 
  • Post #30
  • Quote
  • Jul 13, 2013 4:36pm Jul 13, 2013 4:36pm
  •  4xPIPAHOLIC
  • Joined Aug 2009 | Status: Member | 2,576 Posts
Quoting xandi
Disliked
{quote} and you are right my friend!! Iīm a friend of 4xpip, he doesnīt mind to wait we finish to focus on this beautiful EA you/we are making!
Ignored

Hey bro, I did not ask for any coding....just asked a question....
In the future....I have some thoughts in mind....
 
 
  • Post #31
  • Quote
  • Jul 13, 2013 4:38pm Jul 13, 2013 4:38pm
  •  4xPIPAHOLIC
  • Joined Aug 2009 | Status: Member | 2,576 Posts
Quoting Gumrai
Disliked
{quote} Hi, yes the magic letter allows the EA to keep track of its own trades and it will ignore all other trades. Obviously give it a good test on demo and get back to me with any thoughts on how to make it better. I will probably replace the magic letter with the more normal magic number. When I have the time I will look through it again and see if it can be improved. I was concentrating more on the other version that Xandi wanted with variable lot sizes and so this one got pushed out of mind.
Ignored

Thanks for the response Gumrai.....the letters are ok they do there job no need to change it for number.....that is totally your decision....
 
 
  • Post #32
  • Quote
  • Jul 13, 2013 9:41pm Jul 13, 2013 9:41pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting 4xPIPAHOLIC
Disliked
{quote} Thanks for the response Gumrai.....the letters are ok they do there job no need to change it for number.....that is totally your decision....
Ignored
I used the magic letter because they are easier to keep track of. When I've been working on my codes I've had quite a few running at the same time and would sometimes have the same magic number assigned to different EAs. That led to some confusion.
At the moment, the magic letter variable is only accessed when the EA initialises. It means that the EA doesn't lose track of the order ticket numbers if the platform is shut down for any reason. They are not accessed in the main body of the program and so could be deleted by the terminal if the EA is running non stop for 4 weeks or more. I will need to put in an extra bit of code to make sure that this does not happen.
I also need to instruct the EA to remove the message labels when the EA is deinitialised. These are unlikely to cause any problems, so I would rather wait and see if any other modifications are necessary before posting an updated version.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #33
  • Quote
  • Jul 14, 2013 7:07am Jul 14, 2013 7:07am
  •  4xPIPAHOLIC
  • Joined Aug 2009 | Status: Member | 2,576 Posts
Quoting Gumrai
Disliked
{quote} I used the magic letter because they are easier to keep track of. When I've been working on my codes I've had quite a few running at the same time and would sometimes have the same magic number assigned to different EAs. That led to some confusion. At the moment, the magic letter variable is only accessed when the EA initialises. It means that the EA doesn't lose track of the order ticket numbers if the platform is shut down for any reason. They are not accessed in the main body of the program and so could be deleted by the terminal...
Ignored
Very smart, in reality the letters are better.....
 
 
  • Post #34
  • Quote
  • Jul 14, 2013 11:13am Jul 14, 2013 11:13am
  •  ollaya
  • | Joined May 2012 | Status: Member | 33 Posts
Hi Gumrai,

I use the attached script to place buy and sell pending orders (see chart). and i would like to have an ea that replace every closed order( pending order triggered and TP profit reached) by the opposite trade.
say for example that i had a EU pending buy order at 1.30 and take profit at 1.302, if this order is triggered and the TP hit the EA will place a pending sell order at 1.30 and TP at 1.298 .

the other side is when i have a pending sell order at say 1.296 that got triggered and TP hit at 1.294 , the EA will place an order with a buy at 1.296 and TP at 1.298.

the script can place unlimited buy and sell pending order with predefined TP and distance between orders.
Attached Image (click to enlarge)
Click to Enlarge

Name: usdjpy-m30-lqd-markets-ltd-2.png
Size: 51 KB


i will appreciate if you can help me creating the EA.

please let me know if there is any issue.
thanks a lot
Attached File(s)
File Type: ex4 RLF_Multi-Pending_Script.5Digit (1).ex4   9 KB | 358 downloads
 
 
  • Post #35
  • Quote
  • Jul 14, 2013 4:27pm Jul 14, 2013 4:27pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting 4xPIPAHOLIC
Disliked
{quote} Hey bro, I did not ask for any coding....just asked a question.... In the future....I have some thoughts in mind....
Ignored
it was a temptive of joking! donīt take it serious!
ps: Gumrai is Top!!
http://smileys.emoticonsonly.com/emo...rophy-1302.gif
 
 
  • Post #36
  • Quote
  • Jul 14, 2013 4:36pm Jul 14, 2013 4:36pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
So here's another version. Be warned though, I have hardly been able to do any testing. Problem is when trying to test in real time, market doesn't seem to want to trigger the pending orders So if you and maybe a few others test it on demo any problems may come to light that much quicker. This one will open up to 5 pending orders automatically and you can input the Lot size for each pending order If Lotsize is left at zero a pending order will not be opened. So if you only want to open 3 pending orders then you input values for LotSizePT1 to...
Ignored
Broo, Iīve just read it and it seems better and better!! going o test it hope tonight...I think is only missing the : "if TP his hit delete all pending orders"..very good work bro!!!
 
 
  • Post #37
  • Quote
  • Jul 14, 2013 4:47pm Jul 14, 2013 4:47pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting ollaya
Disliked
Hi Gumrai, I use the attached script to place buy and sell pending orders (see chart). and i would like to have an ea that replace every closed order( pending order triggered and TP profit reached) by the opposite trade. say for example that i had a EU pending buy order at 1.30 and take profit at 1.302, if this order is triggered and the TP hit the EA will place a pending sell order at 1.30 and TP at 1.298 . the other side is when i have a pending sell order at say 1.296 that got triggered and TP hit at 1.294 , the EA will place an order with a...
Ignored
I can't make any promises at the moment as I am busy with the projects that I am working on. Everything takes me a long time because I am learning about coding as I go along.
If/when I have some spare time, I will give it some thought, but I have no idea when that may be.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #38
  • Quote
  • Jul 14, 2013 5:02pm Jul 14, 2013 5:02pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
{quote} Broo, Iīve just read it and it seems better and better!! going o test it hope tonight...I think is only missing the : "if TP his hit delete all pending orders"..very good work bro!!!
Ignored
Hi Xandi
It is included in the code, so once the original trade is closed all related pending orders will be deleted.
This should work whether TP is hit or if the trade is closed manually.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #39
  • Quote
  • Jul 14, 2013 5:06pm Jul 14, 2013 5:06pm
  •  4xPIPAHOLIC
  • Joined Aug 2009 | Status: Member | 2,576 Posts
Quoting xandi
Disliked
{quote} it was a temptive of joking! donīt take it serious! ps: Gumrai is Top!! {image}
Ignored
No worries my bro!!! I am sure he is....
 
 
  • Post #40
  • Quote
  • Jul 14, 2013 5:19pm Jul 14, 2013 5:19pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
{quote} Hi Xandi It is included in the code, so once the original trade is closed all related pending orders will be deleted. This should work whether TP is hit or if the trade is closed manually.
Ignored
perfecttt!!!!!I thought so!!many thanks ☼
 
 
  • Platform Tech
  • /
  • Change "Open Order TP(target)" if other pending order triggered
  • Reply to Thread
    • 1 Page 23456 9
    • 1 Page 234 9
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023