Job finished
Specification
See attached autofib.mq5, note that the timesettings are not as needed, only whole hours can be entered, this must also be based on minutes as starting time for the Fibonacci retractement.
Usage is multiple EA’s (1xEA per Symbol) on one account!
The TP and SL can be hidden for the broker by true or false in the general settings.
Fibonacci retracement variation based on the current day and time, for example 04:45 (broker server time) start and watches from that time for highs and lows till the current time. There are 5 levels, 3 are customizable with the input settings, representing Entry, SL and TP. The EA places an position at the entry level (buy if the fibo is up (high of the fibo is later in time then low of the range) and sell if the fibo is down (low of the fibo is later in time then the high of the fibo.
The Fibonacci checks if there is a position for the symbol of the EA, if there is an position and it is in the direction of the fibonnacci no position is taken, if the position is the opposite of direction of the fibonnacci, the position will be closed and the fibonnacci places the trading position.
If the EA hits the target in money for the current symbol of the EA for the current day no further is allowed. The next day trading starts over again.
Inputs
Use Fibonacci retracement true or false; if true the Fibonacci levels are used for trading, if false no trading is allowed.
SL and TP hidden for broker, true or false, if true the SL and TP are hidden for the broker.
Timetrading start hour starthour for the trading
Timetrading start min start minutes for the trading
Time start hour start hours of the fibonacci range of the current day
Time start min start minutes of the fibonacci range of the current day
Positions close end hour time of the current day open positions should be closed
Positions delete end min time of the current day open positions should be closed
Level TP The fibolevel of the Take profit
Level Entry The fibolevel of the Entry
Level SL The fibolevel of the Stop Loss
Color Line Level 0 Sets the color of the line which marks level 0
LineType Level 0 Sets the type of the line which marks level 0
LineWidth Level 0 Sets the width of the line which marks the level 0
Color Line TP Sets the color of the line which marks the TP
LineType TP Sets the type of the line which marks the TP.
LineWidth TP Sets the width of the line which marks the TP.
Color Line Entry Sets the color of the line which marks the Entry
LineType Entry Sets the type of the line which marks the Entry.
LineWidth Entry Sets the width of the line which marks the Entry.
Color Line SL Sets the color of the line which marks the SL
LineType SL Sets the type of the line which marks the SL.
LineWidth SL Sets the width of the line which marks the SL.
Color Line Level 1 Sets the color of the line which marks level 1
LineType Level 1 Sets the type of the line which marks level 1
LineWidth Level 1 Sets the width of the line which marks the level 0
Visualization
The Fibonacci levels are visualized by lines and labels on the chart
Dynamic Lotsize calculation (per Symbol) for the current day
Lotsize are dynamic being calculated, every position the lotsize is calculated until TP is reached also the profit in money is reached. Lotsize is calculated including commission per lot and spread. If previous deal of the current day of the pair/symbol is a loss then the new trade lot size (calculated by the function) should be based on the default profit (Profit in amount plus spread plus commission) + the loss of the previous deal ( loss + commission).
Example, the account runs two EA, EURUSD and USDJPY, 1st deal EURUSD for current day is a loss of 18,- commission 2, total today -20.-. USDJPY deal 1 was a profit of 20,- commission of 2,- total +18. For the new EURUSD position it is about making up that loss of -20 and the new profit of 40+commission+spread. It should leave the profit of USDJPY out of the lot size calculation.
If the EA hits the target in money for the current symbol no further trading is allowed.
Inputs
Target profit symbol in money: … 100 target amount of profit for the current symbol in the base currency
Commission: … /1 lot input of the commission per 1 lot.
Spread: … input for the common spread of the current symbol.
Close All function
If the set target profit of the account is reached then all orders should be deleted and all positions should be closed and further trading is for the current day no longer allowed.
For example:
The current position is at a profit of 100, target is 150,- so the position is not closed yet. However, the account target profit is reached then all orders should be deleted and all positions should be closed and further trading is for the current day no longer allowed. In this case for this symbol the position is closed at 100,- profit. The next day trading starts over again.
Inputs
Target profit account in money: … 1.000 target amount of profit for the account in the base currency
Delivery as an .mq5 and ex5. file