Indicator Problem - Question - NinjaTrader Programming | futures io social day trading

 Notices

Indicator Problem - Question
 Updated: April 6th, 2013 (07:46 AM) Views / Replies: 739 / 5 Created: April 5th, 2013 (03:53 PM) by mk77ch Attachments: 3

 Welcome to futures io.

# Indicator Problem - Question

Elite Member
Switzerland

Broker/Data: Dorman
Favorite Futures: Currency Futures, ES

Posts: 79 since Oct 2010

Indicator Problem - Question

Hello,

Im new to Ninjatrader Programming and today i tried to convert a MetaTrader 4 Indicator to Ninjatrader 7.
When i attach the indicator to a chart, it looks good but with each new bar the values getting wrong.

The MT4 Source Code can be found here: TSI MACD - MQL4 Code Base (TSI_MACD_true, scroll down)

I attached the NT Indicator i made.

I guess the problem is located in the definition of the current bar [0] and [-1] but i really dont know what exactly is wrong.

Code
 rawMtmBuffer[0] = MACD(fast,slow,signal)[0] - MACD(fast,slow,signal)[-1]; absMtmBuffer[0] = Math.Abs(rawMtmBuffer[0]); emaRawMtmBuffer[0] = EMA(rawMtmBuffer,first_R)[0]; emaAbsMtmBuffer[0] = EMA(absMtmBuffer,first_R)[0]; ema2RawMtmBuffer[0] = EMA(emaRawMtmBuffer,second_S)[0]; ema2AbsMtmBuffer[0] = EMA(emaAbsMtmBuffer,second_S)[0]; if(ema2AbsMtmBuffer[0] != 0.0) { tsiBuffer[0] = -100.0 * (ema2RawMtmBuffer[0] / ema2AbsMtmBuffer[0]); } signalBuffer[0] = WMA(tsiBuffer,signalPeriod)[0]; TsiMacd.Set(tsiBuffer[0]); TsiSignal.Set(signalBuffer[0]);
it would be great if somebody of you could give me a hint how i could fix this.

thank you!
mike

Attached Files

Last edited by mk77ch; April 5th, 2013 at 04:05 PM. Reason: added the right indicator...

 April 5th, 2013, 03:53 PM #2 (permalink) Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 April 5th, 2013, 04:43 PM #3 (permalink) Elite Member Cedar Rapids, iowa   Futures Experience: Intermediate Platform: Ninjatrader Broker/Data: Ninjatrader - Continuum Favorite Futures: 6E, TF, 6J     Posts: 626 since Aug 2009 Thanks: 426 given, 1,132 received Zero refers to the current bar, 1 refers to the previous bar, -1 refers to a future bar. Are you trying to predict the future? .

Elite Member
Switzerland

Broker/Data: Dorman
Favorite Futures: Currency Futures, ES

Posts: 79 since Oct 2010

 Zero refers to the current bar, 1 refers to the previous bar, -1 refers to a future bar. Are you trying to predict the future? .

thank you very much that fixed the problem ;-)
i attach the working indicator here so maybe someone find it useful.

cheers,
mike

Attached Files
 The following 2 users say Thank You to mk77ch for this post:

Elite Member
Portland Oregon, United States

Futures Experience: Beginner
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex

Posts: 1,333 since Jul 2009

tsi not coded efficiently

I made some changes that will tremendously improve its performance.

 "If we don't loosen up some money, this sucker is going down." -GW Bush, 2008 “Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014 “The greatest shortcoming of the human race is our inability to understand the exponential function.” Prof. Albert Bartlett
Attached Files
 The following 4 users say Thank You to Zondor for this post:

Elite Member
Switzerland

Broker/Data: Dorman
Favorite Futures: Currency Futures, ES

Posts: 79 since Oct 2010

Zondor

thank you very much!
as im new to ninjatrader coding this helps a lot!

cheers,
mike

 futures io > Indicator Problem - Question

Upcoming Webinars and Events (4:30PM ET unless noted)

December

Dec 13

## Battlestations! Show us your trading desks w/GFF Brokers (\$750 in Prizes)

January

 Similar Threads Thread Thread Starter Forum Replies Last Post babypowder NinjaTrader 9 March 31st, 2014 04:43 PM eseeker EasyLanguage Programming 18 August 2nd, 2012 01:16 PM h20polo NinjaTrader 3 May 24th, 2011 06:44 PM hector24 The Elite Circle 18 April 8th, 2011 09:34 AM GarryM NinjaTrader Programming 8 September 9th, 2009 11:48 PM

 Tags code, dow, futures, indicator, indicators, information, macd, metatrader, mql, mql4, mt4, ninjascript, ninjatrader, ninjatrader 7, programming, signal, source code, values