NexusFi: Find Your Edge


Home Menu

 





crossing an indicator for backtesting


Discussion in NinjaTrader

Updated
    1. trending_up 2,040 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

crossing an indicator for backtesting

  #1 (permalink)
 yeshe 
San Fransisco Ca
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB
Trading: forex
Posts: 17 since Jan 2014
Thanks Given: 5
Thanks Received: 1

Hello forum,

I want to do something very easy but cannot figure it out

I want while BACKTESTING as soon as the price >= upperBowlingerBand go long

I have e-mailed back and forth a lot with Ninjatrader

they came up with the following code

The code seems not logical to me and sometimes it does not work.

In this forum i saw one of Mikes great videos, in which he mentions:

"NinjaTrader is not capable of submitting intrabar orders in backtesting. Live strategies can submit intrabar orders using calculate bar close = false. Trying to simulate IOG within a backtestable strategy in NinjaTrader requires writing custom code to use MTF and try to work-around the problem, and it adds a great deal of complexity, plus MTF doesn't even work in current beta's of NinjaTrader."

Can this simple condition be programmed in Ninjatrader (for Backtesting)?


Would love some expertise from this forum

many tx

Yeshe


protected override void Initialize()
{
CalculateOnBarClose = true;
// this adds the tick secondary data series
Add(PeriodType.Tick, 1);




protected override void OnBarUpdate()
{
// this makes sure that the script is processed with tick data
if (BarsInProgress != 1)
return;



if (Closes[1][1] < Bollinger(Closes[0], 2,14).Upper[1] &&
Closes[1][0] >= Bollinger(Closes[0], 2,14).Upper[0])
{


// enter order on tick series
EnterLong(1, 1, "longOrder");
}
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 yeshe 
San Fransisco Ca
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB
Trading: forex
Posts: 17 since Jan 2014
Thanks Given: 5
Thanks Received: 1


Unfortunately no answers yet from this forum

I have something to add since my ongoing investigation on this item.

Ninjatrader confirmed it is not possible:

"I've been getting assistance from our development, however, this is not a very common question. Intra-bar granularity is mostly used for getting proper exits in backtest. Finding a crossover using intra-bar granularity is not a question I've had to answer before."


The final code is

if (Closes[0][0] < Bollinger(Closes[0], 2,14).Upper[0] &&
Closes[1][0] >= Bollinger(Closes[0], 2,14).Upper[0])

This will refer to the Upperbowlinger of the recently closed primary bar. But will not refer to the actual BB value (between two primary bars).

Is it possible within Multicharts?

eagerly awaiting your response

Started this thread Reply With Quote
  #4 (permalink)
 yeshe 
San Fransisco Ca
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB
Trading: forex
Posts: 17 since Jan 2014
Thanks Given: 5
Thanks Received: 1

Just to update this thread

Ninja trader is submitting a request to have this implemented.


also Multicharts is not able to solve this

I am wondering if i am asking a strange question, also because of no reply in this forum, i must be the only one having this problem? I run into this problem with every indicator used as an entry- or exitsignal during backtesting.

answer from Multicharts:
primary data is weekly
secondary data is daily

"I have consulted once again with our developers regarding your inquiry.
The code is not able to (daily) refer to bb values between 2 (weekly) bars if the indicator is based on the weekly series.
When the indicator is based on the weekly series there are only two values and a connecting line between them for two weekly bars.
There are no values in-between.
If you want to have values on each daily bar then you need to base the study calculation on a daily series (Format->Study->Format->Properties->Base study on)."

Still would love to know how futures.io (formerly BMT) members deal with this.. or not??
So i can backtest and optimize correctly what seems only possible to do in real time( for now).

Started this thread Reply With Quote
  #5 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

This code will only work if the bar CLOSES above the upper Bollinger band, not if it moves through it within a bar and closes back below it. To backtest that situation, you will need to use EnterLongStopLimit() for order entries. Sorry, I don't have time to write, debug and support a code sample for you at this time but that is something you or your contact at Ninjatrader can look at.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on August 26, 2014


© 2024 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 - Privacy Policy - Downloads - Top
no new posts