Logarithm & SMA Issue - NinjaTrader Programming | futures io social day trading
futures io futures trading


Logarithm & SMA Issue
Updated: Views / Replies:1,081 / 3
Created: by srgtroy Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Logarithm & SMA Issue

  #1 (permalink)
Elite Member
Los Angeles, California Republic
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES, Mongolian Horse Futures
 
srgtroy's Avatar
 
Posts: 1,456 since Jan 2011
Thanks: 1,009 given, 2,238 received

Logarithm & SMA Issue

I'm new to NinjaScript and not the world's greatest programmer so if this is a stupid question please excuse me.

I would like to plot the value of the 21 period SMA of the logarithms of the close values of each bar.

However, the Math.Log function won't let me use a DataSeries value. And the SMA function won't let me use a double value. How can I get around this.

Plot0.Set(SMA(Math.Log(Close[0])), 21)); is a no go.

Here's some simple code I tried to get around it but it didn't work. It should help illustrate the problem though.

double cl = Close[0];
double Lcl = Math.Log(cl);
DSOne.Set(Lcl);
Plot0.Set(SMA(DSOne,
21));

Any help would be greatly appreciated!

Reply With Quote
 
  #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.

 
  #3 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary



srgtroy View Post
I'm new to NinjaScript and not the world's greatest programmer so if this is a stupid question please excuse me.

I would like to plot the value of the 21 period SMA of the logarithms of the close values of each bar.

However, the Math.Log function won't let me use a DataSeries value. And the SMA function won't let me use a double value. How can I get around this.

Plot0.Set(SMA(Math.Log(Close[0])), 21)); is a no go.

Here's some simple code I tried to get around it but it didn't work. It should help illustrate the problem though.

double cl = Close[0];
double Lcl = Math.Log(cl);
DSOne.Set(Lcl);
Plot0.Set(SMA(DSOne,
21));

Any help would be greatly appreciated!

You need to declare a new DataSeries in the Variables section, for example
 
Code
private DataSeries logPrice;
then initialize this DataSeries object in the Initialize() Section
 
Code
logPrice = new DataSeries(this);
Then you can use it in OnBarUpdate():
 
Code
logPrice.Set(Math.Log(Input[0]));
Value.Set(SMA(logPrice, 21)[0]);
The point is that you need a DataSeries object to be able to apply the SMA; you cannot apply it to a variable of type double.

But what do you want to do with a SMA of the logarithm of price?

You cannot display it on the main panel, and for intraday charts you definitely do not need it.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #4 (permalink)
Elite Member
Los Angeles, California Republic
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES, Mongolian Horse Futures
 
srgtroy's Avatar
 
Posts: 1,456 since Jan 2011
Thanks: 1,009 given, 2,238 received

Thanks for the help.

I did setup the necessary DataSeries info in the Variables and Initialize sections. That didn't turn out to be the problem. Nevertheless, you're example helped me figure it out. I noticed the first letter in logPrice was not capitalized, so I changed all the first letters I had to small caps and it worked.

Thanks, again.

Reply With Quote

Reply



futures io > > > > > Logarithm & SMA Issue

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
AnaVisualEMA to SMA Doppio NinjaTrader Programming 7 May 11th, 2015 01:24 PM
SMA Simple Trading websouth NinjaTrader 5 July 14th, 2012 09:56 AM
can daily&weekly indy work from monthly SMA in MA? nt6.5 mystiq NinjaTrader 4 February 27th, 2011 11:40 AM
SMA Big Mike Platforms, Tools and Indicators 0 June 28th, 2010 04:42 AM
SMA over/under mahlonhersh NinjaTrader 1 February 12th, 2010 06:10 PM


All times are GMT -4. The time now is 07:12 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.09 seconds with 19 queries on phoenix via your IP 54.226.227.175