Need Understanding

 

val1=0;

val2=0;

if open[Shift+1]close[Shift] then

if close[shift+1]> iBANDS(IBAND,2,MODE_HIGH,Shift+1) then // val1=High[shift];

Begin

ShortFlag=1;

LongFlag=0;

val1=High[shift];

end;

MQL Questions:

1) What does Shift mean? Does it mean the current candlestick? Or a Moving Average?

2) What does Shift+1 mean then?

3) What does val1=High(shift)? What is High(shift)?

Dave

 

I believe shift is for the indicator, meaning it doesnt take current candle, it takes the one before, if you make shift+30 itll mean that the expert will take the 30th candle from current backwards.

Hope I made myself clear here

 

If this be the case, then what is shift(-1) - One Forward?? The terminology syntax of this language is something else. The Dictionary does not even talk about shift.

 

Yes, gazuz is right.

To make it clear, the lowest value of shift is 0 meaning current candle. Shift + 1 means 1 bar backward, so if Shift holds value 10, then Shift + 1 = 11 (the 11th previous bar).

 

having trouble with the shift junction. using a 100 period moving average. shifting back 1 period and 2 periods. If 100 period ma shift 1 is greater than 100 period shift2, then buy visa versa. the expert seems to be trading when it should not be. i have attached a screen capture. the problem may be that the value for the moving avg on the screen may be different from the one calculated internally by the expert giving me misleading results. anybody else have problems with the moving average calculations? maybe someone can help figure why the expert is trading when the moving avg on the screen says it should not be.

thanks

todd

Files:
ma.jpg  90 kb
 

In the shot, i see the ma move slightly upward. That makes ma shift 1 > ma shift 2 true.

 

if you move the cursor down the ma it says 1.7750 for most of it (even where it entered and exited a trade). i thought about it being up slightly so i added 100 period ma shift 1 is greater than 100 period shift2 +0.0001 as per your other thread, but it did not seem to work. maybe i am not doing it right. the ma on the screen may be rounded to 0.0000. not sure how to get it to work properly. any help would be great.

 

here is another shot. the ma appears to be up slightly, but the ma still says 1.7550

Files:
ma2.jpg  98 kb
 

Ah! MAs on chart are rounded accordingly to its scale. Let's say the real value of MA in expert is 1.77504. It will be shown 1.7750 on chart.

If you want the MA values hold in expert to be exactly as on chart then use NormalizeDouble(). E.g. NormalizeDouble(iMA(...),4)

 

scorp

how do you code this? tried this ma1_1 = NormalizeDouble(iMA(100,MODE_EMA,PRICE_CLOSE,1); but when i verify i get an error(too complex expression).

thank you

todd

 

try ma1_1 = NormalizeDouble(iMA(100,MODE_EMA,PRICE_CLOSE,1),4);

Reason: