Kod: Zaznacz cały
void GetWRBArray( string symbol, int timeframe, int bars.back, int& wrb.array[][2], bool mirror = false ) {
// First Dimension = number, Second Dimension, 0 = time, 1 =type
int limit, del.count, array.size, open.file, timeframe.dim;
string file.name;
static int indicator.counted[9];
// comment
if ( timeframe == 1 ) {
timeframe.dim = 1;
} else if ( timeframe == 5 ) {
timeframe.dim = 2;
} else if ( timeframe == 15 ) {
timeframe.dim = 3;
} else if ( timeframe == 30 ) {
timeframe.dim = 4;
} else if ( timeframe == 60 ) {
timeframe.dim = 5;
} else if ( timeframe == 240 ) {
timeframe.dim = 6;
} else if ( timeframe == 1440 ) {
timeframe.dim = 7;
} else if ( timeframe == 10080 ) {
timeframe.dim = 8;
} else if ( timeframe == 43200 ) {
timeframe.dim = 9;
}
if ( indicator.counted[timeframe.dim] == 0 ) {
// Check for saved indicator.cunted
file.name = StringConcatenate( symbol,"-M", timeframe, "-Zone-IndicatorCounted.DAT" );
open.file = FileOpen( file.name, FILE_BIN|FILE_READ );
if ( open.file > 0 ) {
FileReadArray( open.file, indicator.counted, 0, ArraySize( indicator.counted ) );
FileClose( open.file );
}
}
if ( ArrayRange( wrb.array, 0 ) == 0 ) {
// Check for saved Array
// Load Array Size
file.name = StringConcatenate( symbol,"-M", timeframe, "-WRB-Zones-Array-Size.DAT" );
open.file = FileOpen( file.name, FILE_BIN|FILE_READ );
if ( open.file > 0 ) {
array.size = FileReadInteger( open.file );
FileClose( open.file );
}
if ( array.size > 0 ) {
// Load Array
file.name = StringConcatenate( symbol,"-M", timeframe, "-WRB-Zones-Array.DAT" );
open.file=FileOpen( file.name, FILE_BIN|FILE_READ );
if ( open.file > 0 ) {
ArraySetAsSeries( wrb.array, true );
ArrayResize( wrb.array, array.size );
FileReadArray( open.file, wrb.array, 0, array.size );
FileClose( open.file );
for ( int c = 0; c < array.size; c++ ) {
if ( timeframe == 60 )Print(" w miejscu: ", c," jest zapisany czas: ",TimeToStr( wrb.array[c][0] ) );
}
}
}
}
if ( ArrayRange( wrb.array, 0 ) > 0 ) {
// Validate Array Data
for( int i = 0; i < ArrayRange( wrb.array, 0 ); i ++ ) {
if ( iBarShift( symbol, timeframe, wrb.array[i][0] ) > bars.back ) {
del.count++;
}
}
// Delete not valid data
array.size = ArrayRange( wrb.array, 0 ) - del.count;
ArraySetAsSeries( wrb.array, false );
ArrayResize( wrb.array, array.size );
ArraySetAsSeries( wrb.array, true );
}
limit = MathMin( bars.back, iBarShift( symbol, timeframe, wrb.array[0][0] ) );
limit = MathMin( limit, iBarShift( symbol, timeframe, indicator.counted[timeframe.dim] ) );
if ( timeframe == 5 )Print( "limit ", limit );
if ( timeframe == 5 )Print( "last.time ", iBarShift( symbol, timeframe, wrb.array[0][0] ) );
for ( i = limit-1; i >= 0; i-- ) {
indicator.counted[timeframe.dim] = iTime( symbol, timeframe, i );
if ( iClose( symbol, timeframe, i ) > iOpen( symbol, timeframe, i ) ) {
// Look for wrb
if ( isWRB( symbol, timeframe, i ) >= is.bull.wrb ) {
ArraySetAsSeries( wrb.array, false );
ArrayResize( wrb.array, ArrayRange( wrb.array, 0 ) + 1 );
ArraySetAsSeries( wrb.array, true );
// Save Time
wrb.array[0][0] = iTime( symbol, timeframe, i );
// Look for wrb hidden gap
if ( isWRB( symbol, timeframe, i ) == is.bull.wrb.hg ) {
// Look for wrb zone
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isSwingPoint_1( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isSwingPoint_2( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_1( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_2( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_3( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_4( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
// Save hg
wrb.array[0][1] = is.bull.wrb.hg;
}
}
if ( wrb.array[0][1] == 0 ) {
// Save hg
wrb.array[0][1] = is.bull.wrb;
}
// Mirror type
if ( mirror ) {
wrb.array[0][1] *= -1;
}
}
} else if ( iClose( symbol, timeframe, i ) < iOpen( symbol, timeframe, i ) ) {
if ( isWRB( symbol, timeframe, i ) <= is.bear.wrb ) {
ArraySetAsSeries( wrb.array, false );
ArrayResize( wrb.array, ArrayRange( wrb.array, 0 ) + 1 );
ArraySetAsSeries( wrb.array, true );
// Save Time
wrb.array[0][0] = iTime( symbol, timeframe, i );
// Look for wrb hidden gap
if ( isWRB( symbol, timeframe, i ) == is.bear.wrb.hg ) {
// Look for wrb zone
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_1( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isSwingPoint_1( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isStrongContinuation_2( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
wrb.array[0][1] = isSwingPoint_2( symbol, timeframe, i );
}
if ( wrb.array[0][1] == 0 ) {
// Save hg
wrb.array[0][1] = is.bear.wrb.hg;
}
}
if ( wrb.array[0][1] == 0 ) {
// Save hg
wrb.array[0][1] = is.bear.wrb;
}
// Mirror type
if ( mirror ) {
wrb.array[0][1] *= -1;
}
}
}
}
// Save WRB Array to file
array.size = ArrayRange( wrb.array, 0 );
if ( array.size > 0 ) {
for ( c = 0; c < array.size; c++ ) {
if ( timeframe == 60 ) Print("zapisuje w tablicy na miejscu: ", c," czas: ",TimeToStr( wrb.array[c][0] ) );
}
// Save Array Size
file.name = StringConcatenate( symbol,"-M", timeframe, "-WRB-Zones-Array-Size.DAT" );
open.file = FileOpen( file.name, FILE_BIN|FILE_WRITE );
if ( open.file > 0 ) {
FileWriteInteger( open.file, array.size );
FileClose( open.file );
}
// Save Array Data
file.name = StringConcatenate( symbol,"-M", timeframe, "-WRB-Zones-Array.DAT" );
open.file=FileOpen( file.name, FILE_BIN|FILE_WRITE );
if ( open.file > 0 ) {
FileWriteArray( open.file, wrb.array, 0, array.size );
FileClose( open.file );
}
// Save Indicator Counted
file.name = StringConcatenate( symbol,"-M", timeframe, "-Zone-IndicatorCounted.DAT" );
open.file=FileOpen( file.name, FILE_BIN|FILE_WRITE );
if ( open.file > 0 ) {
FileWriteArray( open.file, indicator.counted, 0, ArraySize( indicator.counted ) );
FileClose( open.file );
}
}
}
Wytnij co tylko Ci się podoba. Dzięki za chęci.