示例#1
0
        private void ProcessObtain()
        {
            IndentLevel = 3;

            AddLine("FileWrite(iHandle, when,");

            DataField[] fields   = Analyst.Script.Fields;
            String      lastLine = null;

            foreach (DataField field in fields)
            {
                DataField df = field;
                if (string.Compare(df.Name, "time", true) != 0 &&
                    string.Compare(df.Name, "prediction", true) != 0)
                {
                    String str = EngineArray.Replace(df.Source, "##",
                                                     "pos");
                    if (lastLine != null)
                    {
                        AddLine(lastLine + ",");
                    }
                    lastLine = str;
                }
            }

            if (lastLine != null)
            {
                AddLine(lastLine);
            }
            AddLine(");");
            IndentLevel = 0;
        }
示例#2
0
        private void ProcessObtain()
        {
            IndentLevel = 3;
            AddLine("double[] result = new double[ENCOG_COLS.Length];");

            int idx = 0;

            foreach (DataField df in Analyst.Script.Fields)
            {
                if (string.Compare(df.Name, "time", true) != 0 && string.Compare(df.Name, "prediction", true) != 0)
                {
                    String str = EngineArray.Replace(df.Source, "##", "0");
                    AddLine("result[" + idx + "]=" + str + ";");
                    idx++;
                }
            }
            AddLine("return result;");
            IndentLevel = 0;
        }
示例#3
0
        private void ProcessCalc()
        {
            AnalystField firstOutputField = null;
            int          barsNeeded       = Math.Abs(Analyst.DetermineMinTimeSlice());

            int inputCount  = Analyst.DetermineInputCount();
            int outputCount = Analyst.DetermineOutputCount();

            IndentLevel = 2;
            AddLine("if( _inputCount>0 && Bars>=" + barsNeeded + " )");
            AddLine("{");
            IndentIn();
            AddLine("double input[" + inputCount + "];");
            AddLine("double output[" + outputCount + "];");

            int idx = 0;

            foreach (AnalystField field in Analyst.Script.Normalize
                     .NormalizedFields)
            {
                if (field.Input)
                {
                    DataField df = Analyst.Script.FindDataField(field.Name);
                    String    str;

                    switch (field.Action)
                    {
                    case NormalizationAction.PassThrough:
                        str = EngineArray.Replace(df.Source, "##", "pos+"
                                                  + (-field.TimeSlice));
                        AddLine("input[" + idx + "]=" + str + ";");
                        idx++;
                        break;

                    case NormalizationAction.Normalize:
                        str = EngineArray.Replace(df.Source, "##", "pos+"
                                                  + (-field.TimeSlice));
                        AddLine("input[" + idx + "]=Norm(" + str + ","
                                + field.NormalizedHigh + ","
                                + field.NormalizedLow + ","
                                + field.ActualHigh + ","
                                + field.ActualLow + ");");
                        idx++;
                        break;

                    case NormalizationAction.Ignore:
                        break;

                    default:
                        throw new AnalystCodeGenerationError(
                                  "Can't generate Ninjascript code, unsupported normalizatoin action: "
                                  + field.Action.ToString());
                    }
                }
                if (field.Output)
                {
                    if (firstOutputField == null)
                    {
                        firstOutputField = field;
                    }
                }
            }

            if (firstOutputField == null)
            {
                throw new AnalystCodeGenerationError(
                          "Could not find an output field.");
            }

            AddLine("Compute(input,output);");

            AddLine("ExtMapBuffer1[pos] = DeNorm(output[0]" + ","
                    + firstOutputField.NormalizedHigh + ","
                    + firstOutputField.NormalizedLow + ","
                    + firstOutputField.ActualHigh + ","
                    + firstOutputField.ActualLow + ");");
            IndentOut();
            AddLine("}");
            IndentLevel = 2;
        }