Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Hello seniors,

i need help to plot exploration ...


BUY CONDITION
1) EMA 20 CROSSOVER FROM BELOW EMA 50 (Price to close above 20 EMA)
2) RSI (14,9) CROSSOVER FROM BOTTOM
3) MACD ( 9,9,24) CROSSOVER FROM BOTTOM
(All conditions to satisfy at a time then = BUY)

SELL CONDITION
1) EMA 20 CROSSOVER FROM ABOVE EMA 50(Price to close below 20 EMA)
2) RSI (14,9) CROSSOVER FROM TOP
3) MACD (9,9,24) CROSSOVER FROM TOP
(All conditions to satisfy at a time then = Sell)

Thanx you in advance
http://www.traderji.com/amibroker/97113-rsi-macd-ema-crossover-buy-signal.html#post1041492

Just modify parameters
 
HI all seniors,

I am a newbie to AMI while searching something else i found this site lucky to be here, if any one help me to find a simple AFL which tells you Demand and supply would be better.
I have this code but it isn't very good as it calculate demand and supply on very near prices the higher the range the better it will be

posting the code below here. thanks in advance.

_SECTION_BEGIN("demand and supply");
SetChartOptions(0,chartShowArrows|chartShowDates);
bk=ParamColor( "Bk col",colorDarkGrey);
SetChartBkColor(bk);
SetBarFillColor(IIf(C>O,colorBrightGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C," | Demand & supply |\nPrice",47,64,0,0,0,0);

sr=ParamToggle("Plot Supp/Res lines","No|Yes" ,1);
Per=Param("Sensitivity",1.5,0.5,5,0.5);
g=Param("No.of Lines",1,1,5,1);
x=Cum(1);
Pk1=PeakBars(H,per,1)== 0;
Tk1=TroughBars(L,per,1)== 0;

px1=LastValue(ValueWhen(pk1,x,1));
px2=LastValue(ValueWhen(Pk1,x,2));
px3=LastValue(ValueWhen(Pk1,x,3));
px4=LastValue(ValueWhen(pk1,x,4));
px5=LastValue(ValueWhen(Pk1,x,5));

tx1=LastValue(ValueWhen(Tk1,x,1));
tx2=LastValue(ValueWhen(Tk1,x,2));
tx3=LastValue(ValueWhen(Tk1,x,3));
tx4=LastValue(ValueWhen(Tk1,x,4));
tx5=LastValue(ValueWhen(Tk1,x,5));

XT1 =LastValue(ValueWhen(pk1,H,1));XT1c =LastValue(ValueWhen(pk1,Max(C,O),1));
XT2 =LastValue(ValueWhen(Pk1,H,2));XT2c =LastValue(ValueWhen(pk1,Max(C,O),2));
XT3 =LastValue(ValueWhen(Pk1,H,3));XT3c =LastValue(ValueWhen(pk1,Max(C,O),3));
XT4 =LastValue(ValueWhen(pk1,H,4));XT4c =LastValue(ValueWhen(pk1,Max(C,O),4));
XT5 =LastValue(ValueWhen(Pk1,H,5));XT5c =LastValue(ValueWhen(pk1,Max(C,O),5));

YT1 =LastValue(ValueWhen(tk1,L,1));YT1c =LastValue(ValueWhen(tk1,Min(O,C),1));
YT2 =LastValue(ValueWhen(tk1,L,2));YT2c =LastValue(ValueWhen(tk1,Min(O,C),2));
YT3 =LastValue(ValueWhen(tk1,L,3));YT3c =LastValue(ValueWhen(tk1,Min(O,C),3));
YT4 =LastValue(ValueWhen(tk1,L,4));YT4c =LastValue(ValueWhen(tk1,Min(O,C),4));
YT5 =LastValue(ValueWhen(tk1,L,5));YT5c =LastValue(ValueWhen(tk1,Min(O,C),5));

pk1=IIf(x>px1 AND g>=1 AND sr,XT1,Null);pk1c=IIf(x>px1 AND g>=1 AND sr,XT1c,Null);
Col1=IIf( LastValue(C)>pk1, ColorRGB(14,14,100), ColorRGB(180,20,20) );
Plot(pk1,"",31,1);PlotOHLC(0,pk1,pk1c,0,"",Col1,styleCloud|styleNoLabel,Null, Null, Null, -1);
pk2=IIf(x>px2 AND g>=2 AND sr,XT2,Null);pk2c=IIf(x>px2 AND g>=2 AND sr,XT2c,Null);
Col2=IIf( LastValue(C)>pk2, ColorRGB(24,24,120), ColorRGB(180,40,40) );
Plot(pk2,"",31,1);PlotOHLC(0,pk2,pk2c,0,"",Col2,styleCloud|styleNoLabel,Null, Null, Null, -2);
pk3=IIf(x>px3 AND g>=3 AND sr,XT3,Null);pk3c=IIf(x>px3 AND g>=3 AND sr,XT3c,Null);
Col3=IIf( LastValue(C)>pk3, ColorRGB(34,34,140),ColorRGB(180,60,60));
Plot(pk3,"",31, 1);PlotOHLC(0,pk3,pk3c,0,"",Col3,styleCloud|styleNoLabel,Null, Null, Null, -3);
pk4=IIf(x>px4 AND g>=4 AND sr,XT4,Null);pk4c=IIf(x>px4 AND g>=4 AND sr,XT4c,Null);
Col4=IIf( LastValue(C)>pk4, ColorRGB(44,44,160), ColorRGB(180,80,80));
Plot(pk4,"",31,1);PlotOHLC(0,pk4,pk4c,0,"",Col4,styleCloud|styleNoLabel,Null, Null, Null, -4);
pk5=IIf(x>px5 AND g>=5 AND sr,XT5,Null);pk5c=IIf(x>px5 AND g>=5 AND sr,XT5c,Null);
Col5=IIf( LastValue(C)>pk5, ColorRGB(54,54,180), ColorRGB(180,100,100));
Plot(pk5,"",31,1);PlotOHLC(0,pk5,pk5c,0,"",Col5,styleCloud|styleNoLabel,Null, Null, Null, -5);
tl1=IIf(x>tx1 AND g>=1 AND sr,YT1,Null);tl1c=IIf(x>tx1 AND g>=1 AND sr,YT1c,Null);
Col1=IIf( LastValue(C)>tl1, ColorRGB(14,14,100), ColorRGB(180,20,20) );
Plot(tl1,"",1,1);PlotOHLC(0,tl1,tl1c,0,"",Col1,styleCloud|styleNoLabel,Null, Null, Null, -1);
tl2=IIf(x>tx2 AND g>=2 AND sr,YT2,Null);tl2c=IIf(x>tx2 AND g>=2 AND sr,YT2c,Null);
Col2=IIf( LastValue(C)>YT2, ColorRGB(24,24,120), ColorRGB(180,40,40));
Plot(tl2,"",1,1);PlotOHLC(0,tl2,tl2c,0,"",Col2,styleCloud|styleNoLabel,Null, Null, Null, -2);
tl3=IIf(x>tx3 AND g>=3 AND sr,YT3,Null);tl3c=IIf(x>tx3 AND g>=3 AND sr,YT3c,Null);
Col3=IIf( LastValue(C)>YT3, ColorRGB(34,34,140), ColorRGB(180,60,60) );
Plot(tl3,"",1,1);PlotOHLC(0,tl3,tl3c,0,"",Col3,styleCloud|styleNoLabel,Null, Null, Null, -3);
tl4=IIf(x>tx4 AND g>=4 AND sr,YT4,Null);tl4c=IIf(x>tx4 AND g>=4 AND sr,YT4c,Null);
Col4=IIf( LastValue(C)>YT4, ColorRGB(44,44,160), ColorRGB(180,80,80) );
Plot(tl4,"",1,1);PlotOHLC(0,tl4,tl4c,0,"",Col4,styleCloud|styleNoLabel,Null, Null, Null, -4);
tl5=IIf(x>tx5 AND g>=5 AND sr,YT5,Null);tl5c=IIf(x>tx5 AND g>=5 AND sr,YT5c,Null);
Col5=IIf( LastValue(C)>YT5, ColorRGB(54,54,180), ColorRGB(180,100,100));
Plot(tl5,"",1,1);PlotOHLC(0,tl5,tl5c,0,"",Col5,styleCloud|styleNoLabel,Null, Null, Null, -5);

_SECTION_END();
Kindly help
 

Aman1

Well-Known Member
This formula plots vol histogram. I need volume POC in different color with value.
_SECTION_BEGIN("VAP");
segments = IIf( Interval() < inDaily, Day(), Month() );
segments = segments != Ref( segments , -1 );

PlotVAPOverlayA( segments , Param("Lines", 300, 100, 1000, 1 ), Param("Width", 80, 1, 100, 1 ), ParamColor("Color", ColorRGB(255,245,200) ), ParamToggle("Side", "Left|Right" ) | 2 * ParamToggle("Style", "Fill|Lines", 0) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) );
Plot(segments, "", colorLightGrey, styleHistogram | styleOwnScale );

_SECTION_END();

My apologies for not posting formula in # could not succeed.:confused:
 
**Non-repaintable HHV LLV drawn Horizontal lines**
Help please for the below query friends..

Does anybody have reference to draw horizontal lines according to HHV and LLV during a particular period. AFL should NOT be repaintable.
For eg:
Within 10 bars range [Weekly view], HHV and LLV have to be identified and Horizontal lines have to be drawn.
When period is changed to [Daily view], HHV and LLV should not be re-calculated but drawn lines on Weekly have to be shown.
Image attached for reference, please help.
 
Last edited:

amitrandive

Well-Known Member

hmp

Well-Known Member
Will someone pl. add buy/ sell arrows & exploration/scanning for crossover of 5min(yellow) & hourly stepped line(white) in the following multi time frame afl?
Thanks & regards.
Code:
_SECTION_BEGIN("Trend Color");

HaClose =EMA((O+H+L+C)/4,3); 
HaOpen = IIf(BarIndex()>0,AMA( Ref( HaClose, -1 ), 0.5 ),Open);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) ); 

p1=Param("Extreme period1",5,3,10);
p2=Param("Extreme period2",8,3,20);
p3=Param("Extreme period3",13,3,50);
sc=Param("Score Limit",3,1,7);

HaDiff = IIf(HaClose>HaOpen, 1, IIf((O+H+L+C)/4<HaOpen,-1,0));
HaDiff1 = IIf(HaClose>EMA(HaClose,p1), 1, IIf(HaClose<EMA(HaClose,p1),-1,0));
HaDiff2 = IIf(HaClose>EMA(HaClose,p2), 1, IIf(HaClose<EMA(HaClose,p2),-1,0));
HaDiff3 = IIf(HaClose>EMA(HaClose,p3), 1, IIf(HaClose<EMA(HaClose,p3),-1,0));
HaDiff4 = IIf(EMA(HaClose,p1)>EMA(HaClose,p2), 1, IIf(EMA(HaClose,p1)<EMA(HaClose,p2),-1,0));
HaDiff5 = IIf(EMA(HaClose,p2)>EMA(HaClose,p3), 1, IIf(EMA(HaClose,p2)<EMA(HaClose,p3),-1,0));
HaDiff6 = IIf(HaClose>Ref(HaClose,-1), 1, IIf(HaClose<Ref(HaClose,-1),-1,0));

TScore = HaDiff + HaDiff1 + HaDiff2 + HaDiff3 + HaDiff4 + HaDiff5 + HaDiff6;

FillColor = IIf(TScore>sc AND NOT (Ref(TScore,-1)<sc AND Avg<Ref(Avg,-1)),colorLime,
        IIf(TScore<-sc AND NOT (Ref(TScore,-1)>-sc AND Avg>Ref(Avg,-1)),ColorRGB(100,0,0),colorWhite));
mycolor=IIf(Tscore>0, colorGreen,colorRed);

SetBarFillColor(Fillcolor);

PlotOHLC(O,H,L,C,"Candlestick",myColor,styleCandle|styleLine);
_SECTION_END();

_SECTION_BEGIN("Min");
//

T = Param("Time", 3,1, 60,1);
TimeFrameSet( T* in1Minute ); // switch to 5 minute frame

P = Param("30Min P", 9, 3, 100,1);

ma30_9 = MA( C, P);
Plot( TimeFrameExpand( ma30_9, T* in1Minute), " EMA T",ParamColor( "T EMA", colorCycle ), ParamStyle("T Min style",styleLine | styleThick));
TimeFrameRestore(); // restore time frame to original



TimeFrameSet( in5Minute ); // switch to 5 minute frame

P = Param("5 Min P", 9, 3, 100,1);

ma5_13 = MA( C, P);
Plot( TimeFrameExpand( ma5_13, in5Minute), " EMA 5Min",ParamColor( "5Min EMA", colorCycle ), ParamStyle("5Min style",styleLine | styleThick));
TimeFrameRestore(); // restore time frame to original

TimeFrameSet( in15Minute); // switch to 15 minute frame

P = Param("15 Min P", 11, 3, 100,1);

ma5_15 = MA( C, P);
Plot( TimeFrameExpand( ma5_15, in15Minute), " EMA 15Min",ParamColor( "15Min EMA", colorCycle ), ParamStyle("15Min style",styleLine | styleNoRescale));
TimeFrameRestore(); // restore time frame to origina

TimeFrameSet( inHourly ); // switch now to hourly
P1 = Param("Hr P", 21, 3, 100,1);
mah_9 = MA( C, P1 ); //  moving average from hourly data
Plot( TimeFrameExpand( mah_9, inHourly), " EMA Hrly",ParamColor( "Hr EMA", colorCycle ), ParamStyle("Hr style",styleLine | styleThick| styleNoRescale));
TimeFrameRestore(); // restore time frame to original

TimeFrameSet( inDaily ); // switch now to hourly
P2 = Param("Daily P", 21, 3, 100,1);
mah_13D = MA( C, p2 ); // moving average from daily data
Plot( TimeFrameExpand( mah_13D, inDaily), " EMA Daily",ParamColor( "Daily EMA", colorCycle ), ParamStyle("Daily style",styleLine | styleThick| styleNoRescale));
TimeFrameRestore(); // restore time frame to original
 

_SECTION_END();


//---- pivot points 
DayH = TimeFrameGetPrice("H", inDaily,-1);// yesterdays high 
DayL = TimeFrameGetPrice("L", inDaily,-1);//low 
DayC = TimeFrameGetPrice("C", inDaily,-1);//close 
DayO = TimeFrameGetPrice("O", inDaily,-1);// current day open 
HiDay = TimeFrameGetPrice("H", inDaily); 
LoDay = TimeFrameGetPrice("L", inDaily); 
PP = (DayH + DayL + DayC) / 3 ; 

D = (DayH - DayL)/2;
R1 = D+DayC;

R2 = (DayH-DayL)+DayC;

R3 = R2 +D ;

S1 = DayC - D; 
 
S2 = DayC - (DayH - DayL); 
 
S3 = S2 - D; 

style = styleLine + styleNoRescale; 
rcolor = colorBlue; 
scolor = colorRed; 
pcolor = colorPink;

 Plot( PP, "  P P", ParamColor( "PP", colorTeal ), ParamStyle("PPStyle") );
Plot(R1,"RES",colorRed, styleLine|styleDashed| styleNoRescale );
Plot(R2,"Mid",colorBlue, styleLine|styleDashed| styleNoRescale);
Plot(R3,"SUP",colorGreen, styleLine|styleDashed|  styleNoRescale );
Plot(S1,"RES",colorRed, styleLine|styleDashed|  styleNoRescale );
Plot(s2,"Mid",colorBlue, styleLine|styleDashed| styleNoRescale);
Plot(S3,"SUP",colorGreen, styleLine|styleDashed| styleNoRescale );




_SECTION_END();

//============== TITLE ==============
_SECTION_BEGIN( "Title" );

  
 
  y = Status( "pxchartheight" );
 
GfxTextOut( ("n j e t h v a @ y m a i l . c o m "), 20, y -30);

_SECTION_END();

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style ); 
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style ); 
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.8 ), styleNoLabel| styleNoRescale | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 

Similar threads