• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 3:14am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:14am
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
  •  
  • Page 1 23456 9
  • Page 1 234 9
  •  
  • Post #1
  • Quote
  • First Post: Jun 17, 2013 8:21am Jun 17, 2013 8:21am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Anyone can help me..thereīs any script/EA that make this?

Imagine I have an "Open long position", and I have also a "Pending Buy" below the actual price.
What I need is a script/ea:
change the TP of the Open Order(to a price defined by me) if the Pending BUY is triggered.

my live broker as that, but itīs not MT4, there I can open "pending Orders" if other "pending order" is activated..there I can also change TP of "Open Order" if the "pending Order" is activated..

I need to do this 2 cases, if anyone can help, i apreeciate very very much!
thanks
  • Post #2
  • Quote
  • Jun 18, 2013 9:52am Jun 18, 2013 9:52am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting xandi
Disliked
Anyone can help me..thereīs any script/EA that make this? Imagine I have an "Open long position", and I have also a "Pending Buy" below the actual price. What I need is a script/ea: change the TP of the Open Order(to a price defined by me) if the Pending BUY is triggered. my live broker as that, but itīs not MT4, there I can open "pending Orders" if other "pending order" is activated..there I can also change TP of "Open Order" if the "pending Order" is activated.. I need to do this 2 cases, if anyone can help, i apreeciate very very...
Ignored

anyone? this exists? have been searching but not found..
 
 
  • Post #3
  • Quote
  • Jun 20, 2013 4:55am Jun 20, 2013 4:55am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
I've coded this and believe that it does what you want.
It doesn't matter which chart you attach it to as it is not chart dependent.
You can have an open trade with EURUSD amended when a pending order with EURJPY is triggered and with the EA attached to a AUDCHF chart if you want.
As EAs work on every tick, it is best not to attach to a chart that has little movement.

You have to input PendingTicket and OpenTicket .
These are the order numbers that appear far left on your terminal
AdjustSL and AdjustTP are the new levels that you want with your open trade. Note, they are levels, not pip values.
It is up to you to make sure that these will be relevant at the time that a pending order is triggered.
ie.
if you have a LONG trade open with EURUSD with current price of 1.3200
You have a pending order set to trigger at 1.3100
and you set the EA to change the SL on the open trade to 1.3150, the trade will not be modified and you will get error messages because the EA is trying to set a SL on a LONG trade above the price that triggered the pending order.

I've done minimal testing so please make sure that it works on demo and report any problems and any necessary adjustments.

If you attach the EA to a different chart window you can have it work on different PendingTicket and OpenTicket at the same time

I hope that you find it useful
Attached File(s)
File Type: ex4 Adjust open order when pending triggered v1.ex4   5 KB | 1,242 downloads
Please Do Not PM Me With Coding Enquiries
 
1
  • Post #4
  • Quote
  • Jun 20, 2013 7:56am Jun 20, 2013 7:56am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
I've coded this and believe that it does what you want. It doesn't matter which chart you attach it to as it is not chart dependent. You can have an open trade with EURUSD amended when a pending order with EURJPY is triggered and with the EA attached to a AUDCHF chart if you want. As EAs work on every tick, it is best not to attach to a chart that has little movement. You have to input PendingTicket and OpenTicket . These are the order numbers that appear far left on your terminal AdjustSL and AdjustTP are the new levels that you want with your...
Ignored
stand ovation

Incredible work in few time!!! you are amazing, kid!!! Love you!!!
Going to test this by night, and after weīll be in touch to feedback and sucess together!!!!till there!
Attached Image
 
 
  • Post #5
  • Quote
  • Jun 20, 2013 8:04am Jun 20, 2013 8:04am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Don't thank me until you know that it works for you
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #6
  • Quote
  • Jun 23, 2013 9:49am Jun 23, 2013 9:49am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
Don't thank me until you know that it works for you
Ignored
Sorry I havenīt give you feedback, Iīm on holidays, as soon I can test we will be in touch!
thanks
 
 
  • Post #7
  • Quote
  • Jun 23, 2013 10:04am Jun 23, 2013 10:04am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
{quote} Sorry I havenīt give you feedback, Iīm on holidays, as soon I can test we will be in touch! thanks
Ignored
Well, I posted it just before the weekend, so not expecting feedback as yet.

Don't worry, be happy
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #8
  • Quote
  • Jul 1, 2013 8:02am Jul 1, 2013 8:02am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Here's a different version.
This one will open up to 10 pending orders automatically
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.
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
AdjustTP=true or false - if true a triggered pending order will modify the TP on the original trade and all previously triggered pending orders
..................By modify, I mean that the previously opened orders will all be amended to have the same SL/TP as the triggered trade
OpenTicket is the ticket number of the original trade
AddPendingQuantity enter the number of pending orders that you want to add between 1 and 10
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, spelt correctly with the capital letter depending on what you want.
MagicLetter this enables the EA to keep track of its own orders. Make sure that the letters unique, I advise using EU for EURUSD or UJ for ..................USDJPY, easier to keep track if you are running this EA on more than one chart.


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.

Hope that this is useful. Please test it thoroughly on demo befor thinking of going live with it
Attached File(s)
File Type: ex4 Add Pending Orders v1.ex4   7 KB | 1,079 downloads
Please Do Not PM Me With Coding Enquiries
 
1
  • Post #9
  • Quote
  • Edited 5:17pm Jul 1, 2013 2:44pm | Edited 5:17pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
gumrai, going to test this night!!!! became yesterday from vacation, and I needed this on holidays and I didnīt had test it!
thanks for your effort, if you want check my thread where Iīm explainning and applying the concept mannualy, with your EA will be like a Money Machine
http://www.forexfactory.com/showthread.php?t=388919

Iīll give you feedback sooon soooon
 
 
  • Post #10
  • Quote
  • Jul 1, 2013 6:44pm Jul 1, 2013 6:44pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Hi Gumrai!! Iīm testing the 1st one, I set everything, pending order was triggered, but I canīt see on the 1st open trade the TP changing!
where do I can see it, only when price goes to that adjusted TP?
Attached Image(s) (click to enlarge)
Click to Enlarge

Name: Screenshot1.png
Size: 115 KB
Click to Enlarge

Name: Screenshot2.png
Size: 106 KB
 
 
  • Post #11
  • Quote
  • Jul 1, 2013 7:21pm Jul 1, 2013 7:21pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
Here's a different version. This one will open up to 10 pending orders automatically 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. 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...
Ignored
the idea is good, but I donīt see room to keep changing TP on parameteres...

imagine long side:
when pending order buy limit (price below the open position) is triggered, the TP of open position drop X pips, being equal to the TP of the fresh pending triggered.(in this case the 2 positions be with same TP)
AND SO ON...
If other peding buy limit below these 2 itīs triggered, the TP of the 2 previous open positions drop X pips, in order to be equal to the TP of new triggered position (in this case the 3 positions be with same TP)

when any TP is triggered, all the pendings are cancelled

I donīt use SL, so you donīt have to bother with that! thanks bro for your effort!
 
 
  • Post #12
  • Quote
  • Jul 1, 2013 7:55pm Jul 1, 2013 7:55pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
Hi Gumrai!! Iīm testing the 1st one, I set everything, pending order was triggered, but I canīt see on the 1st open trade the TP changing! where do I can see it, only when price goes to that adjusted TP? {image} {image}
Ignored
Hi,
You haven't got the EA enabled.
You should have a smiley face in the top right corner of the chart.
Click on Expert Advisors in the top toolbar and you will see the face appear.
If the face isn't smiling then click on the face to open the parameters window, click on the "common" tab and click on "Allow live trading"
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #13
  • Quote
  • Jul 1, 2013 8:33pm Jul 1, 2013 8:33pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
{quote} Hi, You haven't got the EA enabled. You should have a smiley face in the top right corner of the chart. Click on Expert Advisors in the top toolbar and you will see the face appear. If the face isn't smiling then click on the face to open the parameters window, click on the "common" tab and click on "Allow live trading"
Ignored
ahhhh ok!! I knew it!! I never used EA!!:nerd:
going test again!!

ps: I have the smile now!!!
 
 
  • Post #14
  • Quote
  • Jul 1, 2013 8:47pm Jul 1, 2013 8:47pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
{quote} the idea is good, but I donīt see room to keep changing TP on parameteres... imagine long side: when pending order buy limit (price below the open position) is triggered, the TP of open position drop X pips, being equal to the TP of the fresh pending triggered.(in this case the 2 positions be with same TP) AND SO ON... If other peding buy limit below these 2 itīs triggered, the TP of the 2 previous open positions drop X pips, in order to be equal to the TP of new triggered position (in this case the 3 positions be with same TP) when any...
Ignored
It should do what you want I think.
The EA will open pending orders and you can modify TP of the pending order in the terminal window. The point is that you don't need to input the ticket number of the pending order, so less chance of mistakes.

One thing that I will need to alter is that for the moment, you HAVE to have a SL in place on the original order.
I put the option to adjust SL and SP in the input parameters and then forgot to include them in the EA
I guess that the idea of trading without a SL is so Alien to me.
So to use it as you wish, just put a ridculous emegency stop on the original order. Otherwise, if adding buy limit orders, it will try to set the SL below zero and the pending order(s) will not be set.

I will make the necessary adjustments as /when I have time.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #15
  • Quote
  • Jul 1, 2013 9:20pm Jul 1, 2013 9:20pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Here's an image of the EA working on Gold, I set the step tight so that a few pending orders would be triggered
The blacked trade is the original trade and you can see that that trade and the 3 triggered pending orders now all have the same TP.
As I mentioned in the last post SL is set very far away

Attached Image (click to enlarge)
Click to Enlarge

Name: ava metatrader.png
Size: 112 KB


Now the next trade has triggered and the TP has been modified on the original and triggered trades

Attached Image (click to enlarge)
Click to Enlarge

Name: ava metatrader2.png
Size: 112 KB


Here you see that I have since adjusted the TP on the 1st 2 pending orders

Attached Image (click to enlarge)
Click to Enlarge

Name: ava metatrader3.png
Size: 113 KB


But note that any adjustments to the pending orders have to be logical
In this case it is not Logical too much because if the 2nd remaining pending order is triggered the TP on all the open trades will be adjusted to 1280, but if the 3rd pending order is triggered the TP's will all be adjusted down again to 1259
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #16
  • Quote
  • Jul 1, 2013 9:42pm Jul 1, 2013 9:42pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
!!very well, worked like charm the 1st one!! going to check your post and the 2nd!!
Attached Image (click to enlarge)
Click to Enlarge

Name: Screenshot1.png
Size: 86 KB
 
 
  • Post #17
  • Quote
  • Jul 1, 2013 9:48pm Jul 1, 2013 9:48pm
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
Here's an image of the EA working on Gold, I set the step tight so that a few pending orders would be triggered The blacked trade is the original trade and you can see that that trade and the 3 triggered pending orders now all have the same TP. As I mentioned in the last post SL is set very far away {image} Now the next trade has triggered and the TP has been modified on the original and triggered trades {image} Here you see that I have since adjusted the TP on the 1st 2 pending orders {image} But note that any adjustments to the pending orders...
Ignored
hmm.. going to test it!! it seems good, but for example, I usually kind of double LOT SIze of position on pending order, or choose the LOt manually...everything else seems good, or even I may use the 1st one on multiple charts...now that I can use EA, Iīm going to test deep and write here conclusions!!
Many many thanks my friend, you are a genius
 
 
  • Post #18
  • Quote
  • Jul 1, 2013 10:03pm Jul 1, 2013 10:03pm
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting xandi
Disliked
{quote} hmm.. going to test it!! it seems good, but for example, I usually kind of double LOT SIze of position on pending order, or choose the LOt manually...everything else seems good, or even I may use the 1st one on multiple charts...now that I can use EA, Iīm going to test deep and write here conclusions!! Many many thanks my friend, you are a genius
Ignored
Thanks, but hardly a genius
Hopefully will be able to tailor it to how you want it, but it will take time
Usually, what is the maximum amount of pending orders that you will set?
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #19
  • Quote
  • Jul 2, 2013 3:25am Jul 2, 2013 3:25am
  •  broketrader
  • Joined Oct 2012 | Status: Beginnner (D) | 1,650 Posts
Hi xandi, I hope you are well.

I still don't see the rules about how to enter ?

I would like to write a fully automatic EA based on your rules but need clear entry rules...
Simplicity is the Ultimate Sophistication.
 
 
  • Post #20
  • Quote
  • Jul 2, 2013 5:45am Jul 2, 2013 5:45am
  •  xandi
  • Joined Jan 2012 | Status: Loving Nature* | 3,985 Posts
Quoting Gumrai
Disliked
{quote} Thanks, but hardly a genius Hopefully will be able to tailor it to how you want it, but it will take time Usually, what is the maximum amount of pending orders that you will set?
Ignored
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..
 
 
  • Platform Tech
  • /
  • Change "Open Order TP(target)" if other pending order triggered
  • Reply to Thread
    • Page 1 23456 9
    • Page 1 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