Polishing
This commit is contained in:
1 parent
32b5260283
commit
7ede9ec980
4 files changed
+176
-56
No files matched your search
@@ -8,15 +8,151 @@
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "In the context of the trading engine, formulas are used to create user defined statistics."
|
||||
"text": "In the context of a trading system, formulas are used to determine the values for several properties, such as the target rate, target size, managed stop loss, managed take profit, and so on."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Formulas may use indicators and object properties made available by the trading engine. They must evaluate to a number."
|
||||
"text": "Formulas may use indicators and trading engine properties. The main difference between writing a formula and writing a condition is that while conditions must evaluate to true or false, formulas must evaluate to a number."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "A simple math example:"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "This simple formula may be used to define an initial take profit target 3% above the rate at which the position was taken."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "tradingEngine.current.position.entryTargetRate.value * 1.03"
|
||||
},
|
||||
{
|
||||
"style": "Note",
|
||||
"text": "To learn how to write formulas, see syntax overview."
|
||||
"text": "You may use any variable made available by the trading engine, as explained on the accessing runtime data page."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "A simple JavaScript example:"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "A bit of very basic JavaScript, introducing conditional statements, allows more intelligence. For example, in this case, we ask if the proposed formula results in a number greater than the current stop loss value; if it does, then the proposed formula is used; if not, then the current stop loss value is left as is."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "This is—basically—a trailing stop loss 2% below the moving average that may go higher if the moving average goes up, but it may never come down—thanks to the use of the IF ELSE clause."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "if (chart.at01hs.bollingerBand.movingAverage * 0.98 > tradingEngine.current.position.stopLoss.value)"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " {chart.at01hs.bollingerBand.movingAverage * 0.98}"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " else"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " {tradingEngine.current.position.stopLoss.value}"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "For developers:"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "To build more complex logic within a formula, create a function that implements the logic and returns a numerical value, and then call the function:"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "function orderRate() {"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const ORDER_STEP_NUMBER = 1 // Secuential step number, starting with 1 from the closest to the price."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const BUY_SELL_SIGN = -1 // 1 for buy orders, -1 for sell orders."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const STEP_SEPARATION = 0.15 // % of separation of stair steps between them."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const BASE_FACTOR = 0.2 // % above or below bollinger band without bias."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const BIAS_FACTOR = 0.3 // % to move the whole stair of orders up or down depending on the bias."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " const BAND_RATE = chart.at01min.bollingerBand.lowerBand // Upper Bollinger Band for sell orders, and Lower for buy orders."
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " let inbalance = tradingEngine.current.episode.episodeBaseAsset.beginBalance.value - tradingEngine.current.episode.episodeBaseAsset.balance.value"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " let BIAS_SIGN"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " if (inbalance === 0) {"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " BIAS_SIGN = 0"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " }"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " if (inbalance < 0) {"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " BIAS_SIGN = + 1"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " }"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " if (inbalance > 0) {"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " BIAS_SIGN = - 1"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " }"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " let rate = BAND_RATE + BUY_SELL_SIGN BAND_RATE (BASE_FACTOR + ORDER_STEP_NUMBER STEP_SEPARATION + BIAS_SIGN BIAS_FACTOR) / 100"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": " return rate"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "}"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "orderRate()"
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
@@ -24,7 +160,7 @@
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "To add the formula node, select Add Missing Items on the parent node menu."
|
||||
"text": "To add a formula, select Add Formula on the corresponding parent node menu."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -136,63 +136,63 @@
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| DARK | 48, 48, 54 | <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\"> </span> |"
|
||||
"text": "| DARK | 48, 48, 54 | RGB(48, 48, 54) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| LIGHT | 234, 226, 222 | <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\"> </span> |"
|
||||
"text": "| LIGHT | 234, 226, 222 | RGB(234, 226, 222); border: 1px black |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GREY | 150, 150, 150 | <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GREY | 150, 150, 150 | RGB(150, 150, 150) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| LIGHT_GREY | 247, 247, 247 | <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\"> </span> |"
|
||||
"text": "| LIGHT_GREY | 247, 247, 247 | RGB(247, 247, 247) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| WHITE | 255, 255, 255 | <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\"> </span> |"
|
||||
"text": "| WHITE | 255, 255, 255 | RGB(255, 255, 255) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| BLACK | 0, 0, 0 | <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\"> </span> |"
|
||||
"text": "| BLACK | 0, 0, 0 | RGB(0, 0, 0) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GOLDEN_ORANGE | 240, 162, 2 | <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GOLDEN_ORANGE | 240, 162, 2 | RGB(240, 162, 2) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| RUSTED_RED | 204, 88, 53 | <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\"> </span> |"
|
||||
"text": "| RUSTED_RED | 204, 88, 53 | RGB(204, 88, 53) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GREEN | 188, 214, 67 | <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GREEN | 188, 214, 67 | RGB(188, 214, 67) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| RED | 223, 70, 60 | <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\"> </span> |"
|
||||
"text": "| RED | 223, 70, 60 | RGB(223, 70, 60) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\"> </span> |"
|
||||
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | RGB(27, 153, 139) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| TITANIUM_YELLOW | 244, 228, 9 | <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\"> </span> |"
|
||||
"text": "| TITANIUM_YELLOW | 244, 228, 9 | RGB(244, 228, 9) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| MANGANESE_PURPLE | 91,80, 122 | <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\"> </span> |"
|
||||
"text": "| MANGANESE_PURPLE | 91,80, 122 | RGB(91,80, 122) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| TURQUOISE | 74, 207, 217 | <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\"> </span> |"
|
||||
"text": "| TURQUOISE | 74, 207, 217 | RGB(74, 207, 217) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| DARK_TURQUOISE | 2, 149, 170 | <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\"> </span> |"
|
||||
"text": "| DARK_TURQUOISE | 2, 149, 170 | RGB(2, 149, 170) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
|
||||
@@ -156,63 +156,63 @@
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| DARK | 48, 48, 54 | <span style=\"display: block; background: RGB(48, 48, 54); border: 1px solid black;\"> </span> |"
|
||||
"text": "| DARK | 48, 48, 54 | RGB(48, 48, 54) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| LIGHT | 234, 226, 222 | <span style=\"display: block; background: RGB(234, 226, 222); border: 1px black; border: 1px solid black;\"> </span> |"
|
||||
"text": "| LIGHT | 234, 226, 222 | RGB(234, 226, 222); border: 1px black |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GREY | 150, 150, 150 | <span style=\"display: block; background: RGB(150, 150, 150); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GREY | 150, 150, 150 | RGB(150, 150, 150) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| LIGHT_GREY | 247, 247, 247 | <span style=\"display: block; background: RGB(247, 247, 247); border: 1px solid black;\"> </span> |"
|
||||
"text": "| LIGHT_GREY | 247, 247, 247 | RGB(247, 247, 247) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| WHITE | 255, 255, 255 | <span style=\"display: block; background: RGB(255, 255, 255); border: 1px solid black;\"> </span> |"
|
||||
"text": "| WHITE | 255, 255, 255 | RGB(255, 255, 255) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| BLACK | 0, 0, 0 | <span style=\"display: block; background: RGB(0, 0, 0); border: 1px solid black;\"> </span> |"
|
||||
"text": "| BLACK | 0, 0, 0 | RGB(0, 0, 0) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GOLDEN_ORANGE | 240, 162, 2 | <span style=\"display: block; background: RGB(240, 162, 2); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GOLDEN_ORANGE | 240, 162, 2 | RGB(240, 162, 2) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| RUSTED_RED | 204, 88, 53 | <span style=\"display: block; background: RGB(204, 88, 53); border: 1px solid black;\"> </span> |"
|
||||
"text": "| RUSTED_RED | 204, 88, 53 | RGB(204, 88, 53) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| GREEN | 188, 214, 67 | <span style=\"display: block; background: RGB(188, 214, 67); border: 1px solid black;\"> </span> |"
|
||||
"text": "| GREEN | 188, 214, 67 | RGB(188, 214, 67) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| RED | 223, 70, 60 | <span style=\"display: block; background: RGB(223, 70, 60); border: 1px solid black;\"> </span> |"
|
||||
"text": "| RED | 223, 70, 60 | RGB(223, 70, 60) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | <span style=\"display: block; background: RGB(27, 153, 139); border: 1px solid black;\"> </span> |"
|
||||
"text": "| PATINATED_TURQUOISE | 27, 153, 139 | RGB(27, 153, 139) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| TITANIUM_YELLOW | 244, 228, 9 | <span style=\"display: block; background: RGB(244, 228, 9); border: 1px solid black;\"> </span> |"
|
||||
"text": "| TITANIUM_YELLOW | 244, 228, 9 | RGB(244, 228, 9) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| MANGANESE_PURPLE | 91,80, 122 | <span style=\"display: block; background: RGB(91,80, 122); border: 1px solid black;\"> </span> |"
|
||||
"text": "| MANGANESE_PURPLE | 91,80, 122 | RGB(91,80, 122) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| TURQUOISE | 74, 207, 217 | <span style=\"display: block; background: RGB(74, 207, 217); border: 1px solid black;\"> </span> |"
|
||||
"text": "| TURQUOISE | 74, 207, 217 | RGB(74, 207, 217) |"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "| DARK_TURQUOISE | 2, 149, 170 | <span style=\"display: block; background: RGB(2, 149, 170); border: 1px solid black;\"> </span> |"
|
||||
"text": "| DARK_TURQUOISE | 2, 149, 170 | RGB(2, 149, 170) |"
|
||||
},
|
||||
{
|
||||
"style": "List",
|
||||
|
||||
@@ -376,32 +376,16 @@ function newSuperalgosDocSpace() {
|
||||
return false
|
||||
}
|
||||
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
|
||||
for (let i = 1; i < 10; i++) {
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
if (paragraphNode === undefined) { return false}
|
||||
}
|
||||
}
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('paragraph') < 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Depending on the Style of Paragraph we will need to remove
|
||||
some info from the innerText.
|
||||
|
||||
Reference in new issue
Block a user