I wanted it to place a pending order for the value of TEMA at the time the first condition is met. TEMA would be at a different value if we wait until price converges with TEMA. is there a way to do that?
if i understand you right, you would place a pending order at the actual price of TEMA, when conditions meet.
i suggest you store the price of TEMA in a variable at the given condition and check if price of market hit this value and open then a market order.
Then it doesn't matter if TEMA changes after x-bars, because you captured the price of TEMA at your defined conditions.
pseudocode:
if(condition1 == true)
{
var TEMAvalue = TEMA(...);
}
if(priceClose() == TEMAvalue)
{
enterTrade();
}