Finding correct bar AFTER the first entry bar?

Back to topics list To post a new topic, please log in or register
DomGilberto 2014.09.11 15:10

As I want my order to close based upon something like "If( BarClose 1 > BarClose 0)"  for longs, how can I write the section so that it WAITS for "Bar 0" above to close BEFORE checking the comparison?

 For a visual example:


In this example above, because Bar 1 Close was GREATER than Bar 2 close, DO NOT close the order. Now if Bar 0 closes < Bar 1 close price, CLOSE the order.

I know this is simple, but my brain is fried today.

 Any help will be greatly appreciated :) 

gooly 2014.09.11 15:22 #

As far as I understand you want to wait until the Bar[0] has closed?

If so you have to compare Bar[1] and Bar[2] at the open of Bar[0].

So if (in your picture) the order was opened at Bar[2] (this will become Bar[3]) and then at open of the (new) Bar[0] /* TmeOpen != Time[0]){TmeOpen = Time[0];} */

CloseOrder(..) if (Close[2]>Close[1])

DomGilberto 2014.09.11 15:42 #
Thanks for your reply, you've lost me a little. Are you talking about the first screenshot or the second one?
DomGilberto 2014.09.11 15:57 #
if( Time[0] > OrderOpenTime() )
  if( Close[2] > Close[1] )
I'm pretty sure this has sorted it... Thanks for your post. You basically made me think about comparing times in the bars!
Back to topics list  

To add comments, please log in or register