Simple Coding Help - No Promise.

Nehal_s143

Well-Known Member
Nehal

Nice addition .... Hope hmp can start scanning now ...

Overall, my recommendation would be to not plot the ribbon because
zero line is important part of this TSI indcator and the ribbon (with its height of 6) almost totally dominates the zero line... Of course, if you must have ribbon, do it such that it gets plotted without shifting the zero line of TSI.

Go thru the stockcharts website for tutorial and interpretation...
i have used two colors in ribbon as base red and blue, if tsi above zero blue, if above zero but below ema then sky blue and if below zero red, below zero but above ema then pink

during range bound market many times cross over to ema or zero is not noticeable, ribbon can help to show even minor change in TSI, if height 6 is making zero line invisible, we can use 1 instead of 6
 

Nehal_s143

Well-Known Member
Shruti

Only below code is enough.Rest is not needed in the code


Code:
_SECTION_BEGIN("RSI EMA");
 
Plot (EMA(RSI(34),9), "Smoothed RSI-5", colorGreen , styleNoLabel | styleThick);
Plot (EMA(RSI(34),20), "Smoothed RSI-14", colorRed , styleNoLabel | styleThick);

Buy = Cross(EMA (RSI(14),5), EMA (RSI(14), 20));
Sell = Cross(EMA (RSI(14),20), EMA (RSI(14), 5));
  
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);
 
_SECTION_END();
RSI EMA Lines plotted are of different values, arrows dont match cross over

below code arrows will match with cross over
Code:
_SECTION_BEGIN("RSI EMA");
 
Plot (EMA(RSI(14),5), "Smoothed RSI-5", colorGreen , styleNoLabel | styleThick);
Plot (EMA(RSI(14),20), "Smoothed RSI-14", colorRed , styleNoLabel | styleThick);

Buy = Cross(EMA (RSI(14),5), EMA (RSI(14), 20));
Sell = Cross(EMA (RSI(14),20), EMA (RSI(14), 5));
  
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);
 
_SECTION_END();
 

Nehal_s143

Well-Known Member
Shruti

Only below code is enough.Rest is not needed in the code


Code:
_SECTION_BEGIN("RSI EMA");
 
Plot (EMA(RSI(34),9), "Smoothed RSI-5", colorGreen , styleNoLabel | styleThick);
Plot (EMA(RSI(34),20), "Smoothed RSI-14", colorRed , styleNoLabel | styleThick);

Buy = Cross(EMA (RSI(14),5), EMA (RSI(14), 20));
Sell = Cross(EMA (RSI(14),20), EMA (RSI(14), 5));
  
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);
 
_SECTION_END();

if want to keep RSI ema value same as plotted then signals will change

Code:
_SECTION_BEGIN("RSI EMA");
 
Plot (EMA(RSI(34),9), "Smoothed RSI-5", colorGreen , styleNoLabel | styleThick);
Plot (EMA(RSI(34),20), "Smoothed RSI-14", colorRed , styleNoLabel | styleThick);


BullRSI=(EMA(RSI(34),9));
BearRSI=(EMA(RSI(34),20));

Buy = BullRSI>BearRsi;
Sell = BullRSI<BearRSI;
Short=BullRSI<BearRSI;
Cover=BullRSI>BearRsi;


Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
  
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);
Plot(50,"", colorGold, styleDashed);


_SECTION_END();
 

Riskyman

Well-Known Member
Hey guys,

I follow a simple trading system. I was wondering if it was possible to write an afl for this system.

Suppose xyz stock made a swing high of 200 rupees and is now trading at 180. After 2 days stock breaks out over 200. I want to be able to find this stock when i run an exploration. Similarly lets say after breaking out over 200 it trades for 2-3 days at 210-215. Eventually it falls below 200 again. Now i want to be able to short it as it couldnt hold the breakout.

Another example: Lets say a stock makes a low of 340 and bounces up to 350. If it falls below 340 again i want to be able to short it. Now suppose after breaking 340 it bounces back above 340 i want to go long.

Is there anyway an Afl can be written to identify swing breakouts or breakout failures? I trade like this with a few select stocks but then there are so many stocks moving around that i end up missing a whole lot of them. If there was an afl i could scan and select a trade if something shows up on the exploration.

I have attached a pic of Apollo tyres which made a minor swing high of 237.7 on the 20-1-15 and on 4-2-15 broke down below this level.

Appreciate if any bright minds can help.

PS: This is an extremely good setup on the hourly and daily time frames. Sometimes you dont get trades for days but when you do get one you usually get a very nice move. Also draw downs are less. Only problem I have is finding the right stock as following so many FnO stocks is just not possible.


I think the logic here would be identify highs over a period of last 50-60 days (if trading the daily) or about roughly 500-700 hours (if trading the hourly) and take the highest high as a level to watch. If stock breaks above this then buy or if it breaks below this last high then sell. Same with down trending stocks.

 
Last edited:

Nehal_s143

Well-Known Member
Most of the system will fail in range bound market, I was testing TSI on Gold when it was range bound yesterday

Please see below chart


upload a picture


TSI support was broken in range bound market and Gold gave nice fall and again in range bound market Gold broke resis and gave good rally.


Similar to example chart


how to capture screen

Below code is used to plot recent support and resistance on price chart

Code:
_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "", colorGreen, styleLine);
}

_SECTION_END();
can it it modified and used on TSI ? or any other code to plot support and resi on TSI indicator itself
 
Last edited:

Riskyman

Well-Known Member
The highlighted in Bold blue is the ultimate truth , hence No Indicator works 100% for all the time.
Absolute truth. But then no one knows when it breaks out of a range. So a lot of the time traders have to take a position and leave it o the markets. Of course there will be stops triggered but when you find a trend it will be more than enough to compensate for all losses. Just my two cents and sorry to butt into your conversation.
 
Hello,
Could some body help me with an afl for the following conditions.

Set-up: 9day Ema crosses above 21 day ema. Price closes above both these EMAs, i.e, C > 9ema and 21 ema.

Buy when price pulls back and closes below 9 ema but above 21 ema.
 

hmp

Well-Known Member
Hi Nehal
Your buy sell coding for TSI will help us to scan stocks which will spurt up/down for next few days.
I think almost 80% of them will give us at least 3/4% moment on either side.I suppose we can use it for intraday also to grab few points as you have displayed on 5 min gold chart.
Thanks & regards.
 
Last edited:

Similar threads