Very very simple AFT need help

Nigel

New Member
#1
Hello for the first time! :)
I'm not very good at code, but was trying to figure out how to plot a ATR based line below price chart.

I'm pretty proud that I've created something like this:

Code:
ATR_Multiple = Param("ATR Multiple", 2.5, 1, 4, 0.5 ); 
ATR_Period = Param("ATR Period", 10, 3, 20, 1 ); 

CalculateATR = C - ATR_Multiple * ATR( ATR_Period ); 

Plot( CalculateATR,"ATR STOP", colorRed );

Now what I would like to change is:
1. add a date selection from which the line will be drawn. I've found sth like this:
Code:
Start = Cross( DateNum(), ParamDate("Start date", "2016-09-09" ) );
but have no skills to make it work :(

2. Instead of trail-stop line above, I would like it to be drawn horizontally, from a specific date. So basically I'd want to: select a date and plot automatic horizontal line which will work as a permanent Stop Loss Signal from that moment.

3. The last thing, I'm here not just to receive a solution, but to learn how to code, so any additional explanations and comments would be more than welcome :)

Thank you in advance!
Nigel
 

mastermind007

Well-Known Member
#2
Hello for the first time! :)
I'm not very good at code, but was trying to figure out how to plot a ATR based line below price chart.

I'm pretty proud that I've created something like this:

Code:
ATR_Multiple = Param("ATR Multiple", 2.5, 1, 4, 0.5 ); 
ATR_Period = Param("ATR Period", 10, 3, 20, 1 ); 

CalculateATR = C - ATR_Multiple * ATR( ATR_Period ); 

Plot( CalculateATR,"ATR STOP", colorRed );

Now what I would like to change is:
1. add a date selection from which the line will be drawn. I've found sth like this:
Code:
Start = Cross( DateNum(), ParamDate("Start date", "2016-09-09" ) );
but have no skills to make it work :(

2. Instead of trail-stop line above, I would like it to be drawn horizontally, from a specific date. So basically I'd want to: select a date and plot automatic horizontal line which will work as a permanent Stop Loss Signal from that moment.

3. The last thing, I'm here not just to receive a solution, but to learn how to code, so any additional explanations and comments would be more than welcome :)

Thank you in advance!
Nigel

Code:
ATR_Multiple = Param("ATR Multiple", 2.5, 1, 4, 0.5 ); 
ATR_Period   = Param("ATR Period", 10, 3, 20, 1 ); 
StartDate    = ParamDate("Start date", "2016-09-09" );
CalculateATR = C - ATR_Multiple * ATR( ATR_Period ); 
Plot( ValueWhen(DateNum() == StartDate, CalculateATR),"ATR STOP", colorRed );
 

Nigel

New Member
#4
@mastermind007

can I ask for your help once again? This code works like a charm but the problem is that the line is drawn on every stock :) How can I distinguish between different symbols and add particular start date only to selected one?

Thansk!
Nigel
 

Similar threads