Can someone please find the mistake, thanks - page 2

 
WHRoeder:
You can't read the future


I dont want to read the future, I want to shift the moving average by one bar and compare the close of the bar 1,2 and 3 with respective values of moving average but with one bar shift forward, right now it will compare present moving average values

thx,

Jay

 
Jay007:


I dont want to read the future, I want to shift the moving average by one bar and compare the close of the bar 1,2 and 3 with respective values of moving average but with one bar shift forward, right now it will compare present moving average values

      dClose1 = Close[pos+1]; 
      dClose2 = Close[pos+2];
      dClose3 = Close[pos+3];      
      3SMA1= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+1); 
      3SMA2= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+2); 
      3SMA3= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+3); 
On the last ittereation Pos == 0 you ARE comparing close of bar 1,2, and 3 with the corresponding MA of bar 1,2, and 3. If you compare the close of bar 0 that's not yet final. Likewise is the MA.
Reason: