Add files via upload

This commit is contained in:
FxPouya
2025-12-26 10:59:31 +03:30
committed by GitHub
parent ebbbb3e71f
commit b54fbf0aa8
7 changed files with 154 additions and 15 deletions
+3 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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 ==="
+2 -1
View File
@@ -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
View File
@@ -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();
+2 -1
View File
@@ -221,7 +221,8 @@
<h3>Step 2: Activate License</h3>
<ol>
<li>Open the application in your web browser</li>
<li>Open the application at: <a href="https://web.fxmathquant.com/login.html"
target="_blank">https://web.fxmathquant.com/login.html</a></li>
<li>Enter your license key in the format: <code>XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX</code></li>
<li>Click "Activate License"</li>
<li>Wait for validation (requires internet connection)</li>
+116
View File
@@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<title>API Test - Trial License</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
}
.test-box {
background: #f5f5f5;
padding: 20px;
border-radius: 8px;
margin: 20px 0;
}
button {
background: #667eea;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background: #5568d3;
}
.result {
margin-top: 20px;
padding: 15px;
border-radius: 5px;
white-space: pre-wrap;
font-family: monospace;
}
.success {
background: #d4edda;
border: 1px solid #c3e6cb;
color: #155724;
}
.error {
background: #f8d7da;
border: 1px solid #f5c6cb;
color: #721c24;
}
</style>
</head>
<body>
<h1>Trial License API Test</h1>
<div class="test-box">
<h3>Test 1: Local API</h3>
<p>Tests: <code>http://localhost/FxMathQuant-Server/api/create.php</code></p>
<button onclick="testAPI('local')">Test Local API</button>
<div id="result-local"></div>
</div>
<div class="test-box">
<h3>Test 2: Production API</h3>
<p>Tests: <code>https://fxmath.com/quantw/api/create.php</code></p>
<button onclick="testAPI('production')">Test Production API</button>
<div id="result-production"></div>
</div>
<script>
async function testAPI(type) {
const urls = {
local: 'http://localhost/FxMathQuant-Server/api/create.php',
production: 'https://fxmath.com/quantw/api/create.php'
};
const resultDiv = document.getElementById('result-' + type);
resultDiv.innerHTML = '<p>Testing...</p>';
const testEmail = 'test' + Date.now() + '@example.com';
try {
const response = await fetch(urls[type], {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
is_trial: true,
email: testEmail
})
});
const data = await response.json();
let resultHTML = `<div class="${data.success ? 'success' : 'error'} result">`;
resultHTML += `<strong>Status:</strong> ${response.status}\n\n`;
resultHTML += `<strong>Response:</strong>\n${JSON.stringify(data, null, 2)}`;
resultHTML += `</div>`;
resultDiv.innerHTML = resultHTML;
} catch (error) {
resultDiv.innerHTML = `<div class="error result">
<strong>Error:</strong>\n${error.message}
</div>`;
}
}
</script>
</body>
</html>