求判断均线角度代码

 

求判断均线角度代码

求判断均线角度代码

求判断均线角度代码

求判断均线角度代码

QQ:9810826

 


MathArctan(MathTan(
((price1-price2)/(WindowPriceMax()- WindowPriceMin()))
/
((shift2-shift1)/WindowBarsPerChart())
))
*180/3.14

https://www.mql5.com/en/search

 
谢谢! 请问高手 能不能帮忙在讲解一下。 非常感谢!
 

shift2 shift1 price1 price2 这两个变量没有搞懂 呵呵

谢谢你们 本人很笨 呵呵

 
没有搞懂 ? 那只好建议你复习中学的三角函数和直角坐标系坐标转换,某两个点Y坐标差值 (price1-price2) 对应的X坐标差值((shift2-shift1), 二者换算为屏幕坐标,除即是正切,再反函数就是弧度,在转换为角度。即可得到这两个点连线的角度。
 

非常感谢。 我自己在研究研究 谢谢你!

 

shift2 shift1 price1 price2 这两个变量没有搞懂 这4个变量不知道代表什么

是2个点的价格吗? 还是均线的价格?

 

我按这个做了一段计算均线角度的代码,却得不到任何显示结果。如果把第12行换成第13行的内容能得到显示结果,但明显是错误的。不知道问题出在了哪里,请指教。

int start()
  {
   int    counted_bars=IndicatorCounted();
//----

   int shift1 = 20;
   int shift2 = 31;

   double price1 = iMA(NULL,15,20,0,MODE_SMA,PRICE_CLOSE,shift1);
   double price2 = iMA(NULL,15,20,0,MODE_SMA,PRICE_CLOSE,shift2);
   
   double X = MathArctan(MathTan(((price1-price2)/(WindowPriceMax()- WindowPriceMin()))/((shift2-shift1)/WindowBarsPerChart())))*180/3.14;                  //---- 第12行
   //double X = MathArctan(MathTan(((price1-price2)/(WindowPriceMax()- WindowPriceMin()))/((Time[shift2]-Time[shift1])/WindowBarsPerChart())))*180/3.14;    //---- 第13行
   
   ObjectDelete("tAngle");
   ObjectCreate("tAngle", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("tAngle","" + X + " A", 10, "Arial", White);
   ObjectSet("tAngle", OBJPROP_CORNER, 1);
   ObjectSet("tAngle", OBJPROP_XDISTANCE, 5);
   ObjectSet("tAngle", OBJPROP_YDISTANCE, 360);
        
   
//----
   return(0);
  }
 

double X = MathArctan(MathTan(((price1-price2)/(WindowPriceMax()- WindowPriceMin()))/((shift2-shift1)/WindowBarsPerChart())))*180/3.14; //---- 第12行
Print(X," ",price1," ",price2,shift2," ",shift1); ///检查输出结果

 

标记一下 留作参考

 
DxdCn 写道 >>

double X = MathArctan(MathTan(((price1-price2)/(WindowPriceMax()- WindowPriceMin()))/((shift2-shift1)/WindowBarsPerChart())))*180/3.14; //---- 第12行
Print(X," ",price1," ",price2,shift2," ",shift1); ///检查输出结果

非常奇怪,打印出来的是这样的结果:


全是:zero divide。如果把第12行换成第13行的内容,打印出来的是五个参数的数值(31与前面的值没放空格):


不知道问题在哪里,理论上看(shift2-shiift1)应该有正确的输出结果。