• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:53pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:53pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Can someone please code this EA for me? 4 replies

Can someone please help me with this code . . . . 4 replies

Can someone add a pending orders delete function to this EA 4 replies

Can Someone code an EA please? 1 reply

Can someone code this,please? 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 2
Attachments: Pending Orders EA: Can someone please code this?
Exit Attachments
Tags: Pending Orders EA: Can someone please code this?
Cancel

Pending Orders EA: Can someone please code this?

  • Post #1
  • Quote
  • First Post: Aug 15, 2013 6:11pm Aug 15, 2013 6:11pm
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
Really simple logic...

For the LONG pending orders EA:
AFTER the "Initial" LONG Position is executed at 1.3000 (example), then
2 Pending BUY LIMIT orders (A, B) is placed BELOW 1.3000
5 pending BUY STOP orders (C, D, E, F, G) is placed ABOVE 1.3000

For the SHORT pending orders EA:
AFTER the "Initial" SHORT Position is executed at 1.3000 (example), then
2 Pending SELL LIMIT orders (A, B) is placed ABOVE 1.3000
5 pending SELL STOP orders (C, D, E, F, G) is placed BELOW 1.3000

Can some coder please take a look at this...the specs are listed in the 2 posts below...simple logic...easy to understand, but hard to explain

Thanks in advance!!!
  • Post #2
  • Quote
  • Aug 15, 2013 6:13pm Aug 15, 2013 6:13pm
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
LONG ENTRIES EA input screen (user manual inputs are in BOLD font)
Position (Initial) price = 1.3000
Position (Initial) lot size = 0.1 lot
Pip Increment for each additional position = 10 pips
Stop Loss = 30 pips [0 means NO stop loss will be set on ANY order]
Take Profit = 100 pips [0 means NO take profit will be set on ANY order]
Breakeven for each position = 40 pips [0 means NO breakeven will be set on ANY order]
Position (A) lot size = 0.1 lot [0 means NO pending order for Position (A)]
Position (B) lot size = 0.1 lot [0 means NO pending order for Position (B)]
Position (C) lot size = 0.1 lot [0 means NO pending order for Position (C)]
Position (D) lot size = 0.1 lot [0 means NO pending order for Position (D)]
Position (E) lot size = 0.1 lot [0 means NO pending order for Position (E)]
Position (F) lot size = 0.1 lot [0 means NO pending order for Position (F)]
Position (G) lot size = 0.1 lot [0 means NO pending order for Position (G)]

For example:
If I typed in the values above and activate this LONG EA

  1. If current price is below 1.3000, then set a BUY STOP order at 1.3000 for Position (Initial); if current price is above 1.3000, then set a BUY LIMIT order at 1.3000 for Position (Initial); order size = 0.1 lot; take profit = 1.3100 (1.3000+100pips); stop loss = 1.2970 (1.3000-30pips); move stop loss to 1.3000 (breakeven) when price is at 1.3040 (1.3000+40pips)

Only after Position (Initial) is executed, then:

  1. Position (A) – set pending BUY LIMIT order for 0.1 lot at 1.2990 (1.3000-10pips); take profit = 1.3090 (1.2990+100pips); stop loss = 1.2970; move stop loss to 1.2990 (breakeven) when price is at 1.3030 (1.2990+40pips)
  2. Position (B) – set pending BUY LIMIT order for 0.1 lot at 1.2980 (1.2990-10pips); take profit = 1.3080 (1.2980+100pips); stop loss = 1.2970; move stop loss to 1.2980 (breakeven) when price is at 1.3020 (1.2980+40pips)
  3. Position (C) – set pending BUY STOP order for 0.1 lot at 1.3010 (1.300+10pips); take profit = 1.3110 (1.3010+100pips); stop loss = 1.2970; move stop loss to 1.3010 (breakeven) when price is at 1.3050 (1.3010+40pips)
  4. Position (D) – set pending BUY STOP order for 0.1 lot at 1.3020 (1.3010+10pips); take profit = 1.3120 (1.3020+100pips); stop loss = 1.2970; move stop loss to 1.3020 (breakeven) when price is at 1.3060 (1.3020+40pips)
  5. Position (E) – set pending BUY STOP order for 0.1 lot at 1.3030 (1.3020+10pips); take profit = 1.3130 (1.3030+100pips); stop loss = 1.2970; move stop loss to 1.3030 (breakeven) when price is at 1.3070 (1.3030+40pips)
  6. Position (F) – set pending BUY STOP order for 0.1 lot at 1.3040 (1.3030+10pips); take profit = 1.3140 (1.3040+100pips); stop loss = 1.2970; move stop loss to 1.3040 (breakeven) when price is at 1.3080 (1.3040+40pips)
  7. Position (G) – set pending BUY STOP order for 0.1 lot at 1.3050 (1.3040+10pips); take profit = 1.3150 (1.3050+100pips); stop loss = 1.2970; move stop loss to 1.3050 (breakeven) when price is at 1.3090 (1.3050+40pips)

So based on the example above, the pending orders would look like this:
Only after Position (Initial) is executed at 1.3000, then
2 Pending BUY LIMIT orders (A, B) is placed BELOW 1.3000
5 pending BUY STOP orders (C, D, E, F, G) is placed ABOVE 1.3000

 
 
  • Post #3
  • Quote
  • Aug 15, 2013 6:15pm Aug 15, 2013 6:15pm
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
SHORT ENTRIES EA input screen (user manual inputs are in BOLD font)
Position (Initial) price = 1.3000
Position (Initial) lot size = 0.1 lot
Pip Increment for each additional position = 10 pips
Stop Loss = 30 pips [0 means NO stop loss will be set on ANY order]
Take Profit = 100 pips [0 means NO take profit will be set on ANY order]
Breakeven for each position = 40 pips [0 means NO breakeven will be set on ANY order]
Position (A) lot size = 0.1 lot [0 means NO pending order for Position (A)]
Position (B) lot size = 0.1 lot [0 means NO pending order for Position (B)]
Position (C) lot size = 0.1 lot [0 means NO pending order for Position (C)]
Position (D) lot size = 0.1 lot [0 means NO pending order for Position (D)]
Position (E) lot size = 0.1 lot [0 means NO pending order for Position (E)]
Position (F) lot size = 0.1 lot [0 means NO pending order for Position (F)]
Position (G) lot size = 0.1 lot [0 means NO pending order for Position (G)]

For example: If I typed in the values above and activate this SHORT EA

  1. If current price is below 1.3000, then set a SELL LIMIT order at 1.3000 for Position (Initial); if current price is above 1.3000, then set a SELL STOP order at 1.3000 for Position (Initial); order size = 0.1 lot; take profit = 1.2900 (1.3000-100pips); stop loss = 1.3030 (1.3000+30pips); move stop loss to 1.3000 (breakeven) when price is at 1.2960 (1.3000-40pips)

Only after Position (Initial) is executed, then:

  1. Position (A) – set pending SELL LIMIT order for 0.1 lot at 1.3010 (1.3000+10pips); take profit = 1.2910 (1.3010-100pips); stop loss = 1. 3030; move stop loss to 1.3010 (breakeven) when price is at 1.2970 (1.3010-40pips)
  2. Position (B) – set pending SELL LIMIT order for 0.1 lot at 1.3020 (1.3010+10pips); take profit = 1.2920 (1.3020-100pips); stop loss = 1. 3030; move stop loss to 1.3020 (breakeven) when price is at 1.2980 (1.3020-40pips)
  3. Position (C) – set pending SELL STOP order for 0.1 lot at 1.2990 (1.3000-10pips); take profit = 1.2890 (1.2990-100pips); stop loss = 1. 3030; move stop loss to 1.2990 (breakeven) when price is at 1.2950 (1.2990-40pips)
  4. Position (D) – set pending SELL STOP order for 0.1 lot at 1.2980 (1.2990-10pips); take profit = 1.2880 (1.2980-100pips); stop loss = 1. 3030; move stop loss to 1.2980 (breakeven) when price is at 1.2940 (1.2980-40pips)
  5. Position (E) – set pending SELL STOP order for 0.1 lot at 1.2970 (1.2980-10pips); take profit = 1.2870 (1.2970-100pips); stop loss = 1. 3030; move stop loss to 1.2970 (breakeven) when price is at 1.2930 (1.2970-40pips)
  6. Position (F) – set pending SELL STOP order for 0.1 lot at 1.2960 (1.2970-10pips); take profit = 1.2860 (1.2960-100pips); stop loss = 1. 3030; move stop loss to 1.2960 (breakeven) when price is at 1.2920 (1.2960-40pips)
  7. Position (G) – set pending SELL STOP order for 0.1 lot at 1.2950 (1.2960-10pips); take profit = 1.2850 (1.2950-100pips); stop loss = 1. 3030; move stop loss to 1.2950 (breakeven) when price is at 1.2910 (1.2950-40pips)

So based on the example above, the pending orders would look like this:
Only after Position (Initial) is executed at 1.3000, then
2 Pending SELL LIMIT orders (A, B) is placed ABOVE 1.3000
5 pending SELL STOP orders (C, D, E, F, G) is placed BELOW 1.3000

 
 
  • Post #4
  • Quote
  • Edited 11:54pm Aug 21, 2013 11:27pm | Edited 11:54pm
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
FF Member LGHR was kind enough to code this Pending Order EA for me.
LGHR's code was written in the post below:
http://www.forexfactory.com/showthre...97#post6910597
Again, many thanks to LGHR for his helps!!!

I have successfully compiled the EA, and attached it below for everyone to test/modify/use.
EDIT: FYI, at the time of this post, the EA does not seem to work, as nothing is being executed and no pending orders are being placed.
Attached File(s)
File Type: mq4 Kokopelli Pending EA.mq4   5 KB | 657 downloads
 
 
  • Post #5
  • Quote
  • Aug 22, 2013 12:18am Aug 22, 2013 12:18am
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
At the time of this post, the EA does not seem to work.
Nonetheless, we're making progress. Now we have the foundation/logic in place.
Let's hope that LGHR can spare some time to make changes to his code.
In the meantime, if anyone else wants to modify the EA, please feel free to do so. The logic is described in posts 1, 2, 3 of this thread.
 
 
  • Post #6
  • Quote
  • Last Post: Aug 22, 2013 10:56pm Aug 22, 2013 10:56pm
  •  kokopelli
  • | Joined Oct 2011 | Status: Hot Member | 338 Posts
Below is the latest compiled version of LHGR code. It still doesn't work.

Here is another attempt at explaining the logic of the EA. I'm hoping that it will make better sense.

I'm looking at my charts to determine whether to go long or short.
1) Let's say my charts said...go LONG and I would like PositionInitialPrice = 1.2010
2) Let's say that the current price is at 1.2000
3) I open this EA and type in PositionInitialPrice = 1.2010 (along with the Size, SL, TP, Increment, Breakeven)
4) This EA sees that current price < PositionInitialPrice, it will place a BUY-STOP to buy at 1.2010 (if current price > PositionInitialPrice, it will place a BUY-LIMIT order)
5) ONLY AFTER PositionInitialPrice is executed...this means that current price is at 1.2010, then this EA will place 2 pending buy orders BELOW 1.2010, and 5 pending buy orders ABOVE 1.2010
6) The 2 pending buy orders BELOW 1.2010 will be BUY-LIMIT orders
7) The 5 pending buy orders ABOVE 1.2010 will be BUY-STOP orders

Here's an example if my charts said to go short.
1) Let's say my charts said...go SHORT and I would like PositionInitialPrice = 1.2010
2) Let's say that the current price is at 1.2000
3) I open this EA and type in PositionInitialPrice = 1.2010 (along with the Size, SL, TP, Increment, Breakeven)
4) This EA sees that current price < PositionInitialPrice, it will place a SELL-LIMIT to short at 1.2010 (if current price > PositionInitialPrice, it will place a SELL-STOP order)
5) ONLY AFTER PositionInitialPrice is executed...this means that current price is at 1.2010, then this EA will place 2 pending short orders ABOVE 1.2010, and 5 pending short orders BELOW 1.2010
6) The 2 pending short orders ABOVE 1.2010 will be SELL-LIMIT orders
7) The 5 pending short orders BELOW 1.2010 will be SELL-STOP orders
Attached File(s)
File Type: mq4 Kokopelli Pending EA.mq4   5 KB | 689 downloads
 
 
  • Platform Tech
  • /
  • Pending Orders EA: Can someone please code this?
  • Reply to Thread
0 traders viewing now
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