Need Understanding

To add comments, please log in or register
Dave77
168
Dave77  

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

gazuz
1264
gazuz  

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

Dave77
168
Dave77  

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.

Scorpion
4008
Scorpion  

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).

rondio
16
rondio  

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
Scorpion
4008
Scorpion  

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

rondio
16
rondio  

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.

rondio
16
rondio  

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

Files:
ma2.jpg 98 kb
Scorpion
4008
Scorpion  

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)

rondio
16
rondio  

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

Scorpion
4008
Scorpion  

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

12
To add comments, please log in or register