Specification
I have two EAs and these EAs works nearly as i want, but i
need some developments and fixing.
The first one
“pending order EA”: on this EA I write as input manually before running
EA
a price range,
number of pieces that the range will be divided
loss for each trade
total profit
stoploss as x pips below/above the range
Then the EA places pending orders on the divided levels. It calculates the lot sizes automatically according to “loss for each trade” and “stoploss; x pips below/above the range” inputs. And takes profit when “total profit” reach the amount written as input.
The second one “overandunder EA”:
This EA finds a high (point D) according to zigzag parameters, then looks x bars back for a horizontally closest lower zigzag high (point B) then marks the lowest point between these points as point C, then if price breaks point C after point D; EA marks the next zigzag low as point E and if price goes again near 40 pips (5 digit platform) to point B it marks that level as point F.
Then EA measures the legs between these points and compare the legs according to their length and duration. If the pattern is compatible with the leg inputs, EA divide the range into number of pieces according to input. Then calculated piece levels becomes our trade entry levels. EA starts to open trades at the test of first high level (point B). Then continue to open trades at the divided piece levels as price moves in the range.
EA puts stoploss x pips above/below of the range, then calculates the lot size according to “loss for each trade” input. In other words, we write x pips stoploss and loss for each trade as input manually before running the EA, then EA finds entry point and calculates the lot size according to these datas.
There are two options for taking profit which should be chosen before running EA. “Total profit” or “take profit level”. Total profit is, as the name suggests, If i write 200 dollars to the total profit section on the input screen, EA should close the trades when total profit becomes 200 dollars on a pattern. But this code closes every trade when total profit becomes 200 dollars. This is not pattern based. First we should fix this. The second option for taking profit is “take profit level”. EA calculates the length as in pips between E and F points and takes profit when price comes to the defined percentage of EF leg.
What I need is EA to open opposite trades when these trades hits stoploss. On the first example above, if price hits stoploss, i want EA to open BUY trades. And that buy trades’ conditions are explained below:
If my first trades are sell according to pattern and if they hit stoploss, i want to be a buyer automatically, right on time of stop or at retest of range. if my first trade is buy and if it stops i want to be a seller automatically, a) right on time of stop or b) at retest of range.
For pending order EA;
We need to add an option like this;
If the trades stops, EA will open trades on the opposite direction instantly or at the retest of the range.
And that trades will have range, entry, take profit and stoploss inputs as follows;
Entry: We will again divide the range so we will have number of pieces. (Input: “number of pieces2”)
Range options; 1- same range of first orders (if I want opposite trades to be opened on the retest of the range), 2-larger range: the range between stoploss point of first orders and the far point of the first range (if I want opposite trades to be opened instantly by hitting stoploss of first trades.)
In the first option EA will wait for retesting of the first defined range and open opposite trades in the same zone. In the second option EA will open opposite trades instantly and will continue to open opposite trades until the far point of the first zone.
Take profit options2;
total profit2: x times of the previous stoploss amount: (If it opens 4 trades and stoploss for each trade was 25 dollars, there will be 100 dollars loss in total and if i write 2 in the totalprofit2 input than total profit2 will be calculated as 200 dollars on the opposite trades. EA will close opposite trades when total profit becomes 200 dollars on a pattern.)
take profit level2: “x times of the stoploss range” For example, if stoploss is 15 pips far from entry point and if we write “take profit level2” as 2 times of stoploss range, than our tp level is 30 pips from entry point. and if one of the trades on a pattern takes profit than other trades in that pattern should be canceled or closed.
Stoploss point2 : A) X pips beyond the far point of the range or B) x pips beyond E point or C) x pips beyond C point
So in the overandender EA there will be 3 options for stoploss point2 input. In the pending order EA we will have only “X pips beyond the far point of the range” for stoploss point2 input.
Loss for each trade2: x times of the first trades’ loss for each trade. (If loss for each trade was 25 dollars in the first trades and if i write 2 on the “Loss for each trade2” input than loss for each opposite trade will be 50 dollars. Lot sizes will be calculated automatically according to stoploss point2 and loss for eachtrade2
So we should write inputs for opposite trades as follows:
1-Range Option: Same range or Larger Range
2-Take profit condition: Totalprofit or take profit level
2-a) Total Profit2: x times of the previous total stoploss amount
2-b) Take profit level2: x times of the stoploss range
3-Stoploss point2:
3-a)Stoploss: X pips beyond far point of the range
3-b)stoploss x pips beyond E point (only for overandunderEA )
3-c)stoploss x pips beyond C point (only for overandunderEA )
4-Loss for each trade2: x times of the first trades’ loss for each trade.
5-number of pieces2
Also, our overandunder EA in the totalprofit option closes all trades in all patterns when defined total profit amount occurs. But this should be pattern based. ıt should look for total profit of trades for each pattern independently.