工作已完成
指定
Hello everyone,
Kindly I need an EA for forex to buy and sell based on candle properties and an indicator.
This expert advisor should check to open positions at the closing of each candle as per the set timeframe. The EA should open a buy order when there are 2 consecutive bull candles (uptrend), and opens a sell order when there are 2 consecutive bear candles (downtrend) in the specific timeframe. The EA should close open positions when either the take profit (TP) or Stop loss (SL) are reached.
However, there are some conditions to opening positions
The EA will have 1 indicator: ATR.
Below are some of the calculations that need to be calculated at the closing of each candle for the constraints with their respective abbreviations. Please use the same abbreviations to make it easier for current and future development.
- Spread (SP)
- Closing candle price (CCP): the closing price of the closing candle.
- Recent Duration (RD): duration set as a timeframe for below calculations
- Highest price (HPRD) /Highest opening or closing price/ calculated for the RD
- Lowest price (LPRD) / Lowest opening or closing price/ calculated for the RD
- Longest downtrend (LDT) / Pips / calculated for the RD
o Difference between highest value and lowest value of 1 or more consecutive red candles
(Highest high and lowest low and NOT highest open and lowest close)
- Longest uptrend (LUT) / Pips / calculated for the RD
o Difference between highest value and lowest value of 1 or more consecutive green candles (highest high and lowest low and NOT highest open and lowest close)
- Current trend range (CTR) /Pips/ calculated for all the candles before the closing candle and including the closing candle that have the same direction as the closing candle.
o For bull candles CTR = highest close of all candles in the range – lowest low of all candles in the range
o For bear candles CTR = highest high of all candles in the range – lowest close of all candles in the range
Indicator Input
- ATR: Period
General Inputs for opening positions
- Specify the timeframe
- Specify up to 6 trading pairs to look for positions
- Recent duration (RD): duration set as a timeframe for below calculations
- Max number of open positions: Set the max number of open positions at the same time
- Lot size (LS): Set the lot size for opening positions
Conditions
1. Closing candle properties
- Closing candle body size{absolute(open-close)} should be:
- {ATR(at closing candle)*2>Closing candle body size>10 pips}
- Bull closing candle upper shadow should be less than the body: (high-close) < (close-open)
- Bear closing candle lower shadow should be less than the body: (close-low) < (open-close)
- Bear candle closing price should be lower than lowest low of any of the current trend’s candles
- Bull candle closing price should be higher than highest high of any of the current trend’s candles
2. Minimum ATR
- ATR minimum (ATRMin): Set the ATRMin to 50 pips. Only open positions if ATR(calculated at closing candle)>ATRmin
3. Stop loss
- Stop loss (SL) : Calculate and set Stop loss for all open orders to = ATR(calculated at closing candle)} pips
4. Take profit
- Take profit (TP): Calculate and set the take profit for all open orders to = (2 * ATR (calculated at closing candle)) – Spread (calculated at closing candle)
- Take profit minimum (TPmin): Set the TPmin to 20 Pips. Only open positions if TP>Tpmin
5. Recent high/low
For buy orders
- CCP + TP < HPRD
- CCP > HPRD + ATR
For sell orders
- CCP – TP > LPRD
- CCP < LRPD – ATR
6. Current trend range
For buy orders
- CTR+ TP < LUT
- CTR > (LUT + ATR)
For sell orders
- CTR – TP < LDT
- CTR > (LDT - ATR)
Attached you can find some examples in order to better convey the different componenets and calculations.
Kindly use same abbreviations when defining objects to make it easier for current and future development.