Simple Coding Help - No Promise.

Another simple question...

I want to plot plain text on a bar -- either below Low or above High. I looked at the PlotText function and I cannot understand how to apply.

Thanks in advance.

EDIT: Ok I figured out how to plot the text. Now how do I stack different texts at different distances from High/Low? The texts are from different indicators so cannot use "\n" See example below...

a
b
c
[] <-- Bar

3rd Parameter decides vertical positioning for the text will be and it is specified in dollar figure, so for nifty, it will be in 5000-6000s. For suzlon, it will be < 10.

Best approach is to form price slabs and use different % multipliers for each, say for e.g. 3%. First text will be at H * 1.03. second is at H * 1.06 and so on.... Order of writing is not important
 

XRAY27

Well-Known Member
hi sir
i want an afl for only engulfing, piercing, dark cloud cover,morning and evening star under candlestick pattern including exploration
 
Last edited:
hello, happy singh

i am trying to add an exploration to the sequential system AFL but cant seem to get it properly executed.

what i want is :

the exploration should find stocks that has " EOD close" value with in +-3% of tdst support\blue\buy line or with in +-3% of tdst resistance\red\sell line.

any help will be appriciated.

the full afl is below

Regards
Ritesh banfa
Hello Ritesh

I don't have time to go through 100s of lines of code you have posted but i can give you the solution, and you will have to incorporate it in your AFL

Lets say MyTDSTLEVEL01,02,03,04 are the variable that holds your levels

the exploration will be simple

Condition01 = Close > MyTDSTLEVEL01 * 1.03 OR Close < MyTDSTLEVEL01 * 0.97;
Condition02 = Close > MyTDSTLEVEL02 * 1.03 OR Close < MyTDSTLEVEL02 * 0.97;
Condition03 = Close > MyTDSTLEVEL03 * 1.03 OR Close < MyTDSTLEVEL03 * 0.97;
Condition04 = Close > MyTDSTLEVEL03 * 1.03 OR Close < MyTDSTLEVEL04 * 0.97;

Filter = Condition01 OR Condition02 OR Condition03 OR Condition04;


:) Happy
 

Nehal_s143

Well-Known Member
hi sir
i want an afl for only engulfing, piercing, dark cloud cover,morning and evening star under candlestick pattern including exploration
Please try this, let me know if this is what you want

_SECTION_BEGIN("Candle Identification");
Plot(C,"",1,64);
O1 = Ref(O,-1);O2 = Ref(O,-2);
H1 = Ref(H,-1);H2 = Ref(H,-2);
L1 = Ref(L,-1);L2 = Ref(L,-2);
C1 = Ref(C,-1);C2 = Ref(C,-2);
function CandlePattern(P)
{
global PatternName;
if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-Ref(MA(C,13),-4)>0); }
else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND
Ref(GapUp(),-1); }
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND
Ref(GapDown(),-1); }
return Pv;
}

PatternNameList = "";
for(Cp=0; Cp<=44; Cp++)
{
VarSet("Pattern"+NumToStr(Cp,1.0),CandlePattern(cP));
PatternNameList = PatternNameList +PatternName+",";
}

BI = BarIndex();
SelectedBar = SelectedValue(BI) -BI[0];
//Selectedbar = Status("lastvisiblebar")-1;
PStr="";
for(Cp=0; Cp<=44; Cp++)
{
Temp = VarGet("Pattern"+NumToStr(Cp,1.0));
if(temp[SelectedBar]) Pstr=Pstr+"#"+NumToStr(Cp,1.0)+" -
"+StrExtract(PatternNameList,Cp)+"n";
}

Title = "nCandle Demostration n"+ Pstr;
_SECTION_END();
 
Hi Happy Singh,

Would you be helping in setting up an buy/sell alert in MT4 indicator with SL. I am not knowledgeable in MT4 but I have the ideas and an indicator which works much more comfortable for me in Scalping. I would be more than happy if you could help in setting up the alerts... Please reply when time permits

Thanks
Sorry won't be able to help you with MT4


:) Happy
 
Dear Happy Singh ji,

A bit of help would be greatly appreciated with the following afl, I am a zero at programming, so doesnt knows about afl, C# etc., what I have written below may be a piece of junk to you, it was done watching some online tutorials, afl reference guide etc.

The strategy is to buy when EMA5 crosses EMA15, and the price crosses above the high of the candle on which the crossover occured, the stoploss should be below the lowest low of the previous swing/ previous 5 bars and the T1 should be Entry + Difference between the Entry and the stoploss, T2 should be T1+ Difference between the Entry and the stoploss. I need horizontal lines to be drawn at the entry, stoploss and t1 and t2 as soon as the buying condition is met. And viceversa for selling.

After all my tries I cant get it done, I have even tried to get a TextBox indicating buying stoploss and targets level but cant get it correctly, kindly assist me. What I have achieved till now is here below :

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
 
 
_SECTION_BEGIN("ema_crossover");
x = EMA(Close,5);
y = EMA(Close,15);
Plot(EMA(Close,5),"",colorRed,styleLine);
Plot(EMA(Close,15),"",colorDarkGreen,styleLine);
 
Crossup = Cross(x,y);
Buy=Crossup;
EnterLong = CrossUp+H;
PlotShapes(shapeUpArrow*Buy,colorBlue,0,H);
GfxSelectFont("Times New Roman", 16, 700, True ); 
GfxTextOut("Buy Above" +EnterLong, 10 , 10 ); 
AlertIf( Buy, "SOUND C:\\Windows\\Media\\abc.wav", "Audio alert", 2 );
Title = Name() + " " + Date()+" " + EncodeColor( colorBlue ) +"5/15 EMA " +EncodeColor( colorRed )
+ " O " + O + " H " + H + " L " + L + " C "+ C + "\n";


Crossdown = Cross(y,x);
Sell=Crossdown;
PlotShapes(shapeDownArrow*Sell,colorRed,0,L);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\abc.wav", "Audio alert", 2 );
Title = Name() + " " + Date()+" " + EncodeColor( colorBlue ) +"5/15 EMA " +EncodeColor( colorRed )
+ " O " + O + " H " + H + " L " + L + " C "+ C + "\n";

_SECTION_END();
Thanks a lot for all your help.

Regards
 
thank you singhji... will try to incorporate this in afl via trial and error...


Regards
CA. Ritesh Bafna
 

Nehal_s143

Well-Known Member
hi

I am trying to make a day trading system based on afls downloaded from traderji, if this day trading system gives good result will share afl here and if this is another junk system (out come of trail and error and my afl coding learning) then will trash it :) I have learned many basic codes of AFL with help of this thread :)
 
Hello Ritesh

I don't have time to go through 100s of lines of code you have posted but i can give you the solution, and you will have to incorporate it in your AFL

Lets say MyTDSTLEVEL01,02,03,04 are the variable that holds your levels

the exploration will be simple

Condition01 = Close > MyTDSTLEVEL01 * 1.03 OR Close < MyTDSTLEVEL01 * 0.97;
Condition02 = Close > MyTDSTLEVEL02 * 1.03 OR Close < MyTDSTLEVEL02 * 0.97;
Condition03 = Close > MyTDSTLEVEL03 * 1.03 OR Close < MyTDSTLEVEL03 * 0.97;
Condition04 = Close > MyTDSTLEVEL03 * 1.03 OR Close < MyTDSTLEVEL04 * 0.97;

Filter = Condition01 OR Condition02 OR Condition03 OR Condition04;


:) Happy
with your guidance i was able to come up with this code

Condition1= C>tdstba*1.05 OR C<tdstba*0.95;
Condition2= C>tdstsa*1.05 OR C<tdstsa*0.95;

Filter= Condition1 OR Condition2;

AddColumn( Condition1, "tdst buy", 1.2, colorBlack);
AddColumn( Condition2, "tdst sell", 1.2, colorBlack);


AddColumn(C, "close", 1.2, colorBlack);

result of exploration using the above code is:



the tdst buy and tdst sell column (bolded for reference in the above code) shows 1 and 0

can u tweak this to make the exploration to show actual price instead of "1" or "0"

the exploration shows stock that do not fit into the criteria denoted by 1

as against the exploration shows stock that fit into the criteria denoted by 0

how can i filter out these "1" stock..??

i hope my question is not confusing you.

thanks!!!
 

Nehal_s143

Well-Known Member
My day trading system (still improvement is required)

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );

if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip = StrFormat( "Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: " + NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
}
_SECTION_END();
Period = Param("Period", 25, 2, 100 );
bi = BarIndex();

procedure PlotLevel( array, nam, Color )
{
x = SelectedValue( bi );
y = SelectedValue( array );
Plot( IIf( bi >= x AND bi < x + Period, y, Null ),
nam, Color, styleDashed );
PlotText( nam, x + Period - 1, y, Color );
}

pl = Ref( LLV( Low, Period ), -1 );
ph = Ref( HHV( High, Period ), -1 );
range = ph - pl;
pc = Ref( Close, -1 );
R5 = ph/pl * pc;
R4 = pc + Range * 1.1/2;
R3 = pc + Range * 1.1/4;
R2 = pc + Range * 1.1/6;
R1 = pc + Range * 1.1/12;

S1 = pc - Range * 1.1/12;
S2 = pc - Range * 1.1/6;
S3 = pc - Range * 1.1/4;
S4 = pc - Range * 1.1/2;
S5 = pc - ( R5 - pc );


Plot( C, Name() + " " + Date(), colorDefault, styleCandle );

PlotLevel( R5, "R5", colorBlue );
PlotLevel( R4, "R4", colorBlue );
PlotLevel( R3, "R3", colorBlue );
PlotLevel( R2, "R2", colorBlue );
//PlotLevel( R1, "R1", colorBlue );
//PlotLevel( S1, "S1", colorRed );
PlotLevel( S2, "S2", colorRed );
PlotLevel( S3, "S3", colorRed );
PlotLevel( S4, "S4", colorRed );
PlotLevel( S5, "S5", colorRed );

_SECTION_BEGIN("Ehlers laguerre RSI");
//Ehlers laguerre RSI
/*
The Laguerre transform provides a time warp such that the Low frequency components are delayed
much more than the High frequency components. This enables very smooth filters to be built
using a Short amount of data.
The Laguerre RSI operates on four data points AND is smoother than an RSI(4).
*/

SetChartBkColor(ParamColor("Panel color ",colorDarkGrey));

SetBarsRequired(200, 0);

// Ehlers formulas
// from Ehlers, John F. Cybernetic Analysis for Stocks and Futures. Wiley. 2004.
// Chapter 14, p. 213. Code on p. 221.

function LRSI(array, gamma)
// Figure 14.8 on p. 221.
{
L0 = array; // Initialize as array
L1 = array;
L2 = array;
L3 = array;
LRSIValue = array;

for(i = 1; i < BarCount; i++)
{
L0 = (1 - gamma)*array + gamma*L0[i-1];
L1 = - gamma * L0 + L0[i-1] + gamma * L1[i-1];
L2 = - gamma * L1 + L1[i-1] + gamma * L2[i-1];
L3 = - gamma * L2 + L2[i-1] + gamma * L3[i-1];

CU = 0;
CD = 0;
if (L0 >= L1) CU = L0 - L1; else (CD = L1 - L0);
if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;

if (CU + CD != 0) LRSIValue = CU / (CU + CD);
}
return LRSIValue;
}


//Plot(LRSI(C, 0.5), "Laguerre RSI", colorWhite, styleLine);
//PlotGrid(0.5);

myc=IIf(LRSI(C,0.5)>0.5,colorBlue,
IIf(LRSI(C,0.5)<0.5,colorRed,31));
// IIf(HaClose<smmaH AND HaClose>smmaL ,colorYellow,31)));

//Plot(6, "", myC, styleOwnScale| styleArea|styleNoLabel,-0.5,100);
_SECTION_END();

_SECTION_BEGIN("cycle121");

SetChartBkColor(ParamColor("Panel color ",colorDarkGrey));


PI = 3.1415926;
Data = (H+L)/2;
// detrending ( high-pass filter )
HFPeriods = Param("HP filter cutoff", 40, 20, 100 );
alpha1 = ( 1-sin(2*pi/HFPeriods) ) / cos( 2 * pi / HFPeriods );
HP = AMA2( Data - Ref( Data, -1 ), 0.5 * ( 1 + alpha1 ), alpha1 );
// 6-tap low-pass FIR filter
SmoothHP = ( HP + 2 * Ref( HP, -1 ) + 3 * Ref( HP, -2 ) +
3 * Ref( HP, -3 ) + 2 * Ref( HP, -4 ) + Ref( HP, -5 ) )/12;
SmoothHPDiff = SmoothHP - Ref( SmoothHP, -1 );
x = BarIndex();
delta = -0.015 * x + 0.5;
delta = Max( delta, 0.15 );
Q = 0;
Real = 0;
Imag = 0;
Ampl = 0;
DB = 0;
I = SmoothHP;
MaxAmpl = 0;
for( N = 8; N <= 50; N++ )
{
beta = cos( 2 * PI / N );
Q = ( N / ( 2 * PI ) ) * SmoothHPDiff;

for( bar = 8; bar < BarCount; bar++ )
{
gamma = 1 / cos( 4 * PI * delta[ bar ] / N );
alpha = gamma - sqrt( gamma ^ 2 - 1 );

Real[ bar ] = 0.5 * ( 1 - alpha ) * ( I[ bar ] - I[ bar - 1 ] ) +
beta * ( 1 + alpha ) * Real[ bar - 1 ] -
alpha * Real[ bar - 2 ];
Imag[ bar ] = 0.5 * ( 1- alpha ) * ( Q[ bar ] - Q[ bar - 1 ] ) +
beta * ( 1 + alpha ) * Imag[ bar - 1 ] -
alpha * Imag[ bar - 2 ];
}
Ampl = Real ^ 2 + Imag ^ 2;
MaxAmpl = Max( MaxAmpl, Ampl );
VarSet("Ampl"+N, Ampl );
}
TunedFilterDisplay = ParamToggle("Dom Cycle Tuned Filter", "Yes|No" );
// Plot Heat Map ( Spectrogram )
// and find dominant cycle
DcNum = DcDenom = 0;
for( N = 8; N <= 50; N++ )
{
Ampl = VarGet("Ampl"+N);
db = Nz( -10 * log10( 0.01 / ( 1 - 0.99 * Ampl / MaxAmpl ) ) );

db = Min( db, 20 ) ;
Red = IIf( db <= 10, 255, 255 * ( 2 - db/10 ) );
Green = IIf( db <= 10, 255 * ( 1 - db/10 ), 0 );
if( NOT TunedFilterDisplay )
PlotOHLC( N, N, N-1, N-1, "", ColorRGB( Red, Green, 0 ),
styleCloud | styleNoLabel );
DcNum = DcNum + (db < 3 ) * N * ( 20 - db );
DcDenom = DcDenom + ( db < 3 ) * ( 20 - db );
}
DC = DcNum / DcDenom;
if( ParamToggle("Show Dom. Cycle?", "No|Yes" ) )
{
DomCycle = Median( DC, 10 );
// Plot( DomCycle, "Dominant Cycle", colorBlue );
}
if( TunedFilterDisplay )
{
DomCycle = Median( DC, 10 );
DomCycle = Max( DomCycle, 8 );
Value = 0;
for( bar = 10; bar < BarCount; bar++ )
{
beta = cos( 2 * PI / domCycle[ bar ] );
gamma = 1 / cos( 4 * PI * delta[ bar ] / DomCycle[ bar ] );
alpha = gamma - sqrt( gamma ^ 2 - 1 );
Value[ bar ] = 0.5 * ( 1 - alpha ) * SmoothHPDiff[ bar ] +
beta * ( 1 + alpha ) * Value[ bar - 1 ] -
alpha * Value[ bar - 2 ];
}
Value2 = ( domCycle / ( 2 * PI ) ) * ( Value - Ref( Value, -1 ) );
// Plot( Value, "Sine", colorBlue );
// Plot( Value2, "Cosine", colorWhite );
}
GraphZOrder = 1;


//myc=IIf(Value2>Value,colorBlue,
// IIf(Value2<Value,colorRed,31));
// IIf(HaClose<smmaH AND HaClose>smmaL ,colorYellow,31)));

//Plot(6, "", myC, styleOwnScale| styleArea|styleNoLabel,-0.5,100);

_SECTION_END();

Buy= C>O AND (LRSI(C,0.5)>0.5) AND Value2>Value; //Buy Condition
Sell=(LRSI(C,0.5)<0.5);
Short = C<O AND (LRSI(C,0.5)<0.5) AND Value2<Value; //Sell Condition
Cover=(LRSI(C,0.5)>0.5);

Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

PlotShapes(Buy*shapeUpArrow,colorBlue,0,L,-35);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,L,-60);
PlotShapes(Short*shapeDownArrow,colorRed,0,H,-35);
PlotShapes(Cover*shapeHollowUpArrow,colorBlue,0,H,-60);

I am using this system for Nifty on 10 min chart, this system generates whipsaw mostly if Nifty gets stuck in very narrow range.

Suggestion are welcome to improve the system :)
 

Similar threads