📜  CurrencyStrength - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:08.145000             🧑  作者: Mango

代码示例1
//--- input parameters
input int               Inpma_period_     = 20;                   // Ma_Period_
input ENUM_TIMEFRAMES   InpWorkingPeriod  = PERIOD_CURRENT;       // Working timeframe


// Identify the buffer numbers
//
const string   IndicatorName     =  "v2strength";
const int      IndexEUR          = 0;
const int      IndexGBP          = 1;
const int      IndexAUD          = 2;
const int      IndexNZD          = 3;
const int      IndexUSD          = 4;
const int      IndexCAD          = 5;
const int      IndexCHF          = 6;
const int      IndexJPY          = 7;
int            Handle;
double         BufferEUR[3];
double         BufferGBP[3];
double         BufferAUD[3];
double         BufferNZD[3];
double         BufferUSD[3];
double         BufferCAD[3];
double         BufferCHF[3];
double         BufferJPY[3];

int OnInit()
{
   Handle   =  iCustom(Symbol(), InpWorkingPeriod, IndicatorName,
                       Inpma_period_);

   if(Handle==INVALID_HANDLE)
     {
      PrintFormat("Error %i", GetLastError());
      return(INIT_FAILED);
     }
}


void OnDeinit(const int reason)
{
//---
   IndicatorRelease(Handle);
}

void OnTick()
{
// Declare Currency Strength Indicator
   int   cnt   =  CopyBuffer(Handle, IndexEUR, 0, 3, BufferEUR);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle, IndexGBP, 0, 3, BufferGBP);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle,  IndexAUD, 0, 3, BufferAUD);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle, IndexNZD, 0, 3, BufferNZD);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle, IndexUSD, 0, 3, BufferUSD);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle, IndexCAD, 0, 3, BufferCAD);
   if(cnt<3)
      return;
   cnt         =  CopyBuffer(Handle, IndexCHF, 0, 3, BufferCHF);
   if(cnt<3)
      return;   
   cnt         =  CopyBuffer(Handle, IndexJPY, 0, 3, BufferJPY);
   if(cnt<3)
      return;   
   double currentEUR        =  BufferEUR[1];
   double currentGBP        =  BufferGBP[1];
   double currentAUD        =  BufferAUD[1];
   double currentNZD        =  BufferNZD[1];
   double currentUSD        =  BufferUSD[1];
   double currentCAD        =  BufferCAD[1];
   double currentCHF        = BufferCHF[1];
   double currentJPY        = BufferJPY[1];
   double priorEUR          = BufferEUR[0];
   double priorGBP          = BufferGBP[0];
   double priorAUD          =  BufferAUD[0];
   double priorNZD          =  BufferNZD[0];
   double priorUSD          =  BufferUSD[0];
   double priorCAD          =  BufferCAD[0];
   double priorCHF          =  BufferCHF[0];
   double priorJPY          =  BufferJPY[0];

//--- Buy Condition   
     if(currentEUR>currentUSD)

//--- Sell Condition  
     if(currentEUR