示例#1
0
        public void onInspector(Plot3 plot)
        {
            //isPlantMode = GUILayout.Toggle( isPlantMode, "Plant Mode", GUI.skin.button );
            isPlantMode = true;

            if (isPlantMode)
            {
                plantEditor.saveTool();

                plantEditor.onEditor();
            }
            else
            {
                plantEditor.restoreTool();
            }



            EditorGUILayout.BeginHorizontal();


            EditorGUILayout.LabelField("cable location");

            if (GUILayout.Button("adjust"))
            {
                adjustCables(plot);
            }

            EditorGUILayout.EndHorizontal();
        }
示例#2
0
        void fittingTerrain(Plot3 plot)
        {
            var district = plot.GetComponentInParent <District3>();

            if (district == null)
            {
                return;
            }


            var tr = district.GetComponentInChildren <Terrain>();

            var field = new TerrainOperator(tr);


            var parts = plot.GetComponentsInChildren <PathSegment3>();           //RoadPart3>();

            foreach (var part in parts)
            {
                var mcs = part.GetComponentsInChildren <MeshCollider>();

                foreach (var mc in mcs)
                {
                    field.adjustMesh(mc);
                }
            }

            tr.Flush();
        }
示例#3
0
 protected override void OnBarUpdate()
 {
     // Use this method for calculating your indicator values. Assign a value to each
     // plot below by replacing 'Close[0]' with your own formula.
     Plot0.Set(Close[0]);
     Plot1.Set(Close[0]);
     Plot3.Set(Close[0]);
 }
示例#4
0
        void adjustCables(Plot3 plot)
        {
            var cablesets = plot.GetComponentsInChildren <PlotPartCableset3>();

            foreach (var cableset in cablesets)
            {
                cableset.adjustCablePositions();
            }
        }
示例#5
0
        public void onScene(Plot3 plot)
        {
            if (isPlantMode)
            {
                plantEditor.saveTool();

                plantEditor.onScene(plot.transform);
            }
        }
示例#6
0
        void resetEditorMesh(Plot3 plot)
        {
            var eos = plot.GetComponentsInChildren <EditorOnlyObject>(true);

            foreach (var eo in eos)
            {
                DestroyImmediate(eo.gameObject);
            }
        }
示例#7
0
        void createEditorMesh(Plot3 plot)
        {
            var paths = plot.GetComponentsInChildren <PathSegment3>();

            foreach (var path in paths)
            {
                path.buildInEditor();
            }
        }
        protected override void CalcBar()
        {
            if (Bars.LastBarInSession)
            {
                m_upperband.Value = (Bars.Close[0] * (1 + (numdevs * volstddev[0] / Math.Sqrt(252))));
                m_lowerband.Value = (Bars.Close[0] * (1 - (numdevs * volstddev[0] / Math.Sqrt(252))));
            }
            else
            {
                m_upperband.Value = (Bars.Close[1] * (1 + (numdevs * volstddev[0] / Math.Sqrt(252))));
                m_lowerband.Value = (Bars.Close[1] * (1 - (numdevs * volstddev[0] / Math.Sqrt(252))));
            }

            Plot1.Set(0, m_upperband.Value);
            Plot2.Set(0, m_lowerband.Value);

            if (enable_depth)
            {
                Plot3.Set(0, (Bars.Close[0] - m_upperband.Value) / (m_upperband.Value - m_lowerband.Value));
                Plot4.Set(0, (m_lowerband.Value - Bars.Close[0]) / (m_upperband.Value - m_lowerband.Value));
            }
        }
示例#9
0
        public void onInspector(Plot3 plot)
        {
            EditorGUILayout.BeginHorizontal();


            EditorGUILayout.LabelField("Editor Temporary Path Mesh");

            if (GUILayout.Button("build"))
            {
                resetEditorMesh(plot);

                createEditorMesh(plot);

                fittingTerrain(plot);
            }

            if (GUILayout.Button("create"))
            {
                resetEditorMesh(plot);

                createEditorMesh(plot);
            }

            if (GUILayout.Button("adjust"))
            {
                fittingTerrain(plot);
            }

            if (GUILayout.Button("remove"))
            {
                resetEditorMesh(plot);
            }


            EditorGUILayout.EndHorizontal();
        }
示例#10
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.


            if (CurrentBar < 30)
            {
                return;
            }


            if ((Low[0] <= DonchianChannel(14)[0]) & (Low[1] > DonchianChannel(14)[1]))
            {
                Plot1.Set(1);
            }


            if ((High[0] >= DonchianChannel(14)[0]) & (High[1] < DonchianChannel(14)[1]))
            {
                Plot0.Set(1);
            }

            int up   = 0;
            int down = 0;
            int y    = 0;

            for (int x = 1; x <= 100; x++)
            {
                if ((Low[x] <= DonchianChannel(14)[x]) & (Low[x + 1] > DonchianChannel(14)[x + 1]))
                {
                    up = 1;
                    y  = x;
                    break;
                }


                if ((High[x] >= DonchianChannel(14)[x]) & (High[x + 1] < DonchianChannel(14)[x + 1]))
                {
                    down = 1;
                    y    = x;
                    break;
                }
            }


            int firstup   = 0;
            int firstdown = 0;


            for (int x = 0; x <= 100; x++)
            {
                if ((up == 1) & (High[x] > High[x + 1]))
                {
                    if (x >= y)
                    {
                        break;
                    }

                    if (x != 0)
                    {
                        firstup = 1;
                        break;
                    }

                    /*
                     * if (!(x < y))
                     * {
                     *  break;
                     * }*/
                }


                if ((down == 1) & (Low[x] < Low[x + 1]))
                {
                    if (x >= y)
                    {
                        break;
                    }

                    if (x != 0)
                    {
                        firstdown = 1;
                        break;
                    }

                    /*
                     * if (!(x < y))
                     * {
                     *  break;
                     * }*/
                }
            }

            if ((firstup == 0) & (up == 1) & (High[0] > High[1]))
            {
                Plot3.Set(1);
            }

            if ((firstdown == 0) & (down == 1) & (Low[0] < Low[1]))
            {
                Plot2.Set(1);
            }
        }
示例#11
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Try to connect, if we are not yet connected.
            // We do this here so that we do not connect everytime the indicator is instanciated.
            // Indicators are often instanciated several times before they are actually used.
            if (_indicatorState == IndicatorState.Uninitialized)
            {
                OpenConnection();
            }

            // Are we in an error state?  If so, display and exit.
            if (_indicatorState == IndicatorState.Error)
            {
                DrawError();
                return;
            }

            // If we are actually connected to a socket, then communicate with it.
            if (_sock != null)
            {
                StringBuilder line = new StringBuilder();

                long when = Time[0].Second +
                            Time[0].Minute * 100l +
                            Time[0].Hour * 10000l +
                            Time[0].Day * 1000000l +
                            Time[0].Month * 100000000l +
                            Time[0].Year * 10000000000l;

                line.Append("\"" + PACKET_BAR + "\",");
                line.Append(when);
                line.Append(",\"");
                line.Append(this.Instrument.FullName);
                line.Append("\"");

                foreach (string name in _sourceData)
                {
                    IDataSeries source;
                    int         totalBars = 1;
                    string      name2     = name;

                    ParseArraySize(name, ref totalBars, ref name2);

                    if (string.Compare(name2, "HIGH", true) == 0)
                    {
                        source = High;
                    }
                    else if (string.Compare(name2, "LOW", true) == 0)
                    {
                        source = Low;
                    }
                    else if (string.Compare(name2, "OPEN", true) == 0)
                    {
                        source = Open;
                    }
                    else if (string.Compare(name2, "CLOSE", true) == 0)
                    {
                        source = Close;
                    }
                    else if (string.Compare(name2, "VOL", true) == 0)
                    {
                        source = Volume;
                    }
                    else if (string.Compare(name2, "THIS", true) == 0)
                    {
                        source = Values[0];
                    }
                    else
                    {
                        source = Eval(name2);
                        if (source == null)
                        {
                            return;
                        }
                    }

                    // now copy needed data
                    var cnt = CurrentBar + 1;

                    for (int i = 0; i < totalBars; i++)
                    {
                        line.Append(",");

                        if (i >= cnt)
                        {
                            line.Append("?");
                        }
                        else
                        {
                            //line.Append(Convert.ToString(source[i]));
                            line.Append(Convert.ToString(source[i], _cultureUSA));
                        }
                    }
                }

                Send(line.ToString());

                // if we are expecting data back from the socket, then wait for it.
                if (_blockingMode)
                {
                    // we are now waiting for a bar
                    _indicatorState = IndicatorState.SentBar;
                    while (_indicatorState != IndicatorState.Error && _indicatorState != IndicatorState.Ready)
                    {
                        WaitForPacket();
                    }

                    // we got a bar message, then display it
                    if (_indicatorState == IndicatorState.Ready)
                    {
                        if (!double.IsNaN(_indicatorData[0]))
                        {
                            Plot1.Set(_indicatorData[0]);
                        }

                        if (!double.IsNaN(_indicatorData[1]))
                        {
                            Plot2.Set(_indicatorData[1]);
                        }

                        if (!double.IsNaN(_indicatorData[2]))
                        {
                            Plot3.Set(_indicatorData[2]);
                        }

                        if (!double.IsNaN(_indicatorData[3]))
                        {
                            Bar1.Set(_indicatorData[3]);
                        }

                        if (!double.IsNaN(_indicatorData[4]))
                        {
                            Bar2.Set(_indicatorData[4]);
                        }

                        if (!double.IsNaN(_indicatorData[5]))
                        {
                            Bar3.Set(_indicatorData[5]);
                        }

                        if (!double.IsNaN(_indicatorData[6]))
                        {
                            IndSell.Set(_indicatorData[6]);
                        }

                        if (!double.IsNaN(_indicatorData[7]))
                        {
                            IndBuy.Set(_indicatorData[7]);
                        }
                    }
                }
                else
                {
                    var hold = this.DrawOnPricePanel;
                    DrawOnPricePanel = false;
                    DrawTextFixed("general msg", "This indicator only sends data, so there is no display.", TextPosition.Center);
                    DrawOnPricePanel = hold;
                }
            }
        }