Specification
Parameters:
<Unique ID>
<Lot Size>
<Slippage>
<Total Positions>
<Fill>
<Specified Price>
<Specified Points>
<Specified Points 2>
Description:
First, we’ll probably need to define a <Unique ID> value for the MT4 instance that we’re starting, so that future MT4 instances that we start with different <Unique ID> values don’t interfere with previous instances.
Then we need to specify the <Lot Size>, which will set the desired size for the traded instrument.
We will also need to specify the maximum amount of <Slippage> that is accepted.
Next, we need to specify <Total Positions>, which is the total number of desired long positions, and this will place that number of BUY LMT orders starting from <Specified Price>. All the other orders will be calculated from this initial <Specified Price>.
An initial check needs to be implemented to verify if <Specified Price> is below or above the current market price.
-
If <Specified Price> is below the current market price, the following logic will be implemented:
The first BUY LMT order will be placed at <Specified Price>.
The second BUY LMT order will be placed at <Specified Price> minus <Specified Points> (ex: 20.00 points).
The third BUY LMT order will be placed at <Specified Price> minus 2X <Specified Points> (ex: 40.00 points).
The fourth BUY LMT order will be placed at <Specified Price> minus 3X <Specified Points> (ex: 60.00 points).
And so on.
Note: Each BUY LMT order can take its reference from the initial <Specified Price> or from the last order in front of it. So it could either deduct <Specified Points> x 1, <Specified Points> x 2, <Specified Points> x 3 etc. from the <Specified Price>, or always deduct <Specified Points> from the last order in front of it.
-
If <Specified Price> is above the current market price, we will use an additional parameter called <Fill>.
If <Specified Price> is higher than the current market price and the <Fill> parameter is set to "off", do not create any BUY LMT orders between the current price and <Specified Price> (i.e. above the current price and below <Specified Price>). Create only the pending BUY LMT orders that are below the current market price.
Every time a BUY LMT order gets filled, a SELL LMT order needs to be placed at <Specified Points 2> (ex: 5.00 points) above that BUY LMT price.
Every time a SELL LMT order gets filled, a BUY LMT order needs to be placed at <Specified Points 2> (ex: 5.00 points) below that SELL LMT price.
And so the cycle for that position starts again.