The start() is the only one that is needed in order to work. This function is executed every tick is recieved in Metatrader. So you must set in this function all parameters and variables that have to be calculate at each tick and call the others functions based on it.
In CyberEA-Template, all function calls is envolved into trading hours variables.
void start(){
First piece of code of the loop: check for trade stratus and trade context:
bool tradeallowed=IsTradeAllowed();
if(!tradeallowed){
Print("Trade not allowed");
}
bool contextbusy=IsTradeContextBusy();
if (contextbusy){
Print("Trade context is busy");
}
Next part: On each tick CyberEA take the current time as value of the local variable named hour. Based on the value of hour we set the next action. On this way, if it's time to trade (we are set the trading hours in the external varialbes) . In this way if hour is equal to expiration hour the function Clean() (for close all orders) is called. If hour is between start and end hour the function CheckForSignal() (check for signal) is called. Also is called the function SearhPositions() (check for orders) and if SearchPositons() is not equal to zero the EA will call CheckForClose() (check for close). If SearchPositions() is equal to zero CheckForOpen() function (check for open) is called. Also I have to comment that TrailStop and BreakEven function will be called only if hour is between trading hours and if we have set it to true in the external variables.
int hour = Hour(); if (hour == Expiration) Clean(); if ((StartHour <= hour) && (EndHour >= hour)) {
CheckForSignal();
if (SearchPositions() != 0)
CheckForClose(); else CheckForOpen();
if (SearchPositions() != 0) {
if (UseTrailingStop == true) TrailStop();
if (UseBreakEven == true) BreakEven();
}
}
Commenting(); Commenting function is called on each tick.
}