我想从最后20 bar获得最高和最低值。我没有获得最高价值的问题,但是我的代码似乎无法正常工作以获得最低价值。只是想知道是否有任何建议。
OnEveryNewBar1();
void OnEveryNewBar1()
{ PipValue = 1;
if ( NDigits == 3 || NDigits == 5 ) PipValue = 10;
if ( BarTime1 < Time[0] ) // we have a new bar opened
{ BarTime1 = Time[0]; // keep the new bar open time
TechnicalAnalysis_S();
TechnicalAnalysis_L();
}
}
void TechnicalAnalysis_S()
{
int m = 2;
int n = 3;
l = 1000;
while ( m <= 20 )
{
if ( 1 < 2 )
{ if ( ( Close[2] > Open[2] ) || ( Close[1] > Open[1] ) ) int i = 2;
while ( i > 0 )
{
if ( Low[i] < l ) l = Low[i];
i = i - 1;
}
print ( "Lowest" + l );
l = 1000;
}
m++;
n++;
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void TechnicalAnalysis_L()
{
int m = 2;
int n = 3;
while ( m <= 20 )
{
if ( 2 > 0 )
{
if ( ( Close[2] < Open[2] ) || ( Close[1] < Open[1] ) ) int i=2;
while ( i > 0 )
{
if ( High[i] > h ) h = High[i];
i = i - 1;
}
print ( "Highest" + h );
h = 0;
}
m++;
n++;
}
}
答案 0 :(得分:1)
虽然代码中有一些奇怪的部分,虽然有些变量缺少它们的声明,但该语言有内置函数。
double aLowestLOW_InTheLast20BARs,
aHighestHIGH_InTheLast20BARs;
// -----------------------------------------------------------------------------
aLowestLOW_InTheLast20BARs = Low[iLowest( _Symbol, // .self
PERIOD_CURRENT, // .self
MODE_LOW, // LOW
20, // Last 20 BARs
0 // from [0]
)
];
// -----------------------------------------------------------------------------
aHighestHIGH_InTheLast20BARs = High[iHighest( _Symbol, // .self
PERIOD_CURRENT, // .self
MODE_HIGH, // HIGH
20, // Last 20 BARs
0 // from [0]
)
];