Some addendums:

In WFO training, there are no transitional trades. Open trades at the end of the period are ignored. In WFO testing, transitional trades can happen. The trade is then opened with parameters from period A and closed with parameters from period B.

For periods in days, just multiply the number of days by 1440/BarPeriod.

DETREND = TRADES corrects the result of any trade by the price difference that would result from detrending the prices.

Time periods with no trading are not included in historical data. For adding a holiday even when the market is open, you must let your script prevent trading on that day.

Bars are just time periods. Their start and end does not depend on price quotes.

All prices are used. The mid point is Price - 0.5*Spread.

The order management depends on the broker API implementation. Normally a trade is cancelled when it is not filled within a certain time period.

All order types are realized with market or limit orders. Special order types by the broker are normally not used.