PDA

View Full Version : entry and prices


d.allen101
06-24-2009, 08:23 AM
hi,

illustration: if(Close[0]>Close[1]) EnterLong(); i know that if this condition is true trade price used in back test is the next bar's open...i wanted to know what method or programming logic do i use to execute EnterLong() only if the next bar's open meets some other condition, for example if i wanted the next bar's Open[-1]>High[0], i know i can't do this but this the logic of what i'm attempting to do. if there's a method will you please provide and if there's logic please "tell" me but don't write the code for me! i trying to learn.

thanks

NinjaTrader_Josh
06-24-2009, 08:29 AM
d.allen101,

This is not possible because NinjaTrader will not let you look into the future. If you are going to place the order it will go in regardless of the open price.

d.allen101
06-24-2009, 08:46 AM
i didn't explain myself well. here's my signal logic: if(Close[0]>Close[1]), now if this condition is true i want to take the trade (EnterLong()) only if the next bar's open which in theory would be Open[-1] is greater than the current bar's high which is High[0]. otherwise condition is false. something like this: if(Close[0]>Close[1] && Open[-1]>High[0]) EnterLong();

NinjaTrader_Josh
06-24-2009, 08:50 AM
d.allen101,

You cannot look into the future. When you place the order at the end of the bar there is no notion of the opening price of the next bar. The order gets filled at the open because that is the next tradeable spot.

At the time you submit the order you have no idea what the next open price is going to be.

d.allen101
06-24-2009, 08:59 AM
i realize i can't look into the future but what i'm saying is there's a condition placed on where the future opening price will be RELATIVE to the current price bar's high, low or whatever current price point i choose. for example if you get a signal right now on a 5 min bar that instructs you to go long at the NEXT 5 min bar's open "BUT" only if the next 5 min bar's open is greater than the CURRENT 5 mins bars high why is this not doable?

NinjaTrader_Josh
06-24-2009, 09:07 AM
No. You cannot look into the future therefore you cannot run any checks against a future open price. Your order is already in place at the end of the bar. Then it gets filled at the open. At the end of the bar there is no such thing as checking the opening price because it does not exist.

d.allen101
06-24-2009, 09:20 AM
hey josh sorry...i understand, i'm essentially entering a market order by using EnterLong(). well how would do i go about saying: "enter market order only if the market opens higher"?

NinjaTrader_Josh
06-24-2009, 09:29 AM
d.allen101,

You check Open[0] > Open[1], but as expected, the order won't go in until the next bar.

You are asking for intrabar granularity that just doesn't exist in a backtest. You have OHLC at one moment in time (close of the bar) so you can't base any logic off of the open point in time.

http://www.ninjatrader-support2.com/vb/showthread.php?t=6652

d.allen101
06-24-2009, 09:45 AM
hey josh i understand what you were trying to explain now...thanks for being patient with me. i'm new to coding and trading so sometimes things that are relatively simple may take me a minute or two before i understand them conceputually. but thanks again for helping me out (i learned something new today)!