opening and closing trades...

 
This may be a question that has been answered before. However, I could not find it in the forum.

When writing expert advisor code, can I write code to make desicsions on the current bar or do I have to use the previous bar for the decision and trade a bar latter?

Thanks,
Dan
 
it depends from your trade strategy. In common case both solutions are possible
 
Are there examples of using the current bar corectly? When I try to use the current bars information to make decisions, I often have trouble.

For example,
if (iClose(NULL,0,0) <= (PL - tenP) )
{
CloseMyOrder();
}

When I try things like this, I do not get an action. But when I use the prevoius bar, I can often get an action but too late.
 
The current bar is the one 'under construction' which has it's Open price set only. Close and likely High and Low are subjects to change from Bid prices arriving before the bar is complete.
In your case iClose(NULL,0,0) is absolutely the same as Close[0], which in turn is Bid price in a tick handler (start() function) effectively. Except the latter gives a direct reference that is much more efficient from the performance perspective.
Just reread your last sentence and think. Aren't you trying to see the future, even the nearest though?
 
thanks for the comments...I guess what I am trying to do is the following. I have a price that I have determined to be the place to sell per a pivot point, indicator or some other beast on a 15min bar chart. I would like to place my sell order as soon as possible after the price penetrates this level during the 15min bar rather than waiting for the next bar. The reason I do not want to wait is due to the fact that some of these bars could be quite large and I will miss the oportunity for movement if I wait for the bar to close.
Reason: