Neutral networks experts (Free code) – Trading Systems – 16 August 2023
registerEA( “nn_example”, “A test EA to run neuron model for XOR(v1.0)”, [ {name: “h11”, value: 20, required: true, type: “Number”, range: [-100, 100], step: 10}, {name: “h12”, value: 20, required: true, type: “Number”, range: [-100, 100], step: 10}, {name: “b1”, value: -10, required: true, type: “Number”, range: [-100, 100], step: 10}, {name:
registerEA( "nn_example", "A test EA to run neuron model for XOR(v1.0)", [ {name: "h11", value: 20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "h12", value: 20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "b1", value: -10, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "h21", value: -20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "h22", value: -20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "b2", value: 30, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "o1", value: 20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "o2", value: 20, required: true, type: "Number", range: [-100, 100], step: 10}, {name: "b", value: -30, required: true, type: "Number", range: [-100, 100], step: 10}, ], function (context) { var account = getAccount(context, 0) var brokerName = getBrokerNameOfAccount(account) var accountId = getAccountIdOfAccount(account) var symbolName = "EUR/USD" getQuotes (context, brokerName, accountId, symbolName) }, function (context) { var h11 = getEAParameter(context, "h11") var h12 = getEAParameter(context, "h12") var b1 = getEAParameter(context, "b1") var h21 = getEAParameter(context, "h21") var h22 = getEAParameter(context, "h22") var b2 = getEAParameter(context, "b2") var o1 = getEAParameter(context, "o1") var o2 = getEAParameter(context, "o2") var b = getEAParameter(context, "b") var sigmoid = function return 1 / (1 + Math.pow(Math.E, -t)) } var nn = function (p1, p2) { return sigmoid(o1 * sigmoid(h11 * p1 + h12 * p2 + b1) + o2 * sigmoid(h21 * p1 + h22 * p2 + b2) + b) } var error = 0 error += nn(1, 1) error += 1 - nn(1, 0) error += 1 - nn(0, 1) error += nn(0, 0) setOptimizationResult(context, -error) printMessage("error: " + error + ", " + Math.round(nn(1, 1)) + " " + Math.round(nn(1, 0)) + " " + Math.round(nn(0, 1)) + " " + Math.round(nn(0, 0))) }, function (context) { })
2.
registerEA( "sample_run_neuron_model", "A test EA to run neuron model(v1.04)", [{ name: "period", value: 20, required: true, type: PARAMETER_TYPE.INTEGER, range: [1, 100] },{ name: "inputNum", value: 20, required: true, type: PARAMETER_TYPE.INTEGER, range: [1, 100] },{ name: "threshold", value: 0.3, required: true, type: PARAMETER_TYPE.NUMBER, range: [0, 1] },{ name: "takeProfit", value: 0.0001, required: true, type: PARAMETER_TYPE.NUMBER, range: [0, 100] }], function (context) { if (typeof localStorage.reservedZone == "undefined") return var reservedZone = JSON.parse(localStorage.reservedZone) if (typeof reservedZone.sample_training_neuron_model == "undefined") return context.myPerceptron = synaptic.Network.fromJSON(reservedZone.sample_training_neuron_model) var account = getAccount(context, 0) var brokerName = getBrokerNameOfAccount(account) var accountId = getAccountIdOfAccount(account) var symbolName = "EUR/USD" getQuotes (context, brokerName, accountId, symbolName) context.chartHandle = getChartHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1) var period = getEAParameter(context, "period") context.indiHandle = getIndicatorHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1, "rsi", [{ name: "period", value: period }]) }, function (context) { }, function (context) { var arrTime = getData(context, context.chartHandle, DATA_NAME.TIME) if (typeof context.currTime == "undefined") { context.currTime = arrTime[arrTime.length - 1] } else if (context.currTime != arrTime[arrTime.length - 1]) { context.currTime = arrTime[arrTime.length - 1] } else { return } var account = getAccount(context, 0) var brokerName = getBrokerNameOfAccount(account) var accountId = getAccountIdOfAccount(account) var symbolName = "EUR/USD" var period = getEAParameter(context, "period") var inputNum = getEAParameter(context, "inputNum") var threshold = getEAParameter(context, "threshold") var takeProfit = getEAParameter(context, "takeProfit") var arrRsi = getData(context, context.indiHandle, "rsi") if (inputNum + period - 1 > arrRsi.length) throw new Error("No enough data.") var input = [] for (var i = arrRsi.length - inputNum - 1; i < arrRsi.length - 1; i++) { input.push(arrRsi[i] / 100) } var result = context.myPerceptron.activate(input)[0] printMessage(result) var ask = null var bid = null var volume = 0.01 try { ask = getAsk(context, brokerName, accountId, symbolName) bid = getBid(context, brokerName, accountId, symbolName) } catch (e) { printErrorMessage(e.message) return } if (result < 0.5 - threshold) { sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUY, 0, 0, volume, ask+takeProfit, bid-3*takeProfit, "", 0, 0) } else if (result > 0.5 + threshold) { sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_SELL, 0, 0, volume, bid-takeProfit, ask+3*takeProfit, "", 0, 0) } } )
3.
registerEA( "sample_training_neuron_model", "A test EA to train neuron model(v1.03)", [{ name: "period", value: 20, required: true, type: PARAMETER_TYPE.INTEGER, range: [1, 100] },{ name: "inputNum", value: 20, required: true, type: PARAMETER_TYPE.INTEGER, range: [1, 100] },{ name: "hiddenNum", value: 50, required: true, type: PARAMETER_TYPE.INTEGER, range: [1, 100] },{ name: "diffPrice", value: 0.0001, required: true, type: PARAMETER_TYPE.NUMBER, range: [0, 10] }], function (context) { var account = getAccount(context, 0) var brokerName = getBrokerNameOfAccount(account) var accountId = getAccountIdOfAccount(account) var symbolName = "EUR/USD" context.chartHandle = getChartHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1) var period = getEAParameter(context, "period") context.indiHandle = getIndicatorHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1, "rsi", [{ name: "period", value: period }]) }, function (context) { var period = getEAParameter(context, "period") var inputNum = getEAParameter(context, "inputNum") var hiddenNum = getEAParameter(context, "hiddenNum") var arrOpen = getData(context, context.chartHandle, DATA_NAME.OPEN) var arrClose = getData(context, context.chartHandle, DATA_NAME.CLOSE) var arrRsi = getData(context, context.indiHandle, "rsi") if (arrRsi.length <= period + 1) return if (inputNum + period - 1 > arrRsi.length) throw new Error("No enough data.") Perceptron.prototype = new synaptic.Network() Perceptron.prototype.constructor = Perceptron var myPerceptron = new Perceptron(inputNum, hiddenNum, 1) var myTrainer = new synaptic.Trainer(myPerceptron) var diffPrice = getEAParameter(context, "diffPrice") var trainingSet = [] var longCount = 0 var shortCount = 0 for (var i = period - 1; i < arrRsi.length - inputNum; i++) { if (arrClose[i * inputNum + inputNum] - arrOpen[i * inputNum + inputNum] > diffPrice) { var input = [] for (var j = 0; j < inputNum; j++) { input.push(arrRsi[i * inputNum + j] / 100) } trainingSet.push({ input: input, output: [0] }) longCount++ } else if (arrOpen[i * inputNum + inputNum] - arrClose[i * inputNum + inputNum] > diffPrice) { var input = [] for (var j = 0; j < inputNum; j++) { input.push(arrRsi[i * inputNum + j] / 100) } trainingSet.push({ input: input, output: [1] }) shortCount++ } } myTrainer.train(trainingSet) if (typeof localStorage.reservedZone == "undefined") { localStorage.reservedZone = JSON.stringify({sample_training_neuron_model: myPerceptron.toJSON()}) } else { var reservedZone = JSON.parse(localStorage.reservedZone) reservedZone.sample_training_neuron_model = myPerceptron.toJSON() localStorage.reservedZone = JSON.stringify(reservedZone) } printMessage(longCount + ", " + shortCount) printMessage(JSON.stringify(trainingSet)) printMessage(JSON.stringify(myPerceptron.toJSON())) }, function (context) { } )
ReadMe….
“sample_training_neuron_model” and “sample_run_neuron_model” are two neural network-based EAs that must be used together. One cannot function without the other.
“sample_training_neuron_model” trains the model, while “sample_run_neuron_model” generates signals based on the model trained by “sample_training_neuron_model”.
To help understand how a neural network works, i have included a simple example called “nn_example”.
The algorithm implemented here is based on Synaptic, an AI framework. Tensorflow, a more advanced framework, runs convolutional neural networks. For more details on Tensorflow, refer to plugin_for_tensorflow.
This is better than fire…
Best regards.
Forex Mastery, a network of Companies specializing in the development of Strict and complex Software used in trading development and automation.
آموزش مجازی مدیریت عالی حرفه ای کسب و کار Post DBA + مدرک معتبر قابل ترجمه رسمی با مهر دادگستری و وزارت امور خارجه | آموزش مجازی مدیریت عالی و حرفه ای کسب و کار DBA + مدرک معتبر قابل ترجمه رسمی با مهر دادگستری و وزارت امور خارجه | آموزش مجازی مدیریت کسب و کار MBA + مدرک معتبر قابل ترجمه رسمی با مهر دادگستری و وزارت امور خارجه |
مدیریت حرفه ای کافی شاپ | حقوقدان خبره | سرآشپز حرفه ای |
آموزش مجازی تعمیرات موبایل | آموزش مجازی ICDL مهارت های رایانه کار درجه یک و دو | آموزش مجازی کارشناس معاملات املاک_ مشاور املاک |
- نظرات ارسال شده توسط شما، پس از تایید توسط مدیران سایت منتشر خواهد شد.
- نظراتی که حاوی تهمت یا افترا باشد منتشر نخواهد شد.
- نظراتی که به غیر از زبان فارسی یا غیر مرتبط با خبر باشد منتشر نخواهد شد.
ارسال نظر شما
مجموع نظرات : 0 در انتظار بررسی : 0 انتشار یافته : ۰