pending orders

Posted By: deweymcg

pending orders - 11/07/12 13:26

Please forgive the newbie question but I am new to coding. I am trying to write a script where when certain conditions are met a pending buy or sell order is placed when price hits the value of tema. The pseudocode would be:

If (condition) then

Buy (MoneyManagement computed) lots at TEMA( 74 )[1]; (and the reverse for a sell order).


I know you can call a function inside an enterLong() command, but I can't figure out how to do this.
Posted By: jcl

Re: pending orders - 11/07/12 14:11

The function inside enterlong is for trade exit only, not (yet) for trade entry. For entering, just check if the price hits TEMA and then place a market order.
Posted By: deweymcg

Re: pending orders - 11/07/12 18:54

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?
Posted By: jcl

Re: pending orders - 11/08/12 16:50

Sure, enter at market when the price crosses the TEMA _and_ the first condition was met within the last n bars.
Posted By: PriNova

Re: pending orders - 11/08/12 17:58

Originally Posted By: deweymcg
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:
Code:
if(condition1 == true)
{
   var TEMAvalue = TEMA(...);
}
if(priceClose() == TEMAvalue)
{
   enterTrade();
}

Posted By: deweymcg

Re: pending orders - 11/08/12 19:12

Thanks! That looks like it will do the trick. I will test this when I get back home
© 2024 lite-C Forums