【发布时间】:2015-12-15 13:40:06
【问题描述】:
使用 MetaTrader 终端 ( MQL4 ),我尝试创建一个反向数组,将其追加(前置)项目。
因此,在每一次变动中,myArray[0] 都成为“最新”值,而之前的值变为 myArray[1],依此类推。
但它听起来比听起来更难。
我试过这样 ->
double myArray = []; // GLOBAL Dynamic array
extern int maxArrayLength = 50; // EXTERN iterable
// -----------------------------------------------------------------------
bool prependToReversedDoubleArray( double& theArray[], double value, int maxLength ) {
int size = ArraySize( theArray ); // LOCAL size
ArraySetAsSeries( theArray, false ); // Normalize the array ( left to right )
ArrayResize( theArray, size + 1 ); // Extend array length
Alert( "test = ", size );
theArray[size] = value; // Insert the new value
ArraySetAsSeries( theArray, true ); // Reverse the array again
if ( ArraySize( theArray ) > maxLength ) {
ArrayResize( theArray, maxLength );
}
return( true );
}
prependToReversedDoubleArray( myArray, 0.1234, maxArrayLength );
【问题讨论】:
-
那么问题是什么,Kev?
-
[0] 元素总是最新的。
-
[0] 元素可能是最新的,问题是,在给定的任务 中,反转数组将无济于事(请参阅下面的详细信息)
标签: low-latency algorithmic-trading mql4 metatrader4 back-testing