NexusFi: Find Your Edge


Home Menu

 





Multicharts Indicator Days over/under SMA


Discussion in MultiCharts

Updated
    1. trending_up 5,612 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 16 posts
    2. attach_file 0 attachments




 
Search this Thread
  #11 (permalink)
 venatrix 
Aschaffenburg
 
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1

Hello ABCTG,

thank you again, I have a solution and only need a small tip to finish.

Everything looks good:



Here is the Code:

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

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

variables:
	SMAv		( 0 ),
	TrackingHi	( 0 ),
	TrackingLo	( 0 ),
	HiDate		( 0 ),
	LoDate		( 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 -
  	if close [1] < SMAv [1] then
  	move = move -1
  	else 
   	move = -1; 
   	
   	if move < TrackingLo then
   	TrackingLo = move
   	else
   	TrackingLo = TrackingLo;
   	
   	if TrackingLo < TrackingLo [1] then
   	LoDate = Date;
   
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;
  	
  	if move > TrackingHi then
  	TrackingHi = move
  	else
  	TrackingHi = TrackingHi;
  	
  	if TrackingHi > TrackingHi [1] then
  	HiDate = Date;
  	
end;

plot1(move,"Days over/under SMA 21");
plot2(TrackingHi, "max. Days over  SMA 21");
plot3(TrackingLo, "max. Days under SMA 21");
plot4(HiDate, "Hi Date ");
plot5(LoDate, "Lo Date ");


If Plot1 >=1 Then
  SetPlotColor(1, Green); 
If Plot1 <= -1 Then
  SetPlotColor(1, red);
 
ClearPrintLog;
Print( ELDateToString (D)," " , time_s2time(T), " TrackingHi ", TrackingHi, " TrackingLo ", TrackingLo, " HiDate ", ELDateToString (HiDate), " LoDate ", ELDateToString (LoDate)  );
I dont have a solution to format the date in the plot statement:



Can you please help me?

Thanks again.

Best regards,
Timo


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CME Group Fee Schedule Changes Hit All Four Exchanges -- …
Traders Hideout
CPI Eve: Fed Hike Odds Hold at 52% for the First Time, I …
Prediction Markets & Event Contracts
Tradeify 3.0 Overhauls Futures Prop Firm Model -- One-Ti …
Funded Trading Evaluation Firms
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Orban Crashes to 21pct on Record Turnout -- McIlroy Drop …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 thanks
  #12 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

Hi Timo,

how do you want to format the date? You can format dates with
 
Code
Date + 19000000
for example.

However when you have larger values together with small values you will likely have a scaling problem (which you can see on your second screenshot).

Regards,
ABCTG


Follow me on X Reply With Quote
  #13 (permalink)
 venatrix 
Aschaffenburg
 
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1


Hi ABCTG,

I would like to format it like in the print statement:

MM/DD/YYYY

Is it possible to show the date in the Data window, but not in the indicator window on the chart
(to avoid the scaling problem)?

Thank you.

Best regards,
Timo


Started this thread Reply With Quote
  #14 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

You can display a plot as a string in the status window, but to be able to display a value in the data window is only doable when you plot it.
 
Code
Plot1( ElDateToString( Date ), "Date") ;
You can however simply set the indicator to be scaled from -100 to +100 for example or simply have an input that allows you to switch certain plots on and off - this way you'd load the indicator twice. One would plot the dates and the other the move values.

Regards,
ABCTG


Follow me on X Reply With Quote
  #15 (permalink)
 venatrix 
Aschaffenburg
 
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1

Thanks ABCTG,

good idea to have an input to switch certain plots on and off, I add these this evening.

With

 
Code
plot4(ELDateToString( HiDate ) , "Hi Date ");
I have in the DataWindow N/A.

What is wrong here?

Thanks again.

Best regards,
Timo


Started this thread Reply With Quote
  #16 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


venatrix View Post
]
 
Code
plot4(ELDateToString( HiDate ) , "Hi Date ");
I have in the DataWindow N/A.

What is wrong here?

That's what I meant with " You can display a plot as a string in the status window, but to be able to display a value in the data window is only doable when you plot it.". I should have added [...] is only doable when you plot it as a value.

Regards,
ABCTG


Follow me on X Reply With Quote
  #17 (permalink)
 venatrix 
Aschaffenburg
 
Experience: Beginner
Platform: NinjaTrader, Multicharts
Trading: ES
Posts: 15 since Feb 2012
Thanks Given: 4
Thanks Received: 1

Good morning ABCTG,

thank you for the clarification.

To avoid to load the indicator 2 times I simply set the indicator to be scaled from -100 to +100, that is ok for this
indicator.

I changed the variables HiDate = Date + 19000000 and LoDate = Date + 19000000, so I can read it in the Data Window, but that is not very nice. Any chance to format this better in the Data Window?



Thank you.

Best regards,
Timo


Started this thread Reply With Quote




Last Updated on May 29, 2015


© 2026 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 - Downloads - Top
no new posts