Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2009, 01:06 AM
Junior Member
 
Join Date: Sep 2009
Location: Malta
Posts: 24
ljuba973 is on a distinguished road
Adx ea

Hi all,

Probably this method is used in a lot of ea you saw before ... But I would like to hear if any of you can suggest me what to do about some problems I have.

Idea is simple - buy when there are conditions for it ... if price go to different direction buy twice more to earn quicker if price start to go up, and continue like that up to 4 positions. Same for sell positions.

I am closing all BUY positions if summary of their profits are > 100. Closing all SELL positions if summary of their profits are > 100. If I am close to Margin - I am closing position with biggest minus.

Problem1: If summary for BUY positions are > 100 for example - I am calling FilterOrders(OP_BUY); but sometimes that function close 1 ... 2 or 3 positions and not all ... sometimes after that function I have remaining positions. How come!? I am passing via all positions and function should close all of them, isn't it?

And also I have problem2 what to do if all 4 positions are open for example for BUY ... and price continue and continue to go down ... WHEN TO STOP LOSS ... As balance continuing to drop closer and closer to margin and earning from Sell positions are useless almost.

Thanks for your help and suggestions

Aleksandar
Attached Files
File Type: mq4 stocktestmulti.mq4 (14.4 KB, 30 views)
File Type: ex4 stocktestmulti.ex4 (14.4 KB, 5 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 10-27-2009, 07:17 PM
Junior Member
 
Join Date: Apr 2009
Posts: 13
sangmane is on a distinguished road
hi,

for problem 1:
change
for(int i=0;i<OrdersTotal();i++)
to
for(int i=OrdersTotal()-1;i>=0;i--)

suggestion for problem 2: count your maximum negatif profit, and close if losses is bigger then that value.

hope this help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 10-27-2009, 11:59 PM
Junior Member
 
Join Date: Sep 2009
Location: Malta
Posts: 24
ljuba973 is on a distinguished road
Thanks

Hi,

Thanks first of all

Problem 1: What is difference between those two ... in both versions I am processing ordertotal-1 and 0 ... ?

Problem 2: I can do that ... as I have that variable in code... but than sometimes I close something good and 'promising' But definitely that is one option.

PS: Any opinion about performances? Suggestions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 10-28-2009, 04:33 AM
Junior Member
 
Join Date: Apr 2009
Posts: 13
sangmane is on a distinguished road
Exclamation

sorry i forget to mention, the loop that should be changed is the loop in the FilterOrders function
Quote:
void FilterOrders(int alType)
{
for(int i=OrdersTotal()-1;i>=0;i--)
it's different when handling order.
let me show you:
assume you have 4 opened order named OrderA, OrderB, OrderC, OrderD.
if you use for(int i=0;i<OrdersTotal();i++), then the sequence would be
- in the order pool, index OrderA = 0, index Order B = 1,...index OrderD = 4
- at first loop, i = 0, OrderA will be closed
- now there are 3 remained opened order, ie : OrderB, OrderC, OrderD
- in the order pool, OrderB will be assigned index 0, OrderC will be assigned index 1, and OrderD will be assigned index 2
- at second loop, i = 1, OrderC will be closed!! Not OrderB as you expected
- now there are 2 remained opened order, ie: OrderB, OrderD
- OrderB will be assigned index 0, OrderD will be assigned index 1
- at third loop, i = 2, there is no opened order that has index 2, so nothing will be closed!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 10-28-2009, 04:37 AM
Junior Member
 
Join Date: Apr 2009
Posts: 13
sangmane is on a distinguished road
Quote:
- in the order pool, index OrderA = 0, index Order B = 1,...index OrderD = 4
i mean - in the order pool, index OrderA = 0, index Order B = 1,..., index OrderD = 3.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 10-28-2009, 10:06 AM
Junior Member
 
Join Date: Sep 2009
Location: Malta
Posts: 24
ljuba973 is on a distinguished road
Thanks

Hm hm hm ... I understood ... That explains a lot ... And unfortunately that means that some of my previous tries were maybe good but this loop misleaded me ...

Thanks a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 10-28-2009, 02:46 PM
Junior Member
 
Join Date: Apr 2009
Posts: 13
sangmane is on a distinguished road
hi,

i hope you've had a clear understanding about this loop. i got this from my experience when coding an EA and want to close all open orders, and face the same problem. the logic of your EA is very interesting, and problem 2 hasn't been solved yet. hope that other member could contribute their opinion. i'm just a newbee (i don't even know how to spell newbee lol) and don't have experience in live trading.

regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 10-28-2009, 04:47 PM
Junior Member
 
Join Date: Sep 2009
Location: Malta
Posts: 24
ljuba973 is on a distinguished road
Hi,

Yes, I understood and it makes sense ... But I am programer and in normaln programing when I take some set of data - they are in memory and their IDs are 'in my hands' so that loop would kill them all, but here is little bit different and handling open positions is as you explained ...

Problem 2 is still there ... and will be forever question "When is clever to stop loss on summary"

Hope somebody else will give us some input here as I think this ea is promissing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 10-28-2009, 04:49 PM
Junior Member
 
Join Date: Sep 2009
Location: Malta
Posts: 24
ljuba973 is on a distinguished road
But my EA is improved obviously a lot with this your change ... performances are much better
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 03:05 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.