You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Search/Replace:
- Check "Whole word only"
- From: i
- To: shift
Replace all
Note the "PRICE_CLOSEshift shift" in the first (and other) lines of the result.
ma20p = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSE, i); ma20p1 = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSE, i+1); ma20p2 = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSE, i+2); ma5p= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE, i); ma5p1= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE, i+1); ma5p2= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE, i+2); diff0 = ma5p - ma20p; diff1 = ma5p1 - ma20p1; diff2 = ma5p2 - ma20p2; double tz, exactcross, deltatime= 2.0; // computed beween bar i and i+2 // equate ma5p2 + tz * deltaprice5 = ma20p2 + tz * deltaprice20 tz= (ma20p2 - ma5p2) * deltatime / ((ma5p - ma5p2) - (ma20p - ma20p2)); exactcross= ma5p2 + tz * (ma5p - ma5p2) / deltatime; if (tz>=0.0 && tz<=deltatime) { // cross within the time segment of the two samples Print("New Cross: ", TimeToStr(Time[i]), " ", ma5p, ",", ma5p2, " - ", ma20p, ",", ma20p2); Print("New Cross: ", TimeToStr(Time[i]), " at ", exactcross, " (tz= ", tz, ")"); Print("Old/New Difference: ", exactcross - CrossLevel);ma20p = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSEshift shift); ma20p1 = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSE,shift shift+1); ma20p2 = iMA(NULL, PERIOD_M30, 20, 0, ma_method, PRICE_CLOSE,shift shift+2); ma5p= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE,shift shift); ma5p1= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE,shift shift+1); ma5p2= iMA(NULL, PERIOD_M30, 5, 0, ma_method, PRICE_CLOSE,shift shift+2); diff0 = ma5p - ma20p; diff1 = ma5p1 - ma20p1; diff2 = ma5p2 - ma20p2; double tz, exactcross, deltatime= 2.0; // computed beween bar shift and shift+2 // equate ma5p2 + tz * deltaprice5 = ma20p2 + tz * deltaprice20 tz= (ma20p2 - ma5p2) * deltatime / ((ma5p - ma5p2) - (ma20p - ma20p2)); exactcross= ma5p2 + tz * (ma5p - ma5p2) / deltatime; if (tz>=0.0 && tz<=deltatime) { // cross within the time segment of the two samples Print("New Cross: ", TimeToStr(Time[shift]), " ", ma5p, ",", ma5p2, " - ", ma20p, ",", ma20p2); Print("New Cross: ", TimeToStr(Time[shift]), " at ", exactcross, " (tz= ", tz, ")"); Print("Old/New Difference: ", exactcross - CrossLevel);