Enter on CalOnBarClose=True, but Exit Immediately on X Ticks | Traders Hideout


futures.io - futures trading strategies, market news, trading charts and platforms


Traders Hideout


Discuss day trading practices and futures trading strategies on this forum for all markets. This forum is also for discussing and reviews for brokers, data feeds, and commercial or third party add-ons




 

Enter on CalOnBarClose=True, but Exit Immediately on X Ticks

  #22 (permalink)

Crete, IL/USA
 
Trading Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 178 since Aug 2009
Thanks: 103 given, 50 received


maryfromcolorado View Post
SpinnyBobos suggestion of using OnMarketData seems to be the way to go, unless you need to backtest.

Just curious why do you not want to use CalcOnBarClose = false ?

Thanks.

for me, using OnBarClose = false becomes problematic when you need values for each bar from things.

I don't know how it is with using indicators like SMA or stochastics and stuff, but if you use

 
Code
protected override void Initialize()
{
      CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
    if (FirstTickOfBar)
    {
         if (Close[0] > someValue)
           // do something
    }
}
Unless there is a different way that I don't know about, I am thinking this is how you would normally get around using OnBarClose = false through using FirstTickOfBar

When you compare using the same exact logic with

 
Code
protected override void Initialize()
{
      CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
     if (Close[0] > someValue)
        // do something
}
they don't always give the same values. Therefore if your strategy is heavily reliant on things being exact with data values, then it makes sense to use OnBarClose = true

If you have to backtest something, just

Add(PeriodType.Tick, 1); // to Initialize()

just make sure you download the data first before you load the chart so it does not take forever to load.

Follow me on Twitter Visit my Facebook Reply With Quote