PDA

View Full Version : Time Since Last Trade


jthom
06-10-2009, 02:50 AM
How is it possible to implement a time on last trade.
Eg: I want to enter a position. Then the time on that position is calculated. Then approximately 30 mins later, once the strategy conditions are met again, do another entry. Not before.

Any Tips??

NinjaTrader_Bertrand
06-10-2009, 04:22 AM
jthom, you could store the trade entry time in a DateTime object and compare it then later for the second entry to take place, easier to implement would be counting the bars passed since the first entry.

http://www.ninjatrader-support.com/HelpGuideV6/BarsSinceEntry.html

jthom
06-10-2009, 06:18 AM
Ok say that Im using Renko 3 bars and ill use the barsince entry method:

protectedoverridevoid OnBarUpdate()
{
if (Historical)
return;
if (CurrentBar < 20)
return;

// Condition set 1
if (BarsSinceEntry() > 10
&& Open[0] > EOTVramBars(0.65, 1.3, true).VramUpConfirm[0]
&& orderId.Length == 0
&& atmStrategyId.Length == 0)


{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);

}


Pretty much nothing happens. Im assuming this will only calculate after an entry has been made? which is <20 >10th bar since last entry?
Is that right?

NinjaTrader_Josh
06-10-2009, 07:28 AM
BarsSinceEntry() is not for ATM orders. It is for NinjaScript orders.