Need some help with magicnumber and multiple orders

 

Hi all,


I'm quite new in coding mql4 and it goes quite well. I've build this ea (see attached file). But something will not work and that is that I want the orders work together.

Example: When 1 buy order is opened that the second one opens x pips away from order 1 and order 3 after x pips from order 2 etc. (without the trading criteria) and that the "group in total" will have one the same SL en the SL closes in steps (see code). Buy and sell groups must be separated.

Can someone explain how to open multiple positions in my EA? And can I have an explanation how magicnumber works?

Many thanks in advance!

Jason

Files:
trendea.mq4  22 kb
 
Do you need a grid-like Cushion between orders? If so, are you looking for one which is Static or Dynamic? If Dynamic, then Dynamic based on what?
 
The order must added after (let's say) 25 pips below the first order if buy, and sell above. So it must be static. The stoploss (see my EA) must be dynamic for the whole group. If one order is added the stoploss is for the whole group.
 
jssinvest:
The order must added after (let's say) 25 pips below the first order if buy, and sell above. So it must be static. The stoploss (see my EA) must be dynamic for the whole group. If one order is added the stoploss is for the whole group.

In that case let the EA place a pending trade
 
Can you help me with that? I have made this EA with a friend and we both are newbies. We did have the fist order pending but now doesn't and have direct execution. The option is build-in the code but I don't know how to change it.
 
jssinvest:
Can you help me with that? I have made this EA with a friend and we both are newbies. We did have the fist order pending but now doesn't and have direct execution. The option is build-in the code but I don't know how to change it.


Yes Yes make it easie.....

Let another do it for you.... Jobs

or learn to code Book

If I have to help you with this then it can be at Jobs

 
I didn't say you have to code it for me. But I wan't some help to learn from this. I am familiar with the job section and otherwise I had create a job! and that is not wat I want only LEARN!!!
 
jssinvest:
I didn't say you have to code it for me. But I wan't some help to learn from this. I am familiar with the job section and otherwise I had create a job! and that is not wat I want only LEARN!!!


You are asking two things **** Need some help with magicnumber and multiple orders ****

Your EA is more then 20 kB I think if you don't know how to do magicnummer or even don't trie something to get it

then how can we help you to learn .... doing this and something more (put pending trades inside it)

 
I'll give it a try to build it in by myself. But do you need a magicnumber to let the orders work together?
 
jssinvest:
I'll give it a try to build it in by myself. But do you need a magicnumber to let the orders work together?

2. What Is MagicNumber?

MQL4 Reference:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

magic - Order magic number. May be used as user defined identifier


I.e., when an order is being placed (a position is being opened), one can assign a unique number to it. This number will consequently be used to distinguish the above order from others. There is no use (or even possibility) applying this feature when trading manually, but it is really unexpendable when trading using an expert (automated trading).


Example 1: A human trader and an expert are trading in the client temrinal at the same time.
Task: The expert must trade according to its algorithm and may not do anything with positions opened manually.
Solution: The expert must assign a unique, non-zero MagicNumber to the position being opened. In future, it must manage only positions, the MagicNumber of which is equal to the preset one.

Example 2: Two experts with different algorithms are trading in the client terminal at the same time.
Task: The expert must manage only "their" orders.
Solution: Each expert must use its unique non-zero MagicNumber when opening positions. In future, they must manage only positions, the MagicNumber of which is equal to the preset one.

Example 3: Several experts, a human trader and an assisting expert realizing a non-standard Trailing Stop are operating in the client terminal simultaneously.
Task: Trading experts must work according to their algorithms and may not do anything with positions opened manually. The assisting expert that realizes Trailing Stop may modify only positions opened manually, but not those opened by other experts.
Solution: The trading experts must use unique MagicNumbers and manage only "their" positions. The assisting expert must modify only those positions having MagicNumber equal to 0.

All three examples are quite realistic, and the users could probably have set such problems for themselves. In all three cases, the MagicNumber is used to solve it. This way is not the unique one, but the easiest.

https://www.mql5.com/en/articles/1359

 
You don't need Magic Numbers when you can tell Orders apart by existing information, i.e. OrderSymbol(), Ordertype(), OrderOpenPricce(), OrderStopLoss(), OrderTakeProfit(), etc. If you have 2 EAs running on the same Symbol but different TimeFrames then you need magic Numbers . . . or 2 different EAs
Reason: