简体   繁体   中英

How can I test every combination of a set of numbers for the highest result possible? (Python, Trading, Pine Script, TradingView)

Prerequisite notes:

I have converted my BUY/SELL Pine Script indicator into Python.

The indicator has a large number of inputs which are arranged as a neural network.

I have the historical data for back testing my indicator.

What I need:

I need to adjust the inputs and the neural network weights automatically to result the highest net profit possible.

The back testing structure has already been coded, I just need a set of equations which can automatically optimize a set of inputs on command.

If the answer is more complicated that "a set of equations", then please give a general explanation of the process I have to go through.

Thanks for you help!

I have only been coding for 4 months so please be nice... lol

Optimisation of neural network is performed by many methods, the simplest of which is stochastic gradient descent via backpropagation . Summarily, this is an iterative optimisation procedure that updates network parameters by subtracting a term proportional to the gradient of a loss with respect to each parameter until parameter convergence.

The best solution would be to use a framework like PyTorch or TensorFlow , which provide libraries that automatically compute these gradients and perform optimisation of neural networks for you, possibly with (very) high-level APIs like Keras that abstract away the details.

Alternatively, if the network itself is not already implemented in a language like Python in which frameworks are available, and if the network is very simple , the procedure would be to:

  1. Compute (analytically) the derivatives of the loss your network uses with respect to all network parameters; by recursive application of the multivariate chain rule.
  2. Iteratively update the parameters of the network according to a term proportional to this gradient for each parameter, using subsets of your whole dataset if appropriate.

This alternative solution is not desirable and you should either ask for the network code (it's likely already written in such a framework.) or re-implement it yourself in PyTorch or TensorFlow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM