mirror of
https://github.com/FxPouya/FxMathQuantWebApp.git
synced 2026-08-01 12:37:44 +00:00
Add files via upload
This commit is contained in:
@@ -16,7 +16,8 @@ class CTraderConverter {
|
||||
const magicNumber = Math.floor(100000 + Math.random() * 900000);
|
||||
|
||||
const buyConditions = this.parser.parseRules(buy_rules, 'csharp');
|
||||
const sellConditions = this.parser.parseRules(sell_rules, 'csharp');
|
||||
// SELL rules use inverted operators
|
||||
const sellConditions = this.parser.parseRulesInverted(buy_rules, 'csharp');
|
||||
|
||||
// Convert MQL-style array access to cTrader MarketSeries
|
||||
const convertToCTrader = (condition) => {
|
||||
@@ -108,7 +109,7 @@ namespace cAlgo.Robots
|
||||
public int EndMinute { get; set; }
|
||||
|
||||
//=== SIGNAL SETTINGS ===
|
||||
[Parameter("Close on Opposite", DefaultValue = true, Group = "Signals")]
|
||||
[Parameter("Close on Opposite", DefaultValue = false, Group = "Signals")]
|
||||
public bool CloseOnOpposite { get; set; }
|
||||
|
||||
//=== DISPLAY SETTINGS ===
|
||||
|
||||
+3
-2
@@ -16,7 +16,8 @@ class MQ4Converter {
|
||||
const magicNumber = Math.floor(100000 + Math.random() * 900000);
|
||||
|
||||
const buyConditions = this.parser.parseRules(buy_rules, 'mql');
|
||||
const sellConditions = this.parser.parseRules(sell_rules, 'mql');
|
||||
// SELL rules use inverted operators
|
||||
const sellConditions = this.parser.parseRulesInverted(buy_rules, 'mql');
|
||||
|
||||
return `//+------------------------------------------------------------------+
|
||||
//| Strategy_${symbol}.mq4 |
|
||||
@@ -58,7 +59,7 @@ input int EndHour = 22; // End Hour (Server Time)
|
||||
input int EndMinute = 0; // End Minute
|
||||
|
||||
//=== SIGNAL SETTINGS ===
|
||||
input bool CloseOnOpposite = true; // Close Trade on Opposite Signal
|
||||
input bool CloseOnOpposite = false; // Close Trade on Opposite Signal
|
||||
|
||||
//=== DISPLAY SETTINGS ===
|
||||
input bool ShowChartInfo = true; // Show Info on Chart
|
||||
|
||||
+3
-2
@@ -16,7 +16,8 @@ class MQ5Converter {
|
||||
const magicNumber = Math.floor(100000 + Math.random() * 900000);
|
||||
|
||||
const buyConditions = this.parser.parseRules(buy_rules, 'mq5');
|
||||
const sellConditions = this.parser.parseRules(sell_rules, 'mq5');
|
||||
// SELL rules use inverted operators
|
||||
const sellConditions = this.parser.parseRulesInverted(buy_rules, 'mq5');
|
||||
|
||||
return `//+------------------------------------------------------------------+
|
||||
//| Strategy_${symbol}.mq5 |
|
||||
@@ -65,7 +66,7 @@ input int EndMinute = 0; // End Minute
|
||||
|
||||
//=== SIGNAL SETTINGS ===
|
||||
input group "=== Signal Settings ==="
|
||||
input bool CloseOnOpposite = true; // Close Trade on Opposite Signal
|
||||
input bool CloseOnOpposite = false; // Close Trade on Opposite Signal
|
||||
|
||||
//=== DISPLAY SETTINGS ===
|
||||
input group "=== Display Settings ==="
|
||||
|
||||
@@ -13,7 +13,8 @@ class PineConverter {
|
||||
const tpMultiplier = parameters.tp_multiplier || 3.0;
|
||||
|
||||
const buyConditions = this.parser.parseRules(buy_rules, 'pine');
|
||||
const sellConditions = this.parser.parseRules(sell_rules, 'pine');
|
||||
// SELL rules use inverted operators
|
||||
const sellConditions = this.parser.parseRulesInverted(buy_rules, 'pine');
|
||||
|
||||
return `//@version=5
|
||||
strategy("Strategy ${symbol}", overlay=true,
|
||||
|
||||
+25
-7
@@ -6,33 +6,51 @@ class RuleParser {
|
||||
return rules.map(rule => this.parseRule(rule, platform));
|
||||
}
|
||||
|
||||
parseRule(rule, platform = 'mql') {
|
||||
// Parse rules with inverted operators (for SELL signals)
|
||||
parseRulesInverted(rules, platform = 'mql') {
|
||||
return rules.map(rule => this.parseRule(rule, platform, true));
|
||||
}
|
||||
|
||||
parseRule(rule, platform = 'mql', invertOp = false) {
|
||||
if (rule.type === 'simple') {
|
||||
return this.parseSimpleRule(rule, platform);
|
||||
return this.parseSimpleRule(rule, platform, invertOp);
|
||||
} else {
|
||||
return this.parseArithmeticRule(rule, platform);
|
||||
return this.parseArithmeticRule(rule, platform, invertOp);
|
||||
}
|
||||
}
|
||||
|
||||
parseSimpleRule(rule, platform) {
|
||||
parseSimpleRule(rule, platform, invertOp = false) {
|
||||
const left = this.getPriceReference(rule.left.price, rule.left.shift, platform);
|
||||
const right = this.getPriceReference(rule.right.price, rule.right.shift, platform);
|
||||
const operator = rule.operator;
|
||||
const operator = invertOp ? this.invertOperator(rule.operator) : rule.operator;
|
||||
|
||||
return `${left} ${operator} ${right}`;
|
||||
}
|
||||
|
||||
parseArithmeticRule(rule, platform) {
|
||||
parseArithmeticRule(rule, platform, invertOp = false) {
|
||||
const left1 = this.getPriceReference(rule.left.price1, rule.left.shift1, platform);
|
||||
const left2 = this.getPriceReference(rule.left.price2, rule.left.shift2, platform);
|
||||
const leftOp = rule.left.op;
|
||||
const right = this.getPriceReference(rule.right.price, rule.right.shift, platform);
|
||||
const multiplier = rule.right.multiplier;
|
||||
const operator = rule.operator;
|
||||
const operator = invertOp ? this.invertOperator(rule.operator) : rule.operator;
|
||||
|
||||
return `(${left1} ${leftOp} ${left2}) ${operator} (${right} * ${multiplier})`;
|
||||
}
|
||||
|
||||
// Invert comparison operators for SELL signals
|
||||
invertOperator(operator) {
|
||||
const inversionMap = {
|
||||
'<': '>=',
|
||||
'<=': '>',
|
||||
'>': '<=',
|
||||
'>=': '<',
|
||||
'==': '!=',
|
||||
'!=': '=='
|
||||
};
|
||||
return inversionMap[operator] || operator;
|
||||
}
|
||||
|
||||
getPriceReference(priceType, shift, platform) {
|
||||
const price = priceType.charAt(0).toUpperCase() + priceType.slice(1).toLowerCase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user