MathPow

이 함수는 밑을 지수로 올립니다.

double  MathPow(
   double  base,         // 밑 
   double  exponent      // 지수 값
   );

매개 변수

base

[in]  밑.

exponent

[in]  지수 값.

반환값

지정된 거듭제곱으로 올려질 밑의 값.

참고

MathPow() 대신에 pow()를 사용하실 수 있습니다.

 

예:

#define GRAPH_WIDTH  750
#define GRAPH_HEIGHT 350
 
#property script_show_inputs
 
#include <Graphics\Graphic.mqh>
 
//--- 입력 매개변수
input double   InpExponentValue  =  2;    // exponent value
 
CGraphic ExtGraph;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 1 스텝에서 0부터 10까지 11개의 값을 얻습니다.
   vector X(11,VectorArange);
   Print("vector X = \n",X);
//--- InpExComponentValue 거듭제곱으로 된 X 벡터의 각 값을 계산합니다.
   X=MathPow(X,InpExponentValue);
   Print("MathPow(X,",(string)InpExponentValue,") = \n",X);
   
//--- 계산된 값을 벡터에서 배열로 전송합니다.
   double y_array[];
   X.Swap(y_array);
 
//--- 계산된 벡터 값의 그래프를 그립니다.
   CurvePlot(y_array,clrDodgerBlue);
 
//--- Escape 또는 PgDn 키를 눌러 그래프를 삭제하고(스크린샷 하기) 종료할 때까지 기다립니다.
   while(!IsStopped())
     {
      if(StopKeyPressed())
         break;
      Sleep(16);
     }
 
//--- 모두 삭제
   ExtGraph.Destroy();
   /*
  결과:
   vector X = 
   [0,1,2,3,4,5,6,7,8,9,10]
   MathPow(X,2.0) = 
   [0,1,4,9,16,25,36,49,64,81,100]
   */
  }
//+------------------------------------------------------------------+
//| '스텝' 증분 단위인 '값'으로 벡터 채우기                              |
//+------------------------------------------------------------------+
template<typename T
void VectorArange(vector<T> &vec,T value=0.0,T step=1.0
  { 
   for(ulong i=0i<vec.Size(); i++,value+=step
      vec[i]=value
  }
//+------------------------------------------------------------------+
//| ESC를 누르면 'true'를 반환합니다                                    |
//| PgDn을 누르면 그래프 스크린샷을 찍고 'true'를 반환합니다               |
//| 그렇지 않으면 'false'를 반환 합니다                                 |
//+------------------------------------------------------------------+
bool StopKeyPressed()
  {
//--- ESC를 누르면 'true'를 반환합니다.
   if(TerminalInfoInteger(TERMINAL_KEYSTATE_ESCAPE)!=0)
      return(true);
//--- PgDn을 누르고 그래프 스크린샷이 성공적으로 촬영되면 'true'를 반환합니다
   if(TerminalInfoInteger(TERMINAL_KEYSTATE_PAGEDOWN)!=0 && MakeAndSaveScreenshot(MQLInfoString(MQL_PROGRAM_NAME)+"_Screenshot"))
      return(true);
//--- 'false'를 반환합니다 
   return(false);
  }
//+------------------------------------------------------------------+
//| 그래프 객체를 만들고 곡선 그리기                                     |
//+------------------------------------------------------------------+
void CurvePlot(double &x_array[], double &y_array[], const color colour)
  {
   ExtGraph.Create(ChartID(), "Graphic"000GRAPH_WIDTHGRAPH_HEIGHT);
   ExtGraph.CurveAdd(x_arrayy_arrayColorToARGB(colour), CURVE_LINES);
   ExtGraph.IndentUp(30);
   ExtGraph.CurvePlotAll();
stringtext1="그래프를 삭제하고 스크립트를 중지하려면 ESC를 누르십시오. 또는";
stringtext2=" 화면을 만들고 그래프를 삭제하고 스크립트를 중지하려면 PgDn을 누르세요";
   ExtGraph.TextAdd(549text1ColorToARGB(clrBlack));
   ExtGraph.TextAdd(54,21text2ColorToARGB(clrBlack));
   ExtGraph.Update();
  }
//+------------------------------------------------------------------+
//| 스크린샷을 찍어 이미지를 파일로 저장                                  |
//+------------------------------------------------------------------+
bool MakeAndSaveScreenshot(const string file_name)
  {
   string file_names[];
   ResetLastError();
   int selected=FileSelectDialog("Save Picture"NULL"All files (*.*)|*.*"FSD_WRITE_FILEfile_namesfile_name+".png");
   if(selected<1)
     {
      if(selected<0)
         PrintFormat("%s: FileSelectDialog() function returned error %d"__FUNCTION__GetLastError());
      return false;
     }
   
   bool res=false;
   if(ChartSetInteger(0,CHART_SHOW,false))
      res=ChartScreenShot(0file_names[0], GRAPH_WIDTHGRAPH_HEIGHT);
   ChartSetInteger(0,CHART_SHOW,true);
   return(res);
  }

 

결과:

MathPow_Screenshot