NexusFi: Find Your Edge


Home Menu

 





Counting for RadarScreen


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 2 posts (1 thanks)
    2. looks_two haonkered with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 SKTennis with 1 posts (0 thanks)
    1. trending_up 4,643 views
    2. thumb_up 2 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Counting for RadarScreen

  #1 (permalink)
 haonkered 
Houston, Texas, United States
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 5

I am looking for some guidance on how to start a "count", positive or negative, based on when an indicator occurred and would like to be able to show this in radar screen. I am using the 50/200d ma crossover and would like to show how many days back this occurred for each of the symbols on the radar screen. For bullish crossovers looking to show on radarscreen "L1" if the crossover occurred today, "L2" if yesterday, etc. And then S1, S2, S3, etc for days back the bearish crossover occured. Would like to be able to do this for multiple indicators eventually, MACD, SMA, etc but cannot seem to find any good resources online to read about how to start "the" counting....

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
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
What broker to use for trading palladium futures
Commodities
 
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


haonkered,

one idea would be to count the days the study is running and then store the day count when a cross happens. Based on this I created this simple indicator for you. With every new day you can calculate how many days back a cross occurred.
When you load this indicator make sure to load enough "additional data for accumulative calculations". As you are using a Moving Average with 200 bars length I would suggest to load something around 1000 bars to give the indicator the chance to produce a cross over.

Regards,
ABCTG

 
Code
Variables:
	HaveUpCross		(false),
	HaveDnCross 		(false),
	UpCrossPlot 		("-"),
	DnCrossPlot 		("-"),
	UpCrossValue 		(0),
	DnCrossValue		(0),
	UpCrossDay		(0),
	DnCrossDay 		(0),
	DayCounter 		(0),
	MA50			(0),
	MA200 			(0);

//count days
if Date <> Date[1] then
	DayCounter = DayCounter + 1;
		
MA50 = Average(Close, 50);
MA200 = Average(Close, 200);

//bullish cross
if MA50 crosses over MA200 then
begin  
	//store the day of the upcross
	UpCrossDay = DayCounter;
	HaveUpCross = true;
end;

//bearish cross
if MA50 crosses under MA200 then
begin 
	//store the day of the dncross
	DnCrossDay = DayCounter;
	HaveDnCross = true;
end; 

if HaveUpCross then
begin
	//calculate how many days back the up cross occured
	UpCrossValue = DayCounter - UpCrossDay;
	UpCrossPlot = NumToStr(UpCrossValue, 0) + "L";
end;	
if HaveDnCross then
begin
	//calculate how many days back the dn cross occured
	DnCrossValue = DayCounter - DnCrossDay;
	DnCrossPlot = NumToStr(DnCrossValue, 0) + "S";
end;	

Plot1(UpCrossPlot, "Up Cross");
Plot2(DnCrossPlot, "Dn Cross");

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 haonkered 
Houston, Texas, United States
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 5

Thanks. Seems to be working well. I do have a question however...is there a way to count 01, 02, 03....10,11,12 so that when sorting in RadarScreen the crosses from 1 day ago are not followed by the crosses 11 days ago, and then the 2s and 21s, etc etc

Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Great. Yes, this can be done by simply adding a 0 in those cases.
 
Code
Variables:
	HaveUpCross		(false),
	HaveDnCross 		(false),
	UpCrossPlot 		("-"),
	DnCrossPlot 		("-"),
	UpCrossValue 		(0),
	DnCrossValue		(0),
	UpCrossDay		(0),
	DnCrossDay 		(0),
	DayCounter 		(0),
	MA50			(0),
	MA200 			(0);

//count days
if Date <> Date[1] then
	DayCounter = DayCounter + 1;
		
MA50 = Average(Close, 50);
MA200 = Average(Close, 200);

//bullish cross
if MA50 crosses over MA200 then
begin  
	//store the day of the upcross
	UpCrossDay = DayCounter;
	HaveUpCross = true;
end;

//bearish cross
if MA50 crosses under MA200 then
begin 
	//store the day of the dncross
	DnCrossDay = DayCounter;
	HaveDnCross = true;
end; 

if HaveUpCross then
begin
	//calculate how many days back the up cross occured
	UpCrossValue = DayCounter - UpCrossDay;
	UpCrossPlot = NumToStr(UpCrossValue, 0) + "L";
	if StrLen(UpCrossPlot) <= 2 then
		UpCrossPlot = "0"+ UpCrossPlot;	
end;	
if HaveDnCross then
begin
	//calculate how many days back the dn cross occured
	DnCrossValue = DayCounter - DnCrossDay;
	DnCrossPlot = NumToStr(DnCrossValue, 0) + "S";
	if StrLen(DnCrossPlot) <= 2 then
		DnCrossPlot = "0"+ DnCrossPlot;	
end;	

Plot1(UpCrossPlot, "Up Cross");
Plot2(DnCrossPlot, "Dn Cross");
Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #6 (permalink)
 BobF 
Hyannis, MA
 
Experience: Advanced
Platform: TradeStation
Trading: ES
Posts: 3 since Nov 2011
Thanks Given: 0
Thanks Received: 2

Here is a very simple way to count the number of bars since any event occurred.

Here is an example for two events. The count number is preceded by a letter that you specify as an the Name input.

This uses "L" and "S".

---

Input:
Event1(Average(Close, 50) crosses over Average(Close, 200)), Name1("L"),
Event2(Average(Close, 50) crosses under Average(Close, 200)), Name2("S");

if Event1 then Value1 = 0 else Value1 = Value1 + 1;
if Event2 then Value2 = 0 else Value2 = Value2 + 1;

Plot1(Name1 + NumToStr(Value1,0), "E1");
Plot2(Name2 + NumToStr(Value2,0), "E2");
---

Simply enter the event you want to track as the Event input. Examples might include:

Average(Close, 50) crosses over Average(Close, 200)
RSI(Close, 14) > 50

Reply With Quote
Thanked by:
  #7 (permalink)
SKTennis
Florida City, Florida
 
Posts: 4 since Feb 2014
Thanks Given: 2
Thanks Received: 0

I think if you just remove the "L" and "S" and plot as a number then it will sort numerically. You already have column headers, I think, that identify the direction.

It is because it is a text sort that "L11" sorts before "L2".

Just a FYI...

Samuel

Reply With Quote




Last Updated on February 17, 2014


© 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