SmartQuant Discussion

Neural Network Tutorial, Training, and example code.
Page 1 of 1

Author:  cs96ai [ Sun Feb 27, 2011 6:14 am ]
Post subject:  Neural Network Tutorial, Training, and example code.

Encog has posted a tutorial and training software for a neural network implementations for trading.

The tutorial is based around Ninja but all the code is C# and quite applicable to OpenQuant.

The code is as easy as...

protected override void OnBarUpdate()
  if (CurrentBar < INPUT_WINDOW) return;

//Next we allocate space for the input.
//The number 3 is because we have 3 indicator inputs(the three values of the MACD).
//If you add more, you must up this number.

INeuralData input = new BasicNeuralData(3*INPUT_WINDOW);

//We must now fill the input with the correct time values,
//this is the MACD indicator trailing backwards.
//This must match the order that the network was trained with.

  int index = 0;
  for(int i=0;i<INPUT_WINDOW;i++)
    input[index++] = stats[3].Normalize( MACD(12,26,9)[i] );
    input[index++] = stats[4].Normalize( MACD(12,26,9).Avg[i] );
    input[index++] = stats[5].Normalize( MACD(12,26,9).Diff[i] );

//We are now ready to compute the output from the neural network. We call Encog to do this.

  INeuralData output = network.Compute(input);
  double d = output[0];
  d = stats[6].DeNormalize(d);Finally, we display the output from the neural network.


May all your positions be filled!


Author:  RedEye [ Mon May 16, 2011 6:12 am ]
Post subject:  Re: Neural Network Tutorial, Training, and example code.

Nice post, thank you. Have you found that most things interface between NinjaTrader and OQ without major code rewrites?

Author:  fxmc [ Sun May 13, 2012 4:00 pm ]
Post subject:  Re: Neural Network Tutorial, Training, and example code.

I wrote an API for OQ , it's already inside the Encog-core (was submitted and accepted in the git 6 - 7 months ago).

You can basically load any data and process it in Encog framework.

see :

public static LoaderTypes OpenquantDataLoader(string instrument, DateTime dtfrom, DateTime dtto, Data.Data.BarType bartype, long barsize);
public static double[] FromBarSeriestoDouble(Encog.App.Quant.Loader.OpenQuant.IDataSeries thebarserie);

You start first by :

public LoaderTypes(string instrument, DateTime StartingDate, DateTime ToDate,Data.Data.BarType Type, long SizeOfBars);

I posted a strategy in Encog forums..

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group