<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Powershell Automation --input not working]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/9896/" />
	<updated>2025-01-16T22:04:06Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/9896/powershell-automation-input-not-working/</id>
		<entry>
			<title type="html"><![CDATA[Re: Powershell Automation --input not working]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82394/#p82394" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>Try to print the `$inputFileName` and check if the file actually exists.</p><p>The quotes seem to me unbalanced here:<br /></p><div class="codebox"><pre><code> &quot;--input&quot;, &quot;`&quot;$inputFileName`&quot;&quot;,</code></pre></div></blockquote></div><p>Thanks for the quick response.</p><p>I did question the strange imbalanced looking quotes, but apprently it is correct and has to do with handling of the variables/strings and so on within PS. And the --output was working with the same imbalanced looking quotes anyway.</p><p>But, your suggestion for checking file existence got me to the answer: Because I&#039;m using absolute paths when calling generate.js, I need to also specify the file extension .json on the end. Not needed on the output side as I guess your js handles this. For completness I have added it on the output side anyway.</p><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[begoodall]]></name>
				<uri>https://forexsb.com/forum/user/16312/</uri>
			</author>
			<updated>2025-01-16T22:04:06Z</updated>
			<id>https://forexsb.com/forum/post/82394/#p82394</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Powershell Automation --input not working]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82393/#p82393" />
			<content type="html"><![CDATA[<p>Try to print the `$inputFileName` and check if the file actually exists.</p><p>The quotes seem to me unbalanced here:<br /></p><div class="codebox"><pre><code> &quot;--input&quot;, &quot;`&quot;$inputFileName`&quot;&quot;,</code></pre></div><br /><p>Edit: The backticks are correct!</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2025-01-16T20:39:30Z</updated>
			<id>https://forexsb.com/forum/post/82393/#p82393</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Powershell Automation --input not working]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82390/#p82390" />
			<content type="html"><![CDATA[<p>Hi All</p><p>I&#039;ve recently got into EG and I&#039;m trying to automate as much as possible. I started with DOS cmd, but I am now moving all my programs onto Powershell, so I can then move to Linux, so I can then get a Cloud VPS to run things 24/7. The Powershell on Linux part is to avoid expensive Windows cloud licences, but still remain compatible with my local machine.</p><p>Attached is a validate and generate powershell script. It runs, but it can&#039;t find any existing collection to load - and I know they exist. It ouputs the collection at the end of the run perfectly well. It can&#039;t then read it back in.</p><p>Any ideas? Maybe I&#039;ve gone bug-blind and can&#039;t see something obvious in my code :-/</p><p>Many thanks.</p><p>[I can&#039;t seem to attach the ps1 file, but hopefully the code is readable / will run if someone were to put it in a ps1 file]</p><div class="codebox"><pre><code># Define the parameters for each run
$runs = @(
    @{ Symbol = &quot;AUDJPY&quot;; Period = &quot;M15&quot;; DataStart = &quot;2014-01-01&quot;; DataEnd = &quot;2023-04-01&quot;; RunTimeMinutes = &quot;1&quot; },
    @{ Symbol = &quot;AUDJPY&quot;; Period = &quot;M15&quot;; DataStart = &quot;2014-10-01&quot;; DataEnd = &quot;2023-10-01&quot;; RunTimeMinutes = &quot;1&quot; }
)

# Run each process in parallel
$runs | ForEach-Object -Parallel {
    # Define the function for Node.js process execution
    function Run-NodeProcess {
        param (
            [string]$Symbol,
            [string]$Period,
            [string]$DataStart,
            [string]$DataEnd,
            [string]$RunTimeMinutes,
            [string]$BaseDirectory = &quot;D:/EG&quot;,
            [string]$SettingsFilePath = &quot;$BaseDirectory/genmaster.ini&quot;,
            [string]$ScriptFilePath = &quot;$BaseDirectory/bin/gen.js&quot;
        )

        # Generate input and output filenames using string interpolation
        $inputFileName = &quot;$BaseDirectory/collections/$Period/Coll-IS-$Symbol-$Period-$DataStart&quot;
        $outputFileName = &quot;$BaseDirectory/collections/$Period/Coll-IS-$Symbol-$Period-$DataStart&quot;

        # Ensure the output directory exists
        $outputDir = Split-Path -Path $outputFileName -Parent
        if (-not (Test-Path -Path $outputDir)) {
            New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
        }

        # Debugging: Log paths
        Write-Output &quot;Input File:  $inputFileName&quot;
        Write-Output &quot;Output File: $outputFileName&quot;

        # Start the Node.js process with the provided variables
        Start-Process -FilePath &quot;node&quot; -ArgumentList @(
            &quot;`&quot;$ScriptFilePath`&quot;&quot;,
            &quot;--settings&quot;, &quot;`&quot;$SettingsFilePath`&quot;&quot;,
            &quot;--symbol&quot;, $Symbol,
            &quot;--period&quot;, $Period,
            &quot;--use_data_start&quot;, &quot;true&quot;,
            &quot;--data_start&quot;, $DataStart,
            &quot;--use_data_end&quot;, &quot;true&quot;,
            &quot;--data_end&quot;, $DataEnd,
            &quot;--max_working_minutes&quot;, $RunTimeMinutes,
            &quot;--validate_then_generate&quot;, &quot;true&quot;,
            &quot;--opposite_entry_signal&quot;, &quot;IgnoreOrReverse&quot;,
            &quot;--stop_loss_usage&quot;, &quot;AlwaysUse&quot;,
            &quot;--stop_loss_type&quot;, &quot;Fixed&quot;,
            &quot;--stop_loss_range_min&quot;, &quot;20&quot;,
            &quot;--stop_loss_range_max&quot;, &quot;200&quot;,
            &quot;--take_profit_usage&quot;, &quot;AlwaysUse&quot;,
            &quot;--take_profit_range_min&quot;, &quot;20&quot;,
            &quot;--take_profit_range_max&quot;, &quot;200&quot;,
            &quot;--take_profit_gte_stop_loss&quot;, &quot;true&quot;,
            &quot;--min_count_of_trades&quot;, &quot;100&quot;,
            &quot;--min_profit&quot;, &quot;10&quot;,
            &quot;--min_profit_factor&quot;, &quot;1.2&quot;,
            &quot;--enable_monte_carlo&quot;, &quot;false&quot;,
            &quot;--input&quot;, &quot;`&quot;$inputFileName`&quot;&quot;,
            &quot;--output&quot;, &quot;`&quot;$outputFileName`&quot;&quot;
        ) -WindowStyle Normal -Wait
    }

    # Call the function
    Run-NodeProcess -Symbol $_.Symbol -Period $_.Period -DataStart $_.DataStart -DataEnd $_.DataEnd -RunTimeMinutes $_.RunTimeMinutes
} -ThrottleLimit 4</code></pre></div>]]></content>
			<author>
				<name><![CDATA[begoodall]]></name>
				<uri>https://forexsb.com/forum/user/16312/</uri>
			</author>
			<updated>2025-01-16T17:42:42Z</updated>
			<id>https://forexsb.com/forum/post/82390/#p82390</id>
		</entry>
</feed>
