NexusFi: Find Your Edge


Home Menu

 





Print values - dates only with Moving Average crossing


Discussion in TradeStation

Updated
    1. trending_up 1,762 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Print values - dates only with Moving Average crossing

  #1 (permalink)
jlsegsan
Madrid
 
Posts: 10 since Feb 2018
Thanks Given: 0
Thanks Received: 0

Apologies in advance I am an absolute beginner

I coded a simple indicator to plot 3 moving averages
Then I add the condition of the first 2 crossing
I want to apply this indicator to the Radar where I have selected some values
My info extraction would be very simple at first:

- Future / Stock - Date - Value at which the 2 Moving Averages have crossed
but get data extraction only in the date in which I have a crossing, I don't need the Dates and Values without any Moving average crossing

I have managed to write the Plot part, even the Condition, but I don't know how to code the Print part

Your help would be really appreciated

My coding Inputs:

Price (Close),
Length1 (2),
Length2 (11),
Length3 (22),
ConfirmBars( 1 ) ;

Variables:

FileName (" "),
Counter( 0 );
{ Plot1 Averages on chart }

Plot1 ( AverageFC(Price , Length1), "Avg1");
Plot2 ( AverageFC(Price , Length2), "Avg2");
Plot3 ( AverageFC(Price , Length3), "Avg3");


if AverageFC(Price, Length1) > AverageFC( Price, Length2 ) then
Counter = Counter + 1;
if Counter = ConfirmBars then


Print ("Date -",ELDateToString(Date)," Avg1", Plot1:3.3, " Avg2", Plot2:3:4, " Avg3", Plot3:3:5) ;
If Currentbar = 1 then Print(File("C:\TestTemp.txt"),"Date - ",";"," Avg1 ",";"," Avg2 ",";"," Avg3 ") ;
Print(File("C:\TestTemp.txt"), ELDateToString(Date),";", Plot1:3.3, ";", Plot2:3:4, ";", Plot3:3:5) ;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
ZombieSqueeze
Platforms and Indicators
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
51 thanks
Funded Trader platforms
44 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

jlsegsan,

welcome to futures.io.

What do you intend to do with the prints? Any display in Radarscreen is done via plots, while the output of the print reserved word appears in the "EasyLanguage Print Log".
If you want to display the date in Radarscreen, you could store the date in a variable when your condition is true. Then you can plot plot this variable directly or convert it via ELDateToString and plot the string (you can also set the grid style to date for the latter under the indicator properties: Format Analysis Technique - Grid Style).

You can find a good example here: https://community.tradestation.com/Discussions/Topic_Archive.aspx?Topic_ID=36248

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
jlsegsan
Madrid
 
Posts: 10 since Feb 2018
Thanks Given: 0
Thanks Received: 0


Thanks ABCTG

The link you included in your reponse is exactly what I want: to display the date in Radarscreen

I must be too new in coding Easy language ....Believe me I have tried to apply all that to display the date in Radarscreen when the last EMA Crossing took place.

I tried really hard in order not to be a pain in the neck to you, coming back with every single question I have, but I must admit I have not been succesful, the more things I try the worst

I believe that coding this for you must be a walk in the park ... can you help me

Thank you in advance
This is what I have

inputs:
Price( Close ) ,
Length1 ( 11 ) ,
Length2 ( 22 ) ;


variables:
ExpAv1 ( 0 ) ,
ExpAv2 ( 0 ) ,
_EMA1122 ( False ) ,

HaveUpCross ( False ) ,
HaveDnCross ( False ) ,
UpCrossPlot ( "-" ) ,
DnCrossPlot ( "-" ) ,
UpCrossValue ( 0 ) ,
DnCrossValue ( 0 ) ,
UpCrossDay ( 0 ) ,
DnCrossDay ( 0 ) ,
DayCounter ( 0 ) ;

ExpAv1 = XAverage ( Price , Length1 ) ;
ExpAv2 = XAverage ( Price , Length2 ) ;

if ExpAv1 > ExpAv2

then Begin
_EMA1122 = True ;
Plot1( _EMA1122 , "EMA 11-22" ) ;
end

else Begin
_EMA1122 = False ;
Plot1( _EMA1122 , "EMA 11-22" ) ;
end ;

// retrieve date of the last EMA crossing

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

jlsegsan,

I would suggest checking out the reserved words "crosses over" and "crosses under". These should help you in detecting that the averages crossed. When you are able to detect this, you can save the date at the moment you detect the cross in a variable and plot this variable later.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
jlsegsan
Madrid
 
Posts: 10 since Feb 2018
Thanks Given: 0
Thanks Received: 0

Thanks ABCTG

My issues ... really appreciate your guidance on them


1. Keeps being how to store the date

//store the date of the bullish cross
if ExpAv1 crosses over ExpAv2

then begin
HaveUpCross = true;
UpCrossDay = ??? // don't know how to capture the date
end ;

2. Once we have the bullish cross Date in the past ... I want to check how it worked
Like a backtesting but forward looking ... making the most of the Radar capabilities, checking for all components of an Index)
I know how to do it backward looking (with "offset") but not forward looking
Backward looking would be ... with the Close Date

plot1(CurrentBar, "Bar Nr");

inputs: offset1(20), offset2(40), offset3(60), offset4(80), offset5(100), offset6(120); // each month has typically 20 trading days

// Net gained (or lost) in each period

plot1(1-c[offset5]/c[offset6], "Net%1");
plot2(1-c[offset4]/c[offset5], "Net%2");
plot3(1-c[offset3]/c[offset4], "Net%3");
plot4(1-c[offset2]/c[offset3], "Net%4");
plot5(1-c[offset1]/c, "Net%5");

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

jlsegsan,

you can get the date of a bar using the reserved word Date.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #7 (permalink)
jlsegsan
Madrid
 
Posts: 10 since Feb 2018
Thanks Given: 0
Thanks Received: 0

Hi ABCTG

I tried to store the date in a variable when the condition is true, using the word Date ... without success
I have managed only to work deducting days from the current one (Date [1]) … but I have not been able to link it to the crossing day of the moving averages, to store that date

I also tried to find another thread with something similar, again without success

Please can you code this for me, or give me a thread with a solution similar to the one I am looking for

PS: I was also asking how to do backtesting but forward looking ... making the most of the Radar capabilities, checking for all components of an Index
I know how to do it backward looking (with "offset") but not forward looking
Do you know what word can I use for this?

Best regards

Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

jlsegsan,

I can try to point you in the right direction, but it's hard without knowing the actual code changes that you made.

I am not sure I understand your intentions regarding forward looking. The code is generally evaluated bar by bar starting with the first bar, so you might face the problem that values in the future are not yet calculated on historical bars.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on March 5, 2018


© 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