What i need is a very simple extension of already existing code. This shall be seperated into 2 projects:
1. Chandelier Exit EA
Take the existing code which can found online for a Chandelier Exit indicator. Paste it into an EA and give me the option to set the following external: Magic number, ATR peroid, K(number of multiples). Please take into account that in short cases the EA needs to account for the spread and add it. The most important is that the EA can set the stop automatically by getting the ticket number from the open trades with a for loop or whatever. The Magic number which is an external should reflect the fact that only trades with that Magic are edited.
If you understand Python, the Formula for the Chandelier Exit :
short_period: int = 22,
long_period: int = 22,
k: int = 3,
) -> DataFrame:
Chandelier Exit sets a trailing stop-loss based on the Average True Range (ATR).
The indicator is designed to keep traders in a trend and prevent an early exit as long as the trend extends.
Typically, the Chandelier Exit will be above prices during a downtrend and below prices during an uptrend.
l = pd.Series(
ohlc["high"].rolling(window=long_period).max() - cls.ATR(ohlc, 22) * k,
s = pd.Series(
ohlc["low"].rolling(window=short_period).min() + cls.ATR(ohlc, 22) * k,
2. Multi peroid Chandelier Exit EA
The second part will be to build an other version of this EA which follows these rules:"ATR - (Average True Range) is one of the volatility indicators; the greater the value, the higher the average volatility over the specified time period (of the indicator); measured in points. Trailing by ATR in most cases allows to change the stop loss according to ("adequately", "adaptively") the price behavior type - at high volatility (visible spikes) the price is "let go", when "marking time" it is kept "tighter". The trailing uses 2 ATRs, that are supposed to have different periods - one short (e.g. 5), the other - long (e.g. 20). The calculation of the stop loss always uses the greater value of the 2 ATRs - this is done in order to prevent several low-volatility bars in a row (for example, prior to news release) from moving the stop loss too close to the current price."
In short add another Peroid which is also an extern and save it as another Version.
Under the Link:
you will find the code for part 2 called: 6. Trailing by ATR.
All rules from above also apply to this EA with the Extension.
In my opinon the only real thing you need to do is add a for loop which selctes for the Ticket number and then implement the code i referenced here. If thats not the case please explain me why in your application. And ofc i will need the sourcecode to later make some changes.