Masters Indicators Upgrade
This commit is contained in:
1 parent
01175c1232
commit
b5444d6c77
3 files changed
+159
-72
No files matched your search
@@ -610,7 +610,7 @@ function newTaskFunctions() {
|
||||
}
|
||||
}
|
||||
}
|
||||
processInstance.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
processInstance.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_90
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"type":"Data Mine","name":"Masters","config":"{\n\"codeName\": \"Masters\"\n}","sensorBots":[{"type":"Sensor Bot","name":"Exchange Raw Data","config":"{\n\"codeName\": \"Exchange-Raw-Data\",\n\"repo\": \"Exchange-Raw-Data-Sensor-Bot\"\n}","processes":[{"type":"Process Definition","name":"Historic-OHLCVs","config":"{\n \"codeName\": \"Historic-OHLCVs\",\n \"description\": \"Retrieves and saves historical maket data\",\n \"startMode\": {\n \"noTime\": {\n \"run\": \"true\"\n },\n \"fixedInterval\": {\n \"run\": \"false\",\n \"interval\": 0\n }\n },\n \"deadWaitTime\": 0,\n \"normalWaitTime\": 60000,\n \"retryWaitTime\": 10000\n}","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[],"id":"dfe2556e-a765-4e38-9d30-7f91090c0069","savedPayload":{"position":{"x":19694.65896528582,"y":18079.80666168302},"targetPosition":{"x":19674.617425695335,"y":18486.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"processDependencies":{"type":"Process Dependencies","name":"New Process Dependencies","statusDependencies":[{"type":"Status Dependency","name":"Exchange Raw Data Historic-OHLCVs","config":"{\n \"mainUtility\": \"Self Reference\"\n}","id":"ea39c98b-18e2-44ce-9f7f-86a8a76a688a","savedPayload":{"position":{"x":20111.534021268813,"y":17814.56375630177},"targetPosition":{"x":19893.316491438505,"y":18150.31980838774},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e"}}}],"dataDependencies":[],"dataMineDataDependencies":[],"id":"5c7fae5a-6da6-4864-a167-f2f21d578c72","savedPayload":{"position":{"x":19893.316491438505,"y":18150.31980838774},"targetPosition":{"x":19674.617425695335,"y":18486.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"statusReport":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e","savedPayload":{"position":{"x":20031.71582860312,"y":18304.406526432995},"targetPosition":{"x":19674.617425695335,"y":18486.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionStartedEvent":{"type":"Execution Started Event","name":"","id":"957e7e3a-b167-40be-93b5-9ba4ceff56e5","savedPayload":{"position":{"x":20075.30856507894,"y":18506.680081128765},"targetPosition":{"x":19674.617425695335,"y":18486.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionFinishedEvent":{"type":"Execution Finished Event","name":"New Execution Finished Event","id":"fe40a546-43ee-49df-908a-7e72f598f0cd","savedPayload":{"position":{"x":20019.51506449239,"y":18694.64493952324},"targetPosition":{"x":19674.617425695335,"y":18486.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc","savedPayload":{"position":{"x":19674.617425695335,"y":18486.33639924593},"targetPosition":{"x":19278.707614323983,"y":18688.55263969416},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"products":[{"type":"Product Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","datasets":[{"type":"Dataset Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","id":"fbb7c17e-a909-4fa2-b3c5-eb8ca86297c4","savedPayload":{"position":{"x":19939.732540593195,"y":18584.456194349146},"targetPosition":{"x":19741.31504137297,"y":18616.06022300575},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"38dbb942-a15b-450b-a867-02a94030965f","savedPayload":{"position":{"x":19741.31504137297,"y":18616.06022300575},"targetPosition":{"x":19278.707614323983,"y":18688.55263969416},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Product Definition","name":"Candles","config":"{\n\"codeName\": \"Candles\"\n}","datasets":[{"type":"Dataset Definition","name":"One-Min","config":"{\n\"codeName\": \"One-Min\"\n}","id":"1c3696e4-c28e-4744-9100-706d6dce0c3c","savedPayload":{"position":{"x":19935.702085675992,Line truncated
|
||||
{"type":"Data Mine","name":"Masters","config":"{\n\"codeName\": \"Masters\"\n}","sensorBots":[{"type":"Sensor Bot","name":"Exchange Raw Data","config":"{\n\"codeName\": \"Exchange-Raw-Data\",\n\"repo\": \"Exchange-Raw-Data-Sensor-Bot\"\n}","processes":[{"type":"Process Definition","name":"Historic-OHLCVs","config":"{\n \"codeName\": \"Historic-OHLCVs\",\n \"description\": \"Retrieves and saves historical maket data\",\n \"startMode\": {\n \"noTime\": {\n \"run\": \"true\"\n },\n \"fixedInterval\": {\n \"run\": \"false\",\n \"interval\": 0\n }\n },\n \"deadWaitTime\": 0,\n \"normalWaitTime\": 60000,\n \"retryWaitTime\": 10000\n}","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[],"id":"dfe2556e-a765-4e38-9d30-7f91090c0069","savedPayload":{"position":{"x":19696.65896528582,"y":18077.80666168302},"targetPosition":{"x":19676.617425695335,"y":18484.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"processDependencies":{"type":"Process Dependencies","name":"New Process Dependencies","statusDependencies":[{"type":"Status Dependency","name":"Exchange Raw Data Historic-OHLCVs","config":"{\n \"mainUtility\": \"Self Reference\"\n}","id":"ea39c98b-18e2-44ce-9f7f-86a8a76a688a","savedPayload":{"position":{"x":20113.534021268813,"y":17812.56375630177},"targetPosition":{"x":19895.316491438505,"y":18148.31980838774},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e"}}}],"dataDependencies":[],"dataMineDataDependencies":[],"id":"5c7fae5a-6da6-4864-a167-f2f21d578c72","savedPayload":{"position":{"x":19895.316491438505,"y":18148.31980838774},"targetPosition":{"x":19676.617425695335,"y":18484.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"statusReport":{"type":"Status Report","name":"New Status Report","id":"181c7c34-7243-497a-9ddb-1b0067c6d66e","savedPayload":{"position":{"x":20033.71582860312,"y":18302.406526432995},"targetPosition":{"x":19676.617425695335,"y":18484.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionStartedEvent":{"type":"Execution Started Event","name":"","id":"957e7e3a-b167-40be-93b5-9ba4ceff56e5","savedPayload":{"position":{"x":20077.30856507894,"y":18504.680081128765},"targetPosition":{"x":19676.617425695335,"y":18484.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"executionFinishedEvent":{"type":"Execution Finished Event","name":"New Execution Finished Event","id":"fe40a546-43ee-49df-908a-7e72f598f0cd","savedPayload":{"position":{"x":20021.51506449239,"y":18692.64493952324},"targetPosition":{"x":19676.617425695335,"y":18484.33639924593},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc","savedPayload":{"position":{"x":19676.617425695335,"y":18484.33639924593},"targetPosition":{"x":19280.707614323983,"y":18686.55263969416},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"products":[{"type":"Product Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","datasets":[{"type":"Dataset Definition","name":"Trades","config":"{\n\"codeName\": \"Trades\"\n}","id":"fbb7c17e-a909-4fa2-b3c5-eb8ca86297c4","savedPayload":{"position":{"x":19941.732540593195,"y":18582.456194349146},"targetPosition":{"x":19743.31504137297,"y":18614.06022300575},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}}],"id":"38dbb942-a15b-450b-a867-02a94030965f","savedPayload":{"position":{"x":19743.31504137297,"y":18614.06022300575},"targetPosition":{"x":19280.707614323983,"y":18686.55263969416},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Product Definition","name":"Candles","config":"{\n\"codeName\": \"Candles\"\n}","datasets":[{"type":"Dataset Definition","name":"One-Min","config":"{\n\"codeName\": \"One-Min\"\n}","id":"1c3696e4-c28e-4744-9100-706d6dce0c3c","savedPayload":{"position":{"x":19937.702085675992,Line truncated
|
||||
+157
-70
@@ -1,97 +1,184 @@
|
||||
let candle = record.current // This is the primary dependency
|
||||
let volume = getElement('volumes', candle) // Here I get the volume bar corresponding to the current candle
|
||||
let totalVolume = volume.buy + volume.sell // Candles Volumes split the volume received from the exchange evenly betwen buy and sell because it does not know how much of it there is.
|
||||
|
||||
variable.buyVolume = 0
|
||||
variable.sellVolume = 0
|
||||
|
||||
if (candle.direction === 'Up') {
|
||||
variable.buyVolume = totalVolume
|
||||
}
|
||||
if (candle.direction === 'Down') {
|
||||
variable.sellVolume = totalVolume
|
||||
}
|
||||
let totalBuy
|
||||
let totalSell
|
||||
let totalNonZero
|
||||
/* Maintain the 20 periods moving averages. */
|
||||
variable.last20Buy.splice(0, 1)
|
||||
variable.last20Buy.push(variable.buyVolume)
|
||||
totalBuy = 0
|
||||
totalNonZero = 0
|
||||
for (let i = 0; i < variable.last20Buy.length; i++) {
|
||||
let value = variable.last20Buy[i]
|
||||
if (value > 0) {
|
||||
totalBuy = totalBuy + value
|
||||
totalNonZero++
|
||||
let candle = record.current
|
||||
let previousCandle = record.previous
|
||||
|
||||
variable.supportResistanceZone = calculateSupportResistanceZone()
|
||||
|
||||
deleteResistances(candle.max)
|
||||
increasePeriods()
|
||||
|
||||
variable.resistance = {}
|
||||
|
||||
variable.resistance.rate = 0
|
||||
variable.resistance.period = 0
|
||||
variable.resistance.type = ''
|
||||
|
||||
if (previousCandle !== undefined) {
|
||||
|
||||
let previousPreviousCandle = record.previous.previous
|
||||
|
||||
if (previousPreviousCandle !== undefined) {
|
||||
|
||||
if (previousCandle.max > previousPreviousCandle.max && previousCandle.max > candle.max) {
|
||||
variable.resistance.rate = previousCandle.max
|
||||
variable.resistance.period = 0
|
||||
variable.resistance.type = 'Resistance'
|
||||
increaseResistancesBounces(variable.resistance.rate)
|
||||
rememberResistance(variable.resistance.rate)
|
||||
}
|
||||
}
|
||||
}
|
||||
variable.buySMA20 = totalBuy / totalNonZero
|
||||
|
||||
variable.last20Sell.splice(0, 1)
|
||||
variable.last20Sell.push(variable.sellVolume)
|
||||
totalSell = 0
|
||||
totalNonZero = 0
|
||||
for (let i = 0; i < variable.last20Sell.length; i++) {
|
||||
let value = variable.last20Sell[i]
|
||||
if (value > 0) {
|
||||
totalSell = totalSell + value
|
||||
totalNonZero++
|
||||
setClosestResistances()
|
||||
|
||||
function deleteResistances(rate) {
|
||||
|
||||
let max
|
||||
|
||||
for (let i = 0; i < variable.resistances.length; i++) {
|
||||
let currenRecord = variable.resistances[i]
|
||||
let currentRate = currenRecord[0]
|
||||
|
||||
if (rate >= currentRate + currentRate * variable.supportResistanceZone / 2 / 100) { // It must go through the support / resistance zone around the current rate value
|
||||
max = i
|
||||
}
|
||||
}
|
||||
if (max !== undefined) {
|
||||
variable.resistances.splice(0, max + 1)
|
||||
}
|
||||
}
|
||||
variable.sellSMA20 = totalSell / totalNonZero
|
||||
|
||||
/* Maintain the 200 periods moving averages. */
|
||||
variable.last200Buy.splice(0, 1)
|
||||
variable.last200Buy.push(variable.buyVolume)
|
||||
totalBuy = 0
|
||||
totalNonZero = 0
|
||||
for (let i = 0; i < variable.last200Buy.length; i++) {
|
||||
let value = variable.last200Buy[i]
|
||||
if (value > 0) {
|
||||
totalBuy = totalBuy + value
|
||||
totalNonZero++
|
||||
function increasePeriods() {
|
||||
|
||||
for (let i = 0; i < variable.resistances.length; i++) {
|
||||
let currenRecord = variable.resistances[i]
|
||||
currenRecord[1] = currenRecord[1] + 1
|
||||
}
|
||||
}
|
||||
variable.buySMA200 = totalBuy / totalNonZero
|
||||
|
||||
variable.last200Sell.splice(0, 1)
|
||||
variable.last200Sell.push(variable.sellVolume)
|
||||
totalSell = 0
|
||||
totalNonZero = 0
|
||||
for (let i = 0; i < variable.last200Sell.length; i++) {
|
||||
let value = variable.last200Sell[i]
|
||||
if (value > 0) {
|
||||
totalSell = totalSell + value
|
||||
totalNonZero++
|
||||
function setClosestResistances() {
|
||||
let record
|
||||
|
||||
record = variable.resistances[0]
|
||||
if (record === undefined) { record = [0, 0, 0, 0, 0, 0, 0, 0] }
|
||||
variable.resistance1Rate = record[0]
|
||||
variable.resistance1Period = record[1]
|
||||
variable.resistance1Bounce1 = record[2]
|
||||
variable.resistance1Bounce2 = record[3]
|
||||
variable.resistance1Bounce3 = record[4]
|
||||
variable.resistance1Bounce5 = record[5]
|
||||
variable.resistance1Bounce10 = record[6]
|
||||
variable.resistance1BounceAll = record[7]
|
||||
|
||||
record = variable.resistances[1]
|
||||
if (record === undefined) { record = [0, 0, 0, 0, 0, 0, 0, 0] }
|
||||
variable.resistance2Rate = record[0]
|
||||
variable.resistance2Period = record[1]
|
||||
variable.resistance2Bounce1 = record[2]
|
||||
variable.resistance2Bounce2 = record[3]
|
||||
variable.resistance2Bounce3 = record[4]
|
||||
variable.resistance2Bounce5 = record[5]
|
||||
variable.resistance2Bounce10 = record[6]
|
||||
variable.resistance2BounceAll = record[7]
|
||||
|
||||
record = variable.resistances[2]
|
||||
if (record === undefined) { record = [0, 0, 0, 0, 0, 0, 0, 0] }
|
||||
variable.resistance3Rate = record[0]
|
||||
variable.resistance3Period = record[1]
|
||||
variable.resistance3Bounce1 = record[2]
|
||||
variable.resistance3Bounce2 = record[3]
|
||||
variable.resistance3Bounce3 = record[4]
|
||||
variable.resistance3Bounce5 = record[5]
|
||||
variable.resistance3Bounce10 = record[6]
|
||||
variable.resistance3BounceAll = record[7]
|
||||
|
||||
record = variable.resistances[3]
|
||||
if (record === undefined) { record = [0, 0, 0, 0, 0, 0, 0, 0] }
|
||||
variable.resistance4Rate = record[0]
|
||||
variable.resistance4Period = record[1]
|
||||
variable.resistance4Bounce1 = record[2]
|
||||
|
||||
record = variable.resistances[4]
|
||||
if (record === undefined) { record = [0, 0, 0, 0, 0, 0, 0, 0] }
|
||||
variable.resistance5Rate = record[0]
|
||||
variable.resistance5Period = record[1]
|
||||
variable.resistance5Bounce1 = record[2]
|
||||
|
||||
}
|
||||
|
||||
function rememberResistance(rate) {
|
||||
if (variable.resistances.length === 0) {
|
||||
variable.resistances.push([rate, 1, 0, 0, 0, 0, 0, 0])
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < variable.resistances.length; i++) {
|
||||
let currenRecord = variable.resistances[i]
|
||||
let currentRate = currenRecord[0]
|
||||
|
||||
if (rate > currentRate - currentRate * variable.supportResistanceZone / 2 / 100 && rate < currentRate + currentRate * variable.supportResistanceZone / 2 / 100) {
|
||||
// We are not going to remember this new level since it is absorved by this existing one.
|
||||
return
|
||||
}
|
||||
|
||||
if (rate < currentRate) {
|
||||
variable.resistances.splice(i, 0, [rate, 1, 0, 0, 0, 0, 0, 0])
|
||||
return
|
||||
}
|
||||
|
||||
if (i === variable.resistances.length - 1) {
|
||||
variable.resistances.push([rate, 1, 0, 0, 0, 0, 0, 0])
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
variable.sellSMA200 = totalSell / totalNonZero
|
||||
|
||||
function increaseResistancesBounces(rate) {
|
||||
|
||||
for (let i = 0; i < variable.resistances.length; i++) {
|
||||
let currenRecord = variable.resistances[i]
|
||||
let currentRate = currenRecord[0]
|
||||
let percentage = 100 - rate * 100 / currentRate
|
||||
|
||||
if (percentage <= variable.supportResistanceZone / 2 * 1) {
|
||||
currenRecord[2] = currenRecord[2] + 1
|
||||
}
|
||||
|
||||
if (percentage <= variable.supportResistanceZone / 2 * 2) {
|
||||
currenRecord[3] = currenRecord[3] + 1
|
||||
}
|
||||
|
||||
if (percentage <= variable.supportResistanceZone / 2 * 3) {
|
||||
currenRecord[4] = currenRecord[4] + 1
|
||||
}
|
||||
|
||||
if (percentage <= variable.supportResistanceZone / 2 * 5) {
|
||||
currenRecord[5] = currenRecord[5] + 1
|
||||
}
|
||||
|
||||
if (percentage <= variable.supportResistanceZone / 2 * 10) {
|
||||
currenRecord[6] = currenRecord[6] + 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
variable.last20Buy = []
|
||||
variable.last20Sell = []
|
||||
variable.last200Buy = []
|
||||
variable.last200Sell = []
|
||||
|
||||
for (let i = 0; i < 20; i++) {
|
||||
variable.last20Buy.push(0)
|
||||
variable.last20Sell.push(0)
|
||||
currenRecord[7] = currenRecord[7] + 1
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < 200; i++) {
|
||||
variable.last200Buy.push(0)
|
||||
variable.last200Sell.push(0)
|
||||
}
|
||||
function calculateSupportResistanceZone() {
|
||||
/*
|
||||
The variable % is a percentage we will use for support and resistance based on the time frame.
|
||||
We will fix the % for 1 minute candles and for 24 hs candle and the use the formula to obtain
|
||||
y on a line by knowing 2 points of the line as described here: https://en.wikipedia.org/wiki/Line_(geometry)
|
||||
*/
|
||||
|
||||
let x0 = system.ONE_MIN_IN_MILISECONDS
|
||||
let y0 = 0.1 // At one min, we will consider the resistance / support zone to be 0.1% resistance
|
||||
let x1 = system.ONE_DAY_IN_MILISECONDS
|
||||
let y1 = 4 // At one day, we will consider the resistance / support zone to be 4% resistance
|
||||
|
||||
let x = system.timeFrame // This is the current time frame being calculated
|
||||
let y = (x - x0) * (y1 - y0) / (x1 - x0) + y0
|
||||
|
||||
return y
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user