Topic: Data-file parameter ignored

I have the problem, that the data-file parameter is ignored when I use it as a parameter in my PowerShell script:

$timeframe = 5
$datafile = "c:\express-generator\mydata\$timeframe.json"      

start powershell {node .\bin\gen.js `
                  --settings .\forex.ini `
                  --period = $timeframe `
                  --data-file = $datafile `
                  --max_data_bars = 200000 `                  
                  ;Read-Host}

This is giving me this error message:

..:: Express Generator v2.26 ::..
Cannot read data file: C:\express-generator\data\1.json

The seems to be a default file which is used.

Re: Data-file parameter ignored

I found the solution myself. By using the cmd prompt it's working also from PowerShell script. It doesn't matter if we use PowerShell or CMD for execution:

$timeframes = 1,5,15

foreach ($timeframe in $timeframes)
{
    
    $maxDataBars = switch ( $timeframe )
    {
        1  { 200000 }
        5  { 55000 }
        15 { 35000 }        
    }
    
    $datafile = ".\mydata\${timeframe}.json"        
    
    $command = "node .\bin\gen.js `
               --settings .\forex.ini `
               --period = $timeframe `
               --data_file = $datafile `
               --max_data_bars = $maxDataBars"

    start cmd -ArgumentList "/k $command"
}

Re: Data-file parameter ignored

I managed to run it only by making the commands a single-line string.

$timeframes = 'M1', 'M5', 'M15'

foreach ($timeframe in $timeframes) {

    $maxDataBars = switch ($timeframe) {
        'M1'  { 200000 }
        'M5'  {  55000 }
        'M15' {  35000 }
    }

    $datafile = ".\data\Premium\EURUSD_${timeframe}.json"

    $command  = "node .\bin\gen.js --data-file $datafile --max-data-bars $maxDataBars"

    start cmd -ArgumentList "/k $command"
}

https://image-holder.forexsb.com/store/xgen-powershell-script-test1-thumb.png


Note:

To make it possible to execute Powershell scripts run:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted