Job finished
Specification
Hi, I want a pending order EA which is like this; (it will work on 5 digits platform)
I want to write a price range in the EA manually, for example for EURUSD pair 1,14400-1,14520.
Then i will choose the direction of trade; for example SELL.
The EA will divide the range into pieces. I will write how many pieces will the range be divided manually in the EA.
When price enters into the range, the EA will open trades automatically. Lot sizes will be calculated according to loss in dollars for each trade. For example i will write “50” in the total loss section of the EA, then EA should calculate the lot size according to difference between entry level and stoploss level (it will be written manually in the EA, as 30,40 or 50 pips beyond the range)
And EA close the trades according to loss or total profit in dollars as i write in the EA manually. For example; I will write Total Profit:200, Total loss:50, then EA will close all trades as total loss or total profit occurs.
EA will put all the stoplosses beyond 30-40 pips (this will be also entered manually) of the range.
An example: Lets say i defined a range in to the EA as follows:
Pair: EURUSD
Range: 1.14400-1,14520
Pieces: 3
Trade: SELL
LOSS for each trade: 25 (dollars)
Total Profit: 200 (dollars)
Present price: 1,14050
Stop loss: 40 (pips above the range because trade is SELL, if it was a BUY then it will be 40 pips below the range)
EA will divide the range in to 3 pieces and will calculate entry levels itself: 1.14520-1.14400= 120 pips.
12/3= 40 pips. (Range between trades)
The entry levels will begin from the bottom of the range because present price is below the range: then they will be as follows: 1.14400, 1.14440, and 1,14480. (If the trade was BUY and present price was above the range, then trades will begin from the top of the range of course.)
Stoploss will be 1.14560 (1.14520+40 pips=1,14560)
And lot sizes will be calculated as:
0,1562 lot SELL from 1.14400 (according to 25 dollars loss at the stoploss point-1,14560)
0,208 lot SELL from 1.14440 (according to 25 dollars loss at the stoploss point-1,14560) and
0,312 lot from 1.14480 (according to 25 dollars loss at the stoploss point-1,14560)
EA will start to open SELL trades when price comes up to 1.14400 level.
In this example our stoploss is 1,14560 (Top of the range+stoploss = 1,14520 + 40 pips=1,14560)
Lets say price hit the 1,14500 level at max then started to fall. Then, our EA has opened 3 orders;
When price comes 1.14150 level our profit will be;
102,96 USD from the trade opened at 14480 level with 0,312 lot
60,32 USD from the trade opened at 14440 level with 0,208 lot and
39,05 USD from the trade opened at 14400 level with 00,1562 lot.
Total profit is 202,33 USD.
Total profit has been written as 200 dollars ins the EA as you see above, so EA should close all trades approximately this point.
i will give some examples and explanations to help you about the EA.
An examlpe;
lets say a buy trade entry level is 1.14050 (A) and stoploss is 1.14000(B). And i want to lose 100 dollars if SL hits. Each 1 lot gets or lose 10 dollars for each 10 pip in EURUSD . Range between A and B is 1.14050-1.14000=50 pips. So, by 1 lot i will lose 50 dollars. Then the EA should open trade with 2 lots, because i write 100 dollars to Total loss.
The EA should place pending orders after i activate it.
Number of pending orders will be the same with pieces of the defined range.
For example I want to buy EURUSD between 1.14050-1.14250 range and and i want to buy in 4 pieces. I want to lose 25 dollars for each trade. I want to close trades automatically when Total profit is 200 dollars. So the EA will close the trades when it sees 200 dollars profit. EA will calculate the lot size for each trade according to 25 dollars loss.
Also present price is the price on the chart. For example now EURUSD is 1,13470. If i define a range between 1.14050-1.14250 and if i choose BUY in the EA, then EA should put buystop orders to that range. Because the present price is lower than the range. If the present price was higher than the range and i want to buy in that range than EA should place Buylimit orders to the range. Same is true if i want to SELL in a range. If the present price on the chart is lower than the range and i choose SELL in tihe EA in that range, EA should place selllimit orders to that range. If the present price on the chart is above the range that i defined and if i choose SELL on the EA, then EA should place sellstop orders in that range.
I want EA to put stoploss point of buylimit and buystop orders as “40 pips” (for example) below the minimum edge of the defined range (1.14050-1.14250). (In this example when i write “40” in the stoploss section, EA will put all buylimit and buystop orders’s stoploss to 1,14010 level, because the minimum edge of the range is 1.14050.) On the other hand, EA will put sellstop and sell limit orders’s stoploss above 40 pips of the maximum level of the range.
How many trades will be opened is not important for closing the trades. Maybe just 1 buylimit will be executed or maybe all 4 of them will be executed. This depends on the price movement. For example Price may fall from 1.14500 level to 1.14250 level and then rise to 1.14500 level again. So we will have only one trade. EA will close that trade if it sees 200 dollars profit. Or i can close it manually.
There should be a “pieces” section. For example I will write 4 in that section. Then EA will divide 1,14050-1,14250 range into 4 pieces. The difference between the edges of the range is 200 pips. So the pips between pieces will be 200/4= 50 pips. And robot will put pending orders according to that range between pieces.
For a total example; lets say present price on the chart is 1.14500 and i opened the EA and i write “upper edge of the range” as 1.14250 and “lower edge of the range” as 1.14050, choose “BUY”, write 4 in the “pieces” section, write 25 in the “loss for each trade” section, write 200 in the “total profit” section, write 40 in the “stoploss section”. Then EA will put buylimits to 1,14250, 1,14200, 1,14150 and 1,14100 levels. According to my entries EA will put stoploss level as 1.14010. EA will calculate the lot size for the first trade (1.14250) as 0,104 lot. (1.14250-1.14010=240, 25 dollars/240 pips=0,104 lot). Same as other trades. For the last trade (1.1405) lot size will be calculated as 0,625 lot. (1.14050-1.14010=40, 25 dollars/40 pips =0,625 lots)
As a result;
I want to write on the EA’s interface;
1-Range (The maximum and the minimum edges of trade area)
2-Number of pieces that the range will be divided
3-Loss for each trade
4-Totalprofit
5-Choose SELL or BUY
6-Stoploss as pips (below/above of the range)
EA will do;
1-Calculate the range as pips,
2-Define entry levels according to number of pieces
2-Calculate the lot sizes for each trade according to loss for each trade,
3- Place pending orders,
4-Put all pending orders’ stoploss to SL level (Buylimit and buystop orders’s stoploss will be below the minimum edge of the range, and selllimit and sellstop orders’s stoploss will be above the maximum edge of the range)
5-Close orders when stoploss hit or the totalprofit occurs.