Moving average- Absolute - Sierra Chart Programming | futures io social day trading
futures io futures trading


Moving average- Absolute
Updated: Views / Replies:285 / 5
Created: by Neo1 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
 

Moving average- Absolute

  #1 (permalink)
Elite Member
Christchurch, New Zealand
 
Futures Experience: Beginner
Platform: SC
Broker/Data: IB, BC, Dx Feed
Favorite Futures: US Equities
 
Neo1's Avatar
 
Posts: 417 since Jul 2014
Thanks: 467 given, 463 received

Moving average- Absolute

I want to return the absolute value of a moving average, so based on a length of "1", input values -1,-2, 3, 4 = 10

I know I need to include the math.h library, and use the fabs() function. When I adjust the code and try to implement fabs() I end up with compiler errors. Can someone please show me how this should be implemented.

Here is the basic code without using fabs().

 
Code
// Test
#include "sierrachart.h"
#include "math.h"

SCDLLName("MABS")
   
SCSFExport scsf_MovingAverageSimple(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Avg = sc.Subgraph[0];

	SCInputRef InputData = sc.Input[0];
	SCInputRef Length = sc.Input[3];

	if (sc.SetDefaults)
	{
		sc.GraphName = "Moving Average - ABS";

		sc.GraphRegion = 0;
		sc.ValueFormat = 2;
		sc.AutoLoop = 1;

		Avg.Name = "Avg";
		Avg.DrawStyle = DRAWSTYLE_LINE;
		Avg.PrimaryColor = RGB(0, 255, 0);
		Avg.LineWidth = 1;
		Avg.DrawZeros = true;

		InputData.Name = "Input Data";
		InputData.SetInputDataIndex(SC_LAST);

		Length.Name = "Length";
		Length.SetInt(10);
		Length.SetIntLimits(1, MAX_STUDY_LENGTH);
		
		sc.FreeDLL = 0;

		return;
	}

		sc.DataStartIndex = Length.GetInt() - 1;

		sc.SimpleMovAvg(sc.BaseDataIn[InputData.GetInputDataIndex()], Avg,  Length.GetInt());
}

"Free markets work because they allow people to be lucky, thanks to aggressive trial and error, not by giving rewards or incentives for skill. The strategy is, then, to tinker as much as possible and try to collect as many Black Swan opportunities as you can"
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
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received


Are you aware that you are using sc.FreeDLL = 0 ?
This in itself can be the reason for the compiling problems.

Reply With Quote
 
  #4 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received

...also, in my studies I use fabs() without including math.h

Reply With Quote
The following user says Thank You to yonatan for this post:
 
  #5 (permalink)
Elite Member
Columbus, OH
 
Futures Experience: Intermediate
Platform: SierraChart
Favorite Futures: CL
 
Posts: 11 since May 2013
Thanks: 39 given, 6 received

I think the following may be what your looking for:

To your existing code,
Add this:
SCSubgraphRef Temp1 = sc.Subgraph[1];

and Change the last line to This:

sc.SimpleMovAvg(sc.BaseDataIn[InputData.GetInputDataIndex()], Temp1, Length.GetInt());
Avg[sc.Index] = fabs(Temp1[sc.Index]);

Reply With Quote
The following user says Thank You to mkata for this post:
 
  #6 (permalink)
Elite Member
Christchurch, New Zealand
 
Futures Experience: Beginner
Platform: SC
Broker/Data: IB, BC, Dx Feed
Favorite Futures: US Equities
 
Neo1's Avatar
 
Posts: 417 since Jul 2014
Thanks: 467 given, 463 received


mkata View Post
I think the following may be what your looking for:

To your existing code,
Add this:
SCSubgraphRef Temp1 = sc.Subgraph[1];

and Change the last line to This:

sc.SimpleMovAvg(sc.BaseDataIn[InputData.GetInputDataIndex()], Temp1, Length.GetInt());
Avg[sc.Index] = fabs(Temp1[sc.Index]);

Nice one @mkata, you nailed it. Thanks.

"Free markets work because they allow people to be lucky, thanks to aggressive trial and error, not by giving rewards or incentives for skill. The strategy is, then, to tinker as much as possible and try to collect as many Black Swan opportunities as you can"
Reply With Quote
The following user says Thank You to Neo1 for this post:

Reply



futures io > > > > > Moving average- Absolute

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Opening Breakouts and Reversals w/Al Brooks

Elite only
 

Introducing daytradr by Jigsaw, new stand-alone platform

Oct 19
 

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
moving average monsieur NinjaTrader 1 November 29th, 2015 05:23 PM
What are these moving average? Mopaditi NinjaTrader 3 September 24th, 2014 03:11 PM
Best Moving Average sharmas Elite Automated Trading 62 April 9th, 2012 06:44 PM
Moving Average Kush NinjaTrader Programming 5 November 6th, 2011 12:49 PM
New Moving Average arnaudlx The Elite Circle 10 January 28th, 2011 05:15 AM


All times are GMT -4. The time now is 05:55 AM.

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-10-17 in 0.09 seconds with 19 queries on phoenix via your IP 54.224.203.224