|
@@ -0,0 +1,120 @@
|
|
|
|
|
+package cn.muchinfo.rma.view.base.chart.old.timeCharts;
|
|
|
|
|
+
|
|
|
|
|
+import android.content.Context;
|
|
|
|
|
+
|
|
|
|
|
+import com.desfate.chart.MinusStickChart;
|
|
|
|
|
+import com.desfate.chart.data.ChartDataContainer;
|
|
|
|
|
+import com.desfate.chart.data.ChartPSYDatas;
|
|
|
|
|
+import com.desfate.chart.data.ChartRSIDatas;
|
|
|
|
|
+import com.desfate.chart.entity.LineEntity;
|
|
|
|
|
+import com.desfate.chart.entity.StickEntity;
|
|
|
|
|
+import com.desfate.chart.ui.old.OTC.controls.TargetControl;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import cn.muchinfo.rma.view.base.chart.old.OTCChartActivity;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 指标工具
|
|
|
|
|
+ */
|
|
|
|
|
+public class StickChartTools {
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * RSI 周期为6
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param minusstickchart
|
|
|
|
|
+ * @param dataContainer
|
|
|
|
|
+ */
|
|
|
|
|
+ private void setRSILine(Context context, MinusStickChart minusstickchart, ChartDataContainer dataContainer) {
|
|
|
|
|
+ if (dataContainer.mSize == 0) {
|
|
|
|
|
+ minusstickchart.postInvalidate();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * RSI 5
|
|
|
|
|
+ */
|
|
|
|
|
+ List<LineEntity> lines = new ArrayList<LineEntity>();
|
|
|
|
|
+ ChartRSIDatas rsiData = new TargetControl().getRSI(dataContainer);
|
|
|
|
|
+
|
|
|
|
|
+ LineEntity rsi = new LineEntity();
|
|
|
|
|
+ rsi.setLineData(rsiData.getRsi6());
|
|
|
|
|
+ rsi.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi6));
|
|
|
|
|
+ rsi.setStartIndex(5);
|
|
|
|
|
+ lines.add(rsi);
|
|
|
|
|
+
|
|
|
|
|
+ LineEntity rsi12 = new LineEntity();
|
|
|
|
|
+ rsi12.setLineData(rsiData.getRsi12());
|
|
|
|
|
+ rsi12.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi12));
|
|
|
|
|
+ rsi12.setStartIndex(11);
|
|
|
|
|
+ lines.add(rsi12);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ LineEntity rsi24 = new LineEntity();
|
|
|
|
|
+ rsi24.setLineData(rsiData.getRsi24());
|
|
|
|
|
+ rsi24.setLineColor(context.getResources().getColor(com.desfate.chart.R.color.mtp_chart_k_rsi24));
|
|
|
|
|
+ rsi24.setStartIndex(23);
|
|
|
|
|
+ lines.add(rsi24);
|
|
|
|
|
+
|
|
|
|
|
+ minusstickchart.setLineData(lines);
|
|
|
|
|
+
|
|
|
|
|
+ List<StickEntity> entities = new ArrayList<StickEntity>();
|
|
|
|
|
+ StickEntity entity = null;
|
|
|
|
|
+ for (int i = 0; i < dataContainer.mStickList.subList(0, dataContainer.mSize).size(); i++) {
|
|
|
|
|
+ entity = new StickEntity();
|
|
|
|
|
+ entity.setHigh(100.0);
|
|
|
|
|
+ entity.setLow(0.0);
|
|
|
|
|
+ entities.add(entity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ minusstickchart.setShowStick(false);
|
|
|
|
|
+ minusstickchart.setStickData(entities);
|
|
|
|
|
+// minusstickchart.setDecimalNum(mDecimalNum);
|
|
|
|
|
+ minusstickchart.postInvalidate();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 26 6 PSY
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param minusstickchart
|
|
|
|
|
+ * @param dataContainer
|
|
|
|
|
+ */
|
|
|
|
|
+ private void setPSYLine(MinusStickChart minusstickchart, ChartDataContainer dataContainer) {
|
|
|
|
|
+ if (dataContainer.mSize == 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ ChartPSYDatas chartPSYDatas = new TargetControl().getPSYs(dataContainer);
|
|
|
|
|
+ List<LineEntity> lines = new ArrayList<LineEntity>();
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * psy
|
|
|
|
|
+ */
|
|
|
|
|
+ LineEntity psy = new LineEntity();
|
|
|
|
|
+ psy.setLineData(chartPSYDatas.getPsy());
|
|
|
|
|
+
|
|
|
|
|
+// psy.setLineColor(((OTCChartActivity) getActivity()).getMtpChartControl().getPSYColor());
|
|
|
|
|
+
|
|
|
|
|
+ psy.setStartIndex(25);
|
|
|
|
|
+ lines.add(psy);
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * psyMa
|
|
|
|
|
+ */
|
|
|
|
|
+ LineEntity psyMa = new LineEntity();
|
|
|
|
|
+ psyMa.setLineData(chartPSYDatas.getPsyMa());
|
|
|
|
|
+
|
|
|
|
|
+// psyMa.setLineColor(((OTCChartActivity) getActivity()).getMtpChartControl().getPSYMAColor());
|
|
|
|
|
+
|
|
|
|
|
+ psyMa.setStartIndex(25);
|
|
|
|
|
+ lines.add(psyMa);
|
|
|
|
|
+
|
|
|
|
|
+ minusstickchart.setLineData(lines);
|
|
|
|
|
+
|
|
|
|
|
+ minusstickchart.setShowStick(false);
|
|
|
|
|
+ minusstickchart.setStickData(dataContainer.mStickList.subList(0, dataContainer.mSize));
|
|
|
|
|
+
|
|
|
|
|
+// minusstickchart.setDecimalNum(mDecimalNum);
|
|
|
|
|
+ minusstickchart.postInvalidate();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|