Please help with this quick piece of code....

 

Hi

I am using this code that time "t" and then works forward to the current candle plus 3

 int bar = iBarShift(Symbol(),Period(),t,false);

   if(prewBar==0){prewBar = bar;}
   
 if(Close[0]>Open[0]){
   for(i=3;i<bar;i++){

I am wondering how I can get it to work backwards, so it starts and candle plus 3 then work back to the time specified for "t"?

Thanks

Antony

 
tonyjms2005:

Hi

I am using this code that time "t" and then works forward to the current candle plus 3

I am wondering how I can get it to work backwards, so it starts and candle plus 3 then work back to the time specified for "t"?

Thanks

Antony

Your code starts at candle(3) and works toward candle(bar). If you mean to go in the opposite direction:

if(Close[0]>Open[0]){
   for(i=bar;i>3;i--){
 
tonyjms2005:

Hi

I am using this code that time "t" and then works forward to the current candle plus 3

I am wondering how I can get it to work backwards, so it starts and candle plus 3 then work back to the time specified for "t"?

You mean it works from bar+3 back to bar ?

for(i=bar+3;i>=bar;i--){

A question, did you really mean to be using Close[0] ? it is a moving target and is the same as Bid . . . Close[0] is not fixed until the 0 bar becomes the 1 bar . . .

 
RaptorUK:

You mean it works from bar+3 back to bar ?

A question, did you really mean to be using Close[0] ? it is a moving target and is the same as Bid . . . Close[0] is not fixed until the 0 bar becomes the 1 bar . . .

Haha that is a good point Raptor, that is a contridiction hey, well spotted. I overlooked it as bid and ask, but you are right, Close can't be compared to Open when the candle is still in formation on 0 bar.

I am really curious though, I have been searching for a good tutorial on the whole ordering thing, can you suggest a good link for me, I seem to get the obvious links but not the good ones on this topic. I am still really stuck on my ordering issue really so was looking, cheers.

 
Funky:

I am really curious though, I have been searching for a good tutorial on the whole ordering thing, can you suggest a good link for me, I seem to get the obvious links but not the good ones on this topic. I am still really stuck on my ordering issue really so was looking, cheers.

Not 100% sure what you mean by "ordering" . . do you order as in bar numbers, etc or do you mean placing Orders ? have you checked out the Book ? https://book.mql4.com// there is a lot of good info, you can search it too using the search box top right of this page and then select Book on the left.
 
RaptorUK:
Not 100% sure what you mean by "ordering" . . do you order as in bar numbers, etc or do you mean placing Orders ? have you checked out the Book ? https://book.mql4.com// there is a lot of good info, you can search it too using the search box top right of this page and then select Book on the left.


Thanks Raptor. I must say this is an awesome website to help learn, thanks.

Reason: