NexusFi: Find Your Edge


Home Menu

 





How to plot the previous 20 period RSI(9) high overlay on current RSI(9)?


Discussion in Platforms and Indicators

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




 
Search this Thread

How to plot the previous 20 period RSI(9) high overlay on current RSI(9)?

  #1 (permalink)
kaysonchan
Singapore
 
Posts: 5 since Feb 2016
Thanks Given: 2
Thanks Received: 0

Hello guys,

i am beginner to Amibroker and will appreciate much if you can teach me how to write the code for this conditions:

How to plot the previous 20 period Highest RSI(9) high overlay on current RSI(9)?


Thank you!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 prouser 
Zurich/Switzerland
 
Posts: 79 since Oct 2014

See https://www.amibroker.com/guide/afl/hhv.html

 
Code
// RSI and HHV(RSI) example
// by prouser

SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle, gridFlags = 0, ymax = 0, xmax = 0, blankmargin = 0 );

periods = Param( "RSI Periods", 15, 1, 200, 1 );
HHVperiods = Param( "HHV Periods", 20, 1, 200, 1 );
RSIcolor = ParamColor( "RSI Color", colorCycle );

myRSI = RSI( periods );
HHV_RSI = HHV( myRSI, HHVperiods );

GraphLabelDecimals = 2;

Plot( myRSI, "RSI", RSIcolor, ParamStyle( "RSI Style" ) | styleNoTitle, Null, Null, 0, 1 );
Plot( HHV_RSI, "HHV RSI", colorDarkGreen, ParamStyle( "HHV Style" ) | styleNoTitle, Null, Null, 0, 1 );

PlotGrid( 30, colorBrightGreen, pattern = 0, width = 2, label = True );
PlotGrid( 50, colorGrey50, pattern, width, label );
PlotGrid( 70, colorRed, pattern, width, label );

_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} - " +
                       EncodeColor( RSIcolor ) + "RSI(%g): %g  " +
                       EncodeColor( colorDarkGreen ) + "HHV(RSI(%g), %g): %g " +
                       EncodeColor( -1 ) + "{{VALUES}}",
                       periods, myRSI, periods, hhvperiods, HHV_RSI ) );

Reply With Quote
  #3 (permalink)
kaysonchan
Singapore
 
Posts: 5 since Feb 2016
Thanks Given: 2
Thanks Received: 0


Thank you so much Prouser, this is what i am trying to plot. =)
Will let you know if i manage to get any meaningful results from it.

Have a great week!

Reply With Quote
  #4 (permalink)
kaysonchan
Singapore
 
Posts: 5 since Feb 2016
Thanks Given: 2
Thanks Received: 0

Hi, so sorry to bother again.

I am trying to issue a buy signal when the RSI(x) becomes the HHV_RSI, plus only when RSI is more than 50 but unable to get a accurate buy signal from my backtest. The buy signals are random not following the criteria i issue.
Here is the code i used. Is there any mistake here?

BuySignal1 = Cross(myRSI, HHV_RSI); // myRSI >= HHV_RSI;
BuySignal2 = myRSI > 50;

// buy on the next bar
Buy = Ref( BuySignal1 AND BuySignal2, -1);


TY

Reply With Quote
  #5 (permalink)
 prouser 
Zurich/Switzerland
 
Posts: 79 since Oct 2014

If you use Cross() then you expect one var to have a higher/lower value than the second var in order to return true.
So in this case you expect RSI of "current" bar having a higher value than its own highest value at "current" bar. If a var crosses above its own "current" highest value then it would be expected to be higher than that. But it is logically impossible that this condition will ever return true. Can you follow the logic?

That's why using previous highest value as second argument would make more sense.

 
Code
BuySignal1 = Cross( myRSI, Ref(HHV_RSI, -1) );

Reply With Quote
  #6 (permalink)
kaysonchan
Singapore
 
Posts: 5 since Feb 2016
Thanks Given: 2
Thanks Received: 0

Thanks prouser. I understand the logic now. Basically the two period moves systematically so it doesnt make sense for it to cross over its own high. It makes more sense with a 1 bar delay like the one in your code.

Thanks for clearing my doubts again=)

Reply With Quote




Last Updated on February 23, 2016


© 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