Simple Coding Help - No Promise.

amitrandive

Well-Known Member
TechQuant

Need help for exploring HH,HL.LH and LL values on any time frame for this code.

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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("ZigZag");
P = Param("ZigZag_Percent",0.1,0.01,2,0.01);
ZigH  = Zig(H,P);		ZigL = Zig(L,P);
ZigHi = ZigH > Ref(ZigH,-1) AND ZigH > Ref(ZigH,1);		
ZigLo = ZigL < Ref(ZigL,-1) AND ZigL < Ref(ZigL,1);
j=0;	k=0;	PH[0] = PL[0] = 0;
for( i = 1; i < BarCount-1; i++ ) { 
 if (ZigLo[i])	{
	if (PL[k] > ZigL[i])  	PlotText("LL",i, L[i]-5, colorRed);
	else						PlotText("HL",i, L[i]-5, colorBlue);
	k = k + 1;		PL[k] = ZigL[i]; }
 if (ZigHi[i]) {
	if (PH[j] < ZigH[i])  	PlotText("HH", i, H[i]+5, colorBlue);
	else						PlotText("LH", i, H[i]+5, colorRed);
	j = j + 1;
	PH[j] = ZigH[i]; }
}
_SECTION_END();
 
Hello,

I am looking out for an AFL for below mentioned trade setups. These are simple setups and I keep searching them on all time frames (Hourly, Day, and Week) manually. It would be a great help if one can code them in AFL.

Below are the trade setups:
Inside Bar with Retracements & Fibonacci Levels
Below are instructions to find a Fibonacci Buy Retracement setup.
- Find a swing point low and a swing point high to measure a Fibonacci buy retracement level.
-Wait for an IB to form at the 38%, 50%, 62% or 78% buy levels.
-Once you have identified the IB then Buy signal should generate above the high of the IB.

Below are instructions to find a Fibonacci Sell Retracement setup.
-Find a swing point high and a swing point low to measure a Fibonacci retracement level.
-Wait for an IB to form at the 38%, 50%, 62% or 78% sell levels.
-Once you have identified the IB then Sell signal should generate below the low of the IB.

IB with Divergence/Convergence Levels
Below are instructions to find a Divergence/Convergence Buy setup.
-Look for market to make a lower low and for the stochastic/RSI/MACD to make a higher low.
-Wait for an IB to form.
-Once you have identified the IB then Buy signal should generate above the high of the IB.

Below are instructions to find a Divergence/Convergence Sell setup.
-Look for market to make a higher high and for the stochastic/RSI/MACD to make a lower low.
-Wait for an IB to form.
-Once you have identified the IB then Sell signal should generate below the low of the IB.


Thanks in advance!!
TT
 
Dear All,

Sorry for interrupting you all friends. Can I ask you a question ? Do we have a facility to scan for any indicator, for eg. RSI(14) crossover above 70. But in two different time frames. I mean scan should give the stocks which are crossing above 70 in 5 minutes and in 60 minutes SIMULTANEOUSLY.

I hope you supper guys do have the solutions, Thanks In advance

Regards

Avinash
 
Dear All,

Sorry for interrupting you all friends. Can I ask you a question ? Do we have a facility to scan for any indicator, for eg. RSI(14) crossover above 70. But in two different time frames. I mean scan should give the stocks which are crossing above 70 in 5 minutes and in 60 minutes SIMULTANEOUSLY.

I hope you supper guys do have the solutions, Thanks In advance

Regards

Avinash
It is next to impossible for same indicator with same parameter to have a cross over at same instance in two different timeframes.
 

rvlv

Active Member
hi friends
here is an afl called isfandi intraday trading system.

I like to modify the targets part of the code.

present code uses a percentage. These are not comfortable.

I need a ATR based targets.
can anybody modify the targets please!
thanks.

my long side targets are
//note Ltar1 =longtarget1
//ltar1 = Longentry + 2*ATR(20);
//ltar2 = Longentry + 4*ATR(20);
//ltar3 = Longentry + 6*ATR(20);

my short side targets are
//star1 = Shortentry - 2*ATR(20);
//star2 = Shortentry - 4*ATR(20);
//star3 = Shortentry - 6*ATR(20);

code is as below

HTML:
//isfandi trading system
//targets are too close  keep them far
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, High %g, Low %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("Signal Panel");
no=10;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=IIf(avn==1,sup,res);

showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
if (showsl == 1)
{Plot(s5d,"Stop Loss",colorCustom14,styleDots);}

exitlong = Cross(s5d, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, s5d);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);

Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "Buy @ " + C, 1 );
AlertIf( Sell, "", "Sell @ " + C, 2 );

for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "Buy";
sl = s5d[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);



//to make changes below targets
//tar1 = entry + 2*ATR(20);
//tar2 = entry + 4*ATR(20);
//tar3 = entry + 6*ATR(20);





bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "Sell";
entry = C[i];
sl = s5d[i];
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);

//tar1 = entry - (entry * 0.050);
//tar2 = entry - (entry * 0.112);
//tar3 = entry - (entry * 0.212);




//tar1 = entry -2*ATR(20);
//tar2 = entry -4*ATR(20);
//tar3 = entry - 6*ATR(20);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "Buy", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1));
sl = ssl[BarCount-1];
//Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount-3,entry,Null,colorBlue);
PlotText("TGT-1@"+tar1,BarCount-4,tar1,Null,Clr);
PlotText("TGT-2@"+tar2,BarCount-4,tar2,Null,Clr);
PlotText ("TGT-3@"+tar3,BarCount-4,tar3,Null,Clr);

}

messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="Buy")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 310;

y = pxHeight;

GfxSelectPen( colorGreen, 5); // broader color
GfxRoundRect( x, y - 142, x2, y , 7, 7 ) ;
GfxTextOut( Name(),12,y-140);
GfxTextOut( " Last Traded Price = "+ C , 08,y- 120 );
GfxTextOut( ( "Signal Panel"),160,y-140);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-100) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="Buy",sig + " @ ",sig + " @") + " : " + entry), 13, y-80);
GfxTextOut( ("Trailing Stop Loss : " + sl + " (P/L:" + WriteVal(IIf(sig == "Sell",entry-sl,sl-entry), 2.2) + ")"), 13, y-60);
GfxTextOut( ("TGT:1 : " + tar1), 13, y -40);
GfxTextOut( ("Current Profit/Loss : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 40, y-22);;

}
_SECTION_END();



_SECTION_BEGIN("Sound Alert");
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Chord.wav", "Sell " + C,2,1+2,1);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\tada.wav","Buy " + C,1,1+2,1);
_SECTION_END();



_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",15,30,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBlue) );
Hor=Param("Horizontal Position",750,800,800,800);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut("L.T.P="+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5.45, Ver+45 );
_SECTION_END();


_SECTION_BEGIN("");
GfxSetOverlayMode(0);
GfxSelectPen( colorRed, 3 );
GfxSelectSolidBrush( colorLightYellow );
GfxRoundRect( 350, 38,665, 70, 15, 15 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 17.5, 700, False );
GfxSetTextColor( colorBrown );
GfxSetTextAlign(0);
GfxSetTextColor( colorBlack );
GfxTextOut( " Last Traded Price = "+ BuyPrice , 350, 40);
_SECTION_END();


_SECTION_BEGIN("Isfandi Technical Viewer");
//Plot(C,"",ParamColor( "Color", colorBlue ),ParamStyle("Style") );
//---- pivot points
GfxSetBkColor(colorBlue);
GfxSetTextColor( colorLime );
GfxSelectFont("Times New Roman", 20, 1,500, True );
GfxTextOut(" Intraday Trading System ", 20 , 40 );
_SECTION_END();


_SECTION_BEGIN(" Buy Sell Signal Confirm ");
BarColors =
IIf(BarsSince(Buy) < BarsSince(Sell)
AND BarsSince(Buy)!=0, colorGreen,
IIf(BarsSince(Sell) < BarsSince(Buy)
AND BarsSince(Sell)!=0, colorRed, colorBlue));
//Plot the Candlestick charts
Plot(C, "Close", BarColors, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ) ;
_SECTION_END();

_SECTION_BEGIN("Show Up Down Arrow & Price ");
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

dist = 1.8*ATR(15);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "Buy@" + L[ i ], i, L[ i ]-dist[i], colorWhite, colorGreen );
if( Sell[i] ) PlotText( "Sell@" + H[ i ], i, H[ i ]+dist[i], colorWhite, colorRed );
}


PlotShapes( shape, IIf( Buy, colorBlue, colorRed ), 0, IIf( Buy, Low, High )
);

_SECTION_END();
 
Need help for exploring HH,HL.LH and LL values on any time frame for this code.
Try this.

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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("ZigZag");
P = Param("ZigZag_Percent",0.1,0.01,2,0.01);
ZigH  = Zig(H,P);		ZigL = Zig(L,P);
ZigHi = ZigH > Ref(ZigH,-1) AND ZigH > Ref(ZigH,1);		
ZigLo = ZigL < Ref(ZigL,-1) AND ZigL < Ref(ZigL,1);
j=0;	k=0;	PH[0] = PL[0] = 0;
for( i = 1; i < BarCount-1; i++ ) { 
 if (ZigLo[i])	{
	if (PL[k] > ZigL[i]) {
	 	PlotText("LL",i, L[i]-5, colorRed);
		LL[i] = ZigL[i];
	}
	else {
		PlotText("HL",i, L[i]-5, colorBlue);
		HL[i] = ZigL[i];
	}
	k = k + 1;		PL[k] = ZigL[i]; }
 if (ZigHi[i]) {
	if (PH[j] < ZigH[i]) {
	  	PlotText("HH", i, H[i]+5, colorBlue);
		HH[i] = ZigH[i];
	}
	else {
		PlotText("LH", i, H[i]+5, colorRed);
		LH[i] = ZigH[i];
	}
	j = j + 1;
	PH[j] = ZigH[i]; }
}
_SECTION_END();

Filter = ZigHi OR ZigLo;

AddColumn(High,"High");
AddColumn(Low,"Low");
AddColumn(HH,"HH");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"LL");
 
I am using an indicator in Metatrader which helps to avoid taking a trade when the propability of it moving in my favor are significally low. That is ATR. It calculate the ATR, informs how much the price has moved today and projects a low and a high Projection ATR for the Day. So if let's say we are near the top atr Projected the probability of giving a profit for the day are greatly diminished. I tried to implemented on amibroker but did it only on the title and I dont even jnow if it is correct.
What I would like is from the seniors in here take a look and comment and help to plot the projected lines as well as in the pictures below from MT4.



and here is what I tryed on Ami
Code:
TimeFrameSet(inDaily);
TrueRange = Max( H - L, Max( abs( H - Ref( C, -1 ) ), abs( L - Ref( C, -1 )
) ) );
myATR = MA(TrueRange, 10);
tARGETuP=L+myATR;
tARGETdWN=H-myATR;
TimeFrameRestore();

//Plot(myATR, "myATR", colorBlue, 1);
_SECTION_BEGIN("Title");
dec = (Param("Decimals",2,0,7,1)/10)+1;
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
    EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
    EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
    EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
    EncodeColor(55)+ "    Close = "+ EncodeColor(7)+ WriteVal(C,dec)+
    EncodeColor(55)+ "    Volume = "+ EncodeColor(11)+ WriteVal(V,1)+ "\n" +
    EncodeColor(7)+ "      ATR(10) = "+ EncodeColor(32)+ WriteVal(TimeFrameExpand(Myatr,inDaily),dec)+
	EncodeColor(7)+ "      Today ATR = "+ EncodeColor(32)+ WriteVal(TimeFrameExpand(TrueraNGE,inDaily),dec)+"\n" +
	EncodeColor(7)+ "      TP UP = "+ EncodeColor(32)+ WriteVal(TimeFrameExpand(tARGETuP,inDaily),dec)+
	EncodeColor(7)+ "      TP Dwn = "+ EncodeColor(32)+ WriteVal(TimeFrameExpand(tARGETdwn,inDaily),dec);
_SECTION_END();
Any help greatly appreciated.
 

Similar threads