falsedave wrote:I did look over that, In all honesty it was just a direct copy paste from the original MetaNeural Dash. I decided to leave it as it was for the time being leave the trade logic unchanged. A quick scan over to check it worked but nothing else. Then review and optimize later.
OK falseDave, I'm deciding to optimize the core of the code which is intersting me, because of the reversal detection candle, which I intend to use in a future indicator I'd like to have in my charts.
To begin with, here is the exact optimizing code to obtain Daily Bias (which returns 3 possible values: UP, Down, NONE). I just put the code you have given in a procedure I called
GiveDailyBias
Code: Select all
int GiveBiasDaily(string symb, int DailyShift)
{
//--- daily variables
double DCloseNow = iClose(symb,PERIOD_D1, DailyShift ); // previous day close
double DClosePrv = iClose(symb,PERIOD_D1, DailyShift + 1); // close for the day before the last day
double DOpenNow = iOpen(symb,PERIOD_D1, DailyShift); // open
double DOpenPrv = iOpen(symb,PERIOD_D1, DailyShift + 1); // open for the day before the last day
double DHighNow = iHigh(symb,PERIOD_D1, DailyShift); // high
double DHighPrv = iHigh(symb,PERIOD_D1,DailyShift + 1); // high for the day before the last day
double DLowNow = iLow(symb,PERIOD_D1,DailyShift); // low
double DLowPrv = iLow(symb,PERIOD_D1,DailyShift + 1); // low for the day before the last day
double DVolumNow = iVolume(symb,PERIOD_D1,DailyShift); // volume
double DVolumPrv = iVolume(symb,PERIOD_D1,DailyShift + 1); // volume for the day before the last day
double DRange = DHighNow - DLowNow; // range
if( DVolumNow > DVolumPrv )
{
//--- check for long bias of previous day
// clear sign of upwards strength for the previous day
if(DOpenNow <= DLowNow + 0.33*DRange && DCloseNow >= DLowNow + 0.66 * DRange ) return(UP); // DailyBias = UP;
// standard up bar failure
if(DLowNow < DLowPrv && DCloseNow > DOpenNow && DCloseNow > DLowNow +0.625 * DRange) return(UP); // DailyBias = UP;
// up t failure
if(( DCloseNow - DOpenNow) <= ( 5*iATR(symb,PERIOD_D1,14,0)/100 ) && DCloseNow > DOpenNow ) return(UP); // DailyBias = UP;
// up wall failure
if(DLowNow < DLowPrv && DHighNow > DHighPrv && DCloseNow >= DHighPrv) return(UP); // DailyBias = UP;
//--- check for short bias of previous day
// clear sign of downwards strength for the previous day
if(DCloseNow <= DLowNow + 0.33*DRange && DOpenNow >= DLowNow + 0.66*DRange ) return(DOWN); //DailyBias = DOWN;
// standard down bar failure
if(DHighNow > DHighPrv && DCloseNow < DOpenNow && DCloseNow < DHighNow-0.625*DRange) return(DOWN); //DailyBias = DOWN;
// down t failure
if(DOpenNow - DCloseNow <= ( 5*iATR(symb,PERIOD_D1,14,0)/100 ) && DCloseNow < DOpenNow ) return(DOWN); //DailyBias = DOWN;
// down wall failure
if(DLowNow < DLowPrv && DHighNow > DHighPrv && DCloseNow <= DLowPrv ) return(DOWN); //DailyBias = DOWN;
}
// reversal failure
if( MathAbs(DCloseNow - DOpenPrv) < iATR(symb,PERIOD_D1,14,0)/100 )
{
if( DOpenPrv > DClosePrv) return(UP); // DailyBias = UP;
if( DOpenPrv < DClosePrv) return(DOWN); //DailyBias = DOWN;
}
return(NONE);
}
To call this function from your
metaNeural function just put in its beginning this assignment
DailyBias[index] = GiveBiasDaily(symb, 1)
(1 mean the shift of the Daily Bar which is 1 because you are calculating the Previous Daily Bar)
Give me a few moment and I will post the optimization code of Calculation Hourly stuff.