Expert Advisor Tutorial ~ Verify Custom Indicators

Expert Advisor Tutorial ~ Verify Custom Indicators

# Expert Advisor Tutorial ~ A useful tool to verify your custom indicators.

This expert advisor tutorial shares with you a very useful tool that help you verify whether the output data of your custom indicator are correct.

# I haven't updated my blog for several days.

I was too busy recently. I'm training my neural network and the model is based on a new algorithm.

During the backtesting, I found the data outputted by the onTick callback function and the data outputted by the deinit callback function are inconsistent even if I used the same custom indicator . So there must have been something wrong.

It took me two whole days to check the source codes(including the WEB trader 's and the custom indicator ) and finally, I concluded that the reason why the data are inconsistent is the logic of the custom indicator that I coded had a little bug and the WEB trader has no problem. The bug is very small, so I could hardly find it. I spent two days investigating it, the process was tedious and not worth doing.

I think traders would have no time to deal with it if they encountered similar issues. So I created a new tool to help advanced traders to find the little bug in case their custom indicator s weren't coded perfectly.

The tool will compare the data outputted by the onTick function with the data from the deinit function and check why and where the data are inconsistent.

# It's a simple but useful tool, still in development, but I think you can get benefit from using it.

The source code is shown below, you can refer to our Github repository to get the latest updates as well.

registerEA(
"verify_custom_indicator_and_data",
"A test EA to verify the custom indicator and the data(v1.0)",
[],
function (context) { // Init()
			var account = getAccount(context, 0)
			var brokerName = getBrokerNameOfAccount(account)
			var accountId = getAccountIdOfAccount(account)
			var symbolName = "EUR/USD"

			window.smaHandle = getIndicatorHandle(context, brokerName, accountId, symbolName, "H1", "sma", [{
			    name: "period",
			    value: 20
			}])
		},
function (context) { // Deinit()
			var arrSma = getData(context, window.smaHandle, "sma")

            console.log(arrSma.length)
            for (var i in arrSma){
            	console.log(i + ", " + arrSma[i])
            }

		},
function (context) { // OnTick()
	var arrSma = getData(context, window.smaHandle, "sma")

	if (arrSma.length == 356) {
		for (var i in arrSma){
			console.log(i + ", " + arrSma[i])
		}

	}

})

We started trading since Feb 17th, 2020. Please feel free to track our trading records.

Read More