Insert a function before any form of trade request(SL/TP/Sell/Buy) is executed

 
I tried placing my intended function at the beginning of OnTradeTransaction, but my intended function is being executed after the trade request has already been executed.
 
Jia Run Yuan: I tried placing my intended function at the beginning of OnTradeTransaction, but my intended function is being executed after the trade request has already been executed.

We are unable to read your mind or see your computer. So, please show some example code and log output, and explain your question in more detail.

 
Jia Run Yuan:
I tried placing my intended function at the beginning of OnTradeTransaction, but my intended function is being executed after the trade request has already been executed.

Of course, OnTradeTransaction() triggers after a trade request execution.

We can only execute a function before a trade request in your own code sending trade requests.