NexusFi: Find Your Edge


Home Menu

 





Indicator Problem - Question


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one mk77ch with 3 posts (2 thanks)
    2. looks_two Zondor with 1 posts (4 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Tasker_182 with 1 posts (0 thanks)
    1. trending_up 1,503 views
    2. thumb_up 6 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 3 attachments




 
Search this Thread

Indicator Problem - Question

  #1 (permalink)
 
mk77ch's Avatar
 mk77ch 
Switzerland
 
Experience: Advanced
Platform: NinjaTrader
Broker: Dorman
Trading: Currency Futures, ES
Posts: 132 since Oct 2010
Thanks Given: 27
Thanks Received: 350

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
Elite Membership required to download: fxuTsiMacd.zip
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


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? <grin>.

Reply With Quote
  #4 (permalink)
 
mk77ch's Avatar
 mk77ch 
Switzerland
 
Experience: Advanced
Platform: NinjaTrader
Broker: Dorman
Trading: Currency Futures, ES
Posts: 132 since Oct 2010
Thanks Given: 27
Thanks Received: 350


Tasker_182 View Post
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? <grin>.

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

cheers,
mike

Attached Files
Elite Membership required to download: fxuTsiMacd.zip
Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

I made some changes that will tremendously improve its performance.

There is information about efficient coding in this thread.


"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
Elite Membership required to download: fxuTsiMacd.cs
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 
mk77ch's Avatar
 mk77ch 
Switzerland
 
Experience: Advanced
Platform: NinjaTrader
Broker: Dorman
Trading: Currency Futures, ES
Posts: 132 since Oct 2010
Thanks Given: 27
Thanks Received: 350


Zondor View Post
I made some changes that will tremendously improve its performance.

There is information about efficient coding in this thread.


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

cheers,
mike

Started this thread Reply With Quote




Last Updated on April 6, 2013


© 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