Topic: Powershell Automation --input not working
Hi All
I've recently got into EG and I'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.
Attached is a validate and generate powershell script. It runs, but it can'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't then read it back in.
Any ideas? Maybe I've gone bug-blind and can't see something obvious in my code :-/
Many thanks.
[I can'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]
# Define the parameters for each run
$runs = @(
@{ Symbol = "AUDJPY"; Period = "M15"; DataStart = "2014-01-01"; DataEnd = "2023-04-01"; RunTimeMinutes = "1" },
@{ Symbol = "AUDJPY"; Period = "M15"; DataStart = "2014-10-01"; DataEnd = "2023-10-01"; RunTimeMinutes = "1" }
)
# 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 = "D:/EG",
[string]$SettingsFilePath = "$BaseDirectory/genmaster.ini",
[string]$ScriptFilePath = "$BaseDirectory/bin/gen.js"
)
# Generate input and output filenames using string interpolation
$inputFileName = "$BaseDirectory/collections/$Period/Coll-IS-$Symbol-$Period-$DataStart"
$outputFileName = "$BaseDirectory/collections/$Period/Coll-IS-$Symbol-$Period-$DataStart"
# 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 "Input File: $inputFileName"
Write-Output "Output File: $outputFileName"
# Start the Node.js process with the provided variables
Start-Process -FilePath "node" -ArgumentList @(
"`"$ScriptFilePath`"",
"--settings", "`"$SettingsFilePath`"",
"--symbol", $Symbol,
"--period", $Period,
"--use_data_start", "true",
"--data_start", $DataStart,
"--use_data_end", "true",
"--data_end", $DataEnd,
"--max_working_minutes", $RunTimeMinutes,
"--validate_then_generate", "true",
"--opposite_entry_signal", "IgnoreOrReverse",
"--stop_loss_usage", "AlwaysUse",
"--stop_loss_type", "Fixed",
"--stop_loss_range_min", "20",
"--stop_loss_range_max", "200",
"--take_profit_usage", "AlwaysUse",
"--take_profit_range_min", "20",
"--take_profit_range_max", "200",
"--take_profit_gte_stop_loss", "true",
"--min_count_of_trades", "100",
"--min_profit", "10",
"--min_profit_factor", "1.2",
"--enable_monte_carlo", "false",
"--input", "`"$inputFileName`"",
"--output", "`"$outputFileName`""
) -WindowStyle Normal -Wait
}
# Call the function
Run-NodeProcess -Symbol $_.Symbol -Period $_.Period -DataStart $_.DataStart -DataEnd $_.DataEnd -RunTimeMinutes $_.RunTimeMinutes
} -ThrottleLimit 4