Multicharts Indicator Days over/under SMA - MultiCharts | futures io social day trading
futures io futures trading


Multicharts Indicator Days over/under SMA
Updated: Views / Replies:1,354 / 16
Created: by venatrix 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
 

Multicharts Indicator Days over/under SMA

  #1 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received

Multicharts Indicator Days over/under SMA

Hello,

I am a new Multicharts user and PowerLanguage is my first programming language,
so it is very hard at the Moment

This is my first code and I don´t have a solution, maybe somebody can help me.

I try to track the Days when the Price is over or under the EMA and plot it under the Chart.

For Example Price is 3 Days over EMA then +3 -> next Day Price is under EMA = -1

This code works only for Days over EMA or under EMA, but not together.

Where is the mistake or what can I do better?

 
Code
{
Mai 2015
This Indicator tracks the Days when price is over or under the SMA.
}

inputs:
	Price		( Close ),
	Length		( 21 ),
	Displace	( 0 ) ;

variables:
	var0		( 0 ),
	move 		( 0 ),
	OverEmav	(0),
	UnderEmav	(0);

var0 = Average( Price, Length );

//if Close > var0 then OverEmav = 1;
//if OverEmav >= 1 then move = move +1;
//If close < var0 then move = 0;

If close < var0 then UnderEmav = -1;
If UnderEmav <= -1 then move = move -1;
if close > var0 then move = 0;

 
plot1(move,"Days over/under EMA");
This should be very easy, but I have no idea how to solve it.

Thank you all.

Timo

Reply With Quote
 
  #2 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,534 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Hi Timo,

you can add a check for the previous bar to reset the move value when there is change in the relation of price to the MA.

 
Code
If Close < var0 then 
begin 
 //check if previous bar was also below the average, otherwise set the counter to -1
 if close[1] < var0[1] then
   move = move -1
  else 
    move = -1;
end 
else
if Close > var0 then
begin
//... do the same in here for the case where the close is above the ma
end ;
On a separate matter I would suggest to start using meaningful variable names right. Most of the build in code is not a good example in this case as it uses lots
of var1, var2 or Value1 variable names which makes code much harder to read.

Regards,
ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #3 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received


Hello ABCTG,

thank you for these Tips!
It looks so easy now, but I had no idea how to solve it.

Here is my code:

 
Code
{
Mai 2015
This Indicator tracks the Bars over or under the SMA.
}

inputs:
	Price		( Close ),
	SmaLength	( 21 ),
	Displace	( 0 ) ;

variables:
	SMAv		( 0 ),
	move 		( 0 );

SMAv = Average( Price, SmaLength );

if Close < SMAv then
begin 
//check if previous bar was also below the average, otherwise set the counter to -1
	if close[1] < SMAv [1] then
  	move = move -1
  	else 
   	move = -1; 
end;

if Close > SMAv then
begin
//... do the same in here for the case where the close is above the ma
	if close [1] > SMAv [1] then
 	move = move +1
 	else
  	move = +1;
end;

plot1(move,"Days over/under SMA");

If Plot1 >=1 Then
  SetPlotColor(1, Green); 
If Plot1 <= -1 Then
  SetPlotColor(1, red);

It works and I used better variables. Or could I do something else better?

Thanks again for your help.

Best regards,
Timo

Reply With Quote
The following user says Thank You to venatrix for this post:
 
  #4 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,534 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Hi Timo,

it looks good to me. I don't see any chances that would gain something.

As you increment and decrement a counter (the variable move in this case) in your
code you might at some point stumble over something similar like
 
Code
move += 1 ;
Which (as programmers are lazy ) is just a quicker way of writing
 
Code
move = move + 1 ;
I just thought to point that out for the future, in case you ever come across a similar code expression.

Regards,
ABCTG

Reply With Quote
 
  #5 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received

Hallo ABCTG,

thanks for your comments, really appreciate it!

Best regards,
Timo

Reply With Quote
 
  #6 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received

Hello ABCTG,

maybe you can give me another tip how to solve this problem.

I would like to track the Highest Value of the Days Over or Under the SMA.
I guess I can do this with arrays, correct?

I wrote this code to test programming with arrays, but I dont get a solution for my problem:

 
Code
inputs:
	Price		( Close ),
	SmaLength	( 21 ),
	Displace	( 0 ) ;

variables:
	ArrayCounter	( 0 ),
	SMAv		( 0 ),
	HiMove		( 0 ),
	LoMove		( 0 ),
	move 		( 0 );
	
Array: 
HiOverSMA[1000]	( 0 ),
LoUnderSMA[1000]	( 0 );


SMAv = Average( Price, SmaLength );

If  currentbar = 1 then ClearPrintLog;

if Close < SMAv then
begin 
//check if previous bar was also below the average, otherwise set the counter to -	
  	
	Value1 = text_new( D, T, L, NumtoStr( BarNumber, 0 ));
	text_setstyle( Value1, 2, 0);
	ArrayCounter = ArrayCounter +1;
	If ArrayCounter = 1001 then ArrayCounter = 1;
	LoUnderSMA[ ArrayCounter ] = BarNumber;
	Print( D, T," ArrayCounter ", ArrayCounter," Barnumber ", BarNumber," , ",LoUnderSMA[ 1 ]," , ",LoUnderSMA[ 2 ]," , ",LoUnderSMA[ 3 ]," , ",LoUnderSMA[ 4 ]," , ",LoUnderSMA[ 5 ]);
 	
 	if close [1] < SMAv [1] then
  	move = move -1 
  	
  	else 
   	move = -1;
   
end;

In Excel I had this study in 5 minutes, but in Multicharts I am not able to get these information in
hours, very frustrating.

What is the best way to do this in Multicharts?

Thank you.

Best regards,
Timo

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,534 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Hi Timo,

what exactly do you mean with Highest Value of the Days Over or Under the SMA?
If you are just looking for one value (the highest high of the days above the SMA) you could use a variable and always update it to a higher high. When you want to do this for every swing where price is above the SMA simply reset this variable's value when the price is below the SMA.

Something that should get you started is this code:
 
Code
if Price > SMA then
begin

if High > TrackingHi then
TrackingHi = High;

end
else
TrackingHi = -999999;
Regards,
ABCTG

Reply With Quote
 
  #8 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received

Hi ABCTG,

no, I try to store the highest Value of the indicator. For Example:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Here the SPY was 73 Days over the SMA, and I try to store this Indicator value,
not a high of a price.

Best regards,
Timo

Reply With Quote
 
  #9 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,534 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

Hi Timo,

that's no different than storing a price value. You'd use a variable and update its value when the "move" value is larger than the stored value. Simply adapt the code from my previous post.

Regards,
ABCTG

Reply With Quote
 
  #10 (permalink)
Elite Member
Aschaffenburg
 
Futures Experience: Beginner
Platform: NinjaTrader, Multicharts
Favorite Futures: ES
 
Posts: 15 since Feb 2012
Thanks: 4 given, 1 received


Hi ABCTG,

thanks for your really fast answer! I try it later this evening.

Thanks again.

Timo

Reply With Quote

Reply



futures io > > > > Multicharts Indicator Days over/under SMA

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
Looking for NT7 CCI Indicator based on EMA and not SMA Nemesis NinjaTrader 29 March 29th, 2016 05:41 PM
Extended ray for sma, vwap, trix etc. indicator (NT7) Peke5 The Elite Circle 4 October 23rd, 2014 07:21 AM
Idea: Wick-based SMA Indicator (WiSMA) rewex NinjaTrader 19 June 17th, 2013 11:10 AM
SMA + Standard Deviation Indicator dreart NinjaTrader 1 December 10th, 2012 08:13 PM
MultiCharts and IQfeed alignment with 120 days of Tick Data??? benharrell Reviews of Brokers and Data Feeds 36 June 11th, 2011 04:06 PM


All times are GMT -4. The time now is 06:37 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-18 in 0.13 seconds with 20 queries on phoenix via your IP 54.221.93.187