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

Files:
 

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

 

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?

 

sorry i forget to mention, the loop that should be changed is the loop in the FilterOrders function

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!!

 

- 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.

 

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

 

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

 

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

 

But my EA is improved obviously a lot with this your change ... performances are much better