Tâche terminée
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Spécifications
I would like to have a scalping expert advisor, programmed in mql5, working based on tick data.
The program should take the Bid, Ask and Volume data of the current Tick and keep the record of the same information (Bid, Ask and Volume) of the last “TickCount” ticks (for example TickCount = 50).
If the difference between the price (Ask or Bid as described below) of the current tick and the minimum/maximum price (see below the entry details) of the last “TickCount” ticks is greater than DeltaPrice (pips), one entry condition is fulfilled.
The other condition is that the sum of volumes of the last “TickCount” ticks is greater than “VolumeLimit”.
The program will use a trailing stop, setting initially a Stop Loss at the “TrailingDistance” distance from the current price (Bid or Ask, as described below), and moving it every time when a new higher/lower price is achieved.
Parameters:
1. TickCount
2. DeltaPrice
3. VolumeLimit
4. TrailingDistance
Buy entry conditions
1. (Current Ask – the minimum Ask of the last “TickCount” ticks) > DeltaPrice
AND
2. (The sum of all Volumes of the last “TickCount” ticks) > VolumeLimit
Buy entry trailing stop
Set a trailing stop at (Current Ask – TrailingDistance)
After the position is opened, every time when (Ask– Stop Level) > TrailingDistance the Stop Level is moved at (Ask – TrailingDistance) position
Sell entry conditions
1. (The maximum Bid of the last “TickCount” ticks – Current Bid) > DeltaPrice
AND
2. (The sum of all Volumes of the last “TickCount” ticks) > VolumeLimit
Sell entry trailing stop
Set a trailing stop at (Current Bid + TrailingDistance)
After the position is opened, every time when (Stop Level - Bid) > TrailingDistance the Stop Level is moved at (Bid + TrailingDistance) position
Optimization
The expert advisor should use a customized optimization criterion, according to following formula:
(Balance) * (Max Profit Factor) * (Max Sharpe Ratio)