NexusFi: Find Your Edge


Home Menu

 





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


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one spinnybobo with 8 posts (1 thanks)
    2. looks_two albertjay with 5 posts (1 thanks)
    3. looks_3 xplorer with 5 posts (0 thanks)
    4. looks_4 maryfromcolorado with 2 posts (0 thanks)
    1. trending_up 13,657 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 22 posts
    2. attach_file 0 attachments




 
Search this Thread
  #21 (permalink)
maryfromcolorado
Denver CO USA
 
Posts: 32 since Sep 2016
Thanks Given: 0
Thanks Received: 13

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.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Datafeed for Atas
Platforms and Indicators
Daytrading to swingtrading
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
  #22 (permalink)
 
spinnybobo's Avatar
 spinnybobo 
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
Posts: 173 since Aug 2009
Thanks Given: 105
Thanks Received: 61


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 X Reply With Quote
  #23 (permalink)
maryfromcolorado
Denver CO USA
 
Posts: 32 since Sep 2016
Thanks Given: 0
Thanks Received: 13


Yes, definitely looks timing related (FirstTickOfBar vs OnBarClose), as Close[0] changes with every tick. I will keep that in mind, but for now I have given up on NT, as support couldn't answer my questions on unmanaged strategies. The big issue is they have no Order.Close function like every other trading language I''ve used. And the only strategy they could point me to as an example is CamarillaPointsUnmanaged. One, when ran in real mode it bombs with an order reject. And two, it stops out or hits profit target. That's the only way to get out of the order.

If I missed something, I would love to know how to close an order. I entered a reverse BuyToCover or Sell to get out and sometimes it works, and sometimes it opens up new positions.

Thanks.


Reply With Quote




Last Updated on October 18, 2016


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts