Professional Documents
Culture Documents
Buy Sell System
Buy Sell System
//-------------------------------------------------------------------------
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat(" Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C,
SelectedValue( ROC( C, 1 ) ) ));
T=23;
BHSda=((C-MA(C,T))/MA(C,T))*100;
Graph0=BHSda;
Graph0Style=2+4;
Graph0BarColor=IIf(BHSda>0,5,4);
GraphXSpace=5;
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | styleCandle );
Plot( O, "Open", ParamColor("Color", colorBlack ), styleNoDraw);
Plot( H, "High", ParamColor("Color", colorBlack ), styleNoDraw);
Plot( L, "Low", ParamColor("Color", colorBlack ),styleNoDraw);
//------------------------------------------------------------------------------
Value1 = 60;
Value2 = 40;
BHSMPPer= 13;
BHEXPerc = 2 * BHSMPPer- 1;
//------------------------------------------------------------------------------
r1 = 12;
r2 = 26;
r3 = 9;
Z = 1;
Cond1 = Cross(MACD(r1,r2),Signal(r1,r2,r3));
Cond3 = Zig(C,z)>Ref(Zig(C,z),-4);
Buy = Cond1 AND Cond3;
Cond4 = Cross(Signal(r1,r2,r3),MACD(r1,r2));
Cond6 = Zig(C,z)<Ref(Zig(C,z),-4);
Sell = Cond4 AND Cond6;
//---------------------------------------------------------------------------------
---------------
if((Status("action") == actionExplore) OR (Status("action") == actionScan))
Filter = Buy OR Sell;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Symbol", 77, BSFG, BSG, 120);
AddColumn(DateTime(), "Date", formatDateTime, BSFG, BSG, 100);
AddColumn(TimeNum() ,"Time",1,BSFG, BSG, 100);
AddColumn( Buy, "Buy", 1,BSFG, BSG, 50);
AddColumn( Sell, "Sell", 1,BSFG, BSG, 50 );
AddColumn( O, "Open", 1.2,BSFG, BSG, 100 );
AddColumn( H, "High", 1.2,BSFG, BSG, 100 );
AddColumn( L, "Low", 1.2,BSFG, BSG, 100 );
AddColumn( C, "Close", 1.2,BSFG, BSG, 100 );
AddColumn(Ref(V,-1),"P-Vol",1,BSFG, BSG, 100);
AddColumn(V/(Ref(V,-1)*100),"Increase in Vol",1,BSFG, BSG, 100);
//---------------------------------------------------------------------------------
------------------------
C13=20;//Param("fonts",20,10,30,1 );
C14=2.1;//Param("left-right",2.1,1.0,5.0,0.1 );
C15=12;//Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.4 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.45 );
GfxSetTextColor( colorWhite);
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
//---------------------------------------------------------------------------------
---------------
SetChartBkGradientFill( ParamColor("BgTop",
colorDarkOliveGreen),ParamColor("BgBottom", colorDarkGrey));
pShowtradeLines = ParamToggle("Show Trade Lines", "No|Yes", 1);
Volmin=5000;
Volmax=1000000;
priceRL=150;
priceRH=3000;
BSPeChMi=-25;
BSPeChMa=25;
BSPerTkProf=0.6;
BSPerStLos=0.25;
Bars = 0;
xpdh = 90;
{
BSPl_Rng = (TimeNum() >= 90000 AND TimeNum()<= 235500) AND
(DateNum()==LastValue(DateNum()));
BSFH_Rg = (TimeNum() >= 090000 AND TimeNum()<= 093000) AND
(DateNum()==LastValue(DateNum()));
TimeFrameSet(inDaily);
TOP_ = Open;
PDH_ = Ref(High,-1);
PDL_ = Ref(Low,-1);
PDO_ = Ref(Open,-1);
PDC_ = Ref(Close,-1);
PDM_ = (PDH_+PDL_)/2;
TimeFrameRestore();
isAll = True;
isRth = TimeNum() >= 085400 AND TimeNum() <= 093000;
isdRth = TimeNum() >= 085400 AND TimeNum() <= 160000;
TOP = TimeFrameExpand(TOP_,inDaily,expandFirst);
PDH = TimeFrameExpand(PDH_,inDaily,expandFirst);
PDL = TimeFrameExpand(PDL_,inDaily,expandFirst);
PDO = TimeFrameExpand(PDO_,inDaily,expandFirst);
PDC = TimeFrameExpand(PDC_,inDaily,expandFirst);
PDM = TimeFrameExpand(PDM_,inDaily,expandFirst);
FHH = Ref(HHV(High*BSFH_Rg,Num_Bars),-BSFH_Mrk);
FHL = TimeFrameCompress( aRthL, inDaily, compressLow );
FHL = TimeFrameExpand( FHL, inDaily, expandFirst );
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
FC1=((PDH-PDL)*0.433);
FC2=((PDH-PDL)*0.7666);
FC3=((PDH-PDL)*1.355);
FC4=(FHH-FHL);
A=IIf((FC4<=FC1+PDH*0.005),FC1,0);
B=IIf((FC4<=FC2+PDH*0.005 AND FC4>FC1+PDH*0.005),FC2,0);
Cl=IIf((FC4<=FC3 AND FC4>FC2+PDH*0.005),FC3,0);
AF=(A+B+Cl);
HaC =(O+H+L+C)/4;
HaO = AMA( Ref( HaC, -1 ), 0.5 );
HaH = Max( H, Max( HaC, HaO) );
HaL = Min( L, Min( HaC, HaO) );
BG3=HHV(LLV(HaL,4)+ATR(4),8);
BR3=LLV(HHV(HaH ,4)-ATR(4),8);
co = IIf(Hac>BG3 ,colorBlue,IIf(Hac < BR3,colorRed,colorGrey50));
BuyPrice=(DayL+AF);
BSByTP1=(BuyPrice+(BuyPrice*(BSPerTkProf/100)));
BSByTP2=(C>=BSByTP1);
SellPrice=(DayH-AF);
BSSlTP1=(SellPrice-(SellPrice*(BSPerTkProf/100)));
BSSlTP2=(C<=BSSlTP1);
BSPrCh=(((C-TOP)/TOP)*100);
Vol=(V>=Volmin AND V<=Volmax);
Percentage=(BSPrCh>=BSPeChMi AND BSPrCh<=BSPeChMa);
prc=(C>=priceRL AND C<=priceRH);
BuyStop1=(BuyPrice-(BuyPrice*(BSPerStLos/100)));
BuyStop2=IIf((BuyStop1<=SellPrice) AND SellPrice<=BuyPrice,SellPrice,BuyStop1);
SellStop1=(SellPrice+(SellPrice*(BSPerStLos/100)));
SellStop2=IIf((SellStop1>=BuyPrice) AND SellPrice<=BuyPrice, BuyPrice,SellStop1);
Plot(IIf(pShowtradeLines,BuyStopline,Null),"",colorBrightGreen,styleDots|
styleNoRescale| styleNoLine);
Plot(IIf(pShowtradeLines,SellPriceline,Null),"",colorRed,styleDots|styleNoRescale);
//---------------------------------------------------------------------------------
----------------------------------------
CHA= (O+H+L+C)/4;
OHA = AMA( Ref( CHA,-2 ), 0.5 );
HAH = Max( H, Max( CHA,OHA ) );
HAL = Min( L, Min( CHA,OHA ) );
BG2=HHV(LLV(Low,4)+ATR(4),8);
BR2=LLV(HHV(High,4)-ATR(4),8);
k = Optimize("K",1.75,1,5,0.25);
Per =Optimize("A",10,3,30,1);
j=CHA;
nm=(H-L);
rfsctor = WMA(nm, PER);
revers = (K *rfsctor);
Trend = 1;
NW[0] = 0;
for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j[i] < NW[i-1])
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;
if((j[i] - Revers[i]) > NW[i-1])
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j[i] > NW[i-1])
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;
if((j[i] + Revers[i]) < NW[i-1])
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}
Plot(NW,"",IIf(Trend ==1,6,4),4);
Buy=Cross(j,nw);
Short=Cross(nw,j);
Sell=Cross(nw,j);
Cover=Cross(j,nw);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
dist = 1.5*ATR(15);
Buy2show=0;
Sell2show=0;
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] )
{
PlotText( "Buy@" +WriteVal( H[ i],1.2), i-5, H[ i ]-Trend[i], colorWhite,
colorBlue);
Buy2show=H[i];
}
if( Sell[i] )
{
PlotText( "Sell@" +WriteVal (L[ i ],1), i-5, L[ i ]+Trend[i], colorWhite, colorRed
);
Sell2show=L[ i ];
}
}
AlertIf(Sell,"SOUND C:\\Windows\\Media\\Ding.wav","Sell@" + WriteVal( H,1.2) ,2);
AlertIf(Buy,"SOUND C:\\Windows\\Media\\Ding.wav","Buy@" + WriteVal( O,1.2),1);
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
//---------------------------------------------------------------------------------
-------------
//---------------------------
//to plot buysell price
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorGreen, 2 );
GfxSelectSolidBrush( colorBlack );
GfxRoundRect( 5, 181,250,240, 15, 15 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorPaleGreen );
GfxSetTextAlign(0);
bf=(H-B);
SF=(O-L);
GfxSetTextColor( colorYellow );
GfxTextOut( WriteIf( Long AND NOT Buy, "BUY Profit = "+WriteVal(C-
Buy2show,1.2 ),""),10, 205);
GfxTextOut( WriteIf( shrt AND NOT Sell, "SELL Profit = "+WriteVal(Sell2show-
C,1.2 ),""),10, 205);
//GfxTextOut( WriteIf(Long OR shrt , "CMP = "+WriteVal(C,1.2),""),10, 215);
//---------------------------------------------------------------------------------
--------------------
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorOrange, 2 );
GfxSelectSolidBrush( colorBlack );
GfxRoundRect(5,20, 250,63, 16, 20 );
GfxSetBkMode(1);
GfxSelectFont( "Arial",12, 700, False );
GfxSetTextColor( colorPaleGreen );
GfxSetTextAlign(0);
GfxSetTextColor( colorYellow );
GfxTextOut(WriteIf(SellPrice, "TREND REVERSAL: "+(SellPrice),""), 8 ,25 );
GfxSetTextColor( colorRed );
GfxTextOut( WriteIf(nw, " Trailing SL : "+WriteVal(nw,1),""), 8,
43);
GfxTextOut( WriteIf(Cover AND NOT Buy ," Trailing SL : "+WriteVal(nw,1
),""),8, 43);
GfxSetTextColor( colorGold );
GfxTextOut( WriteIf(nw, " Trailing SL : "+WriteVal(nw,1),""), 8,
43);
GfxTextOut( WriteIf( Short AND NOT Sell," Trailing SL :
"+WriteVal(nw,1 ),""),8, 43);
//-----------------------------------------------------------------------------
function LFI(ret)
{
retval = (Delta * ret);
LFIVal = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return LFIVal;
}
xo=Min(xSp0,xRp0)-Back;
x1=BarCount-1;
//////////////////////////////////////////////////////////////////
r236 = LFI(0.236); r236I = LastValue (r236,1);
r382 = LFI(0.382); r382I = LastValue (r382,1);
r050 = LFI(0.50); r050I = LastValue (r050,1);
r618 = LFI(0.618); r618I = LastValue (r618,1);
r786 = LFI(0.786); r786I = LastValue (r786,1);
e127 = LFI(1.27); e127I = LastValue (e127,1);
e162 = LFI(1.62); e162I = LastValue (e162,1);
e200 = LFI(2.00); e200I = LastValue (e200,1);
e262 = LFI(2.62); e262I = LastValue (e262,1);
e424 = LFI(4.24); e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1);
color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
//////////////////////////////////////////////////////////////////
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
if(text==1)
{
PlotText(" 0% = " + WriteVal(p00,1), LastValue(BarIndex())-(numbars/hts),
p00I + 0.05, color00);
PlotText("23% = " + WriteVal(r236,1), LastValue(BarIndex())-(numbars/hts),
r236I + 0.05, color00);
PlotText("38% = " + WriteVal(r382,1), LastValue(BarIndex())-(numbars/hts),
r382I + 0.05, color00);
PlotText("50% = " + WriteVal(r050,1), LastValue(BarIndex())-(numbars/hts),
r050I + 0.05, color00);
PlotText("62% = " + WriteVal(r618,1), LastValue(BarIndex())-(numbars/hts),
r618I + 0.05, color00);
PlotText("78% = " + WriteVal(r786,1), LastValue(BarIndex())-(numbars/hts),
r786I + 0.05, color00);
PlotText("100% = " + WriteVal(p100,1), LastValue(BarIndex())-
(numbars/hts),p100I + 0.05, color00);
PlotText("127% = " + WriteVal(e127,1), LastValue(BarIndex())-
(numbars/hts),e127I + 0.05, color00);
PlotText("162% = " + WriteVal(e162,1), LastValue(BarIndex())-
(numbars/hts),e162I + 0.05, color00);
PlotText("200% = " + WriteVal(e200,1), LastValue(BarIndex())-
(numbars/hts),e200I + 0.05, color00);
PlotText("262% = " + WriteVal(e262,1), LastValue(BarIndex())-
(numbars/hts),e262I + 0.05, color00);
PlotText("424% = " + WriteVal(e424,1), LastValue(BarIndex())-
(numbars/hts),e424I + 0.05, color00);
}
////////////////////////////////////////////////////////////////////////////
//Normal Pivot
PP = (YH + YL + YC) / 3;
R1 = (2 * PP) - YL;
R2 = PP + (YH - YL);
R3 = YH + 2*(PP-YL);
S1 = (2 * PP) - YH;
S2 = PP - (YH - YL);
S3 = YL - 2*(YH - PP) ;
//
-----------------------------------------------------------------------------------
_SECTION_END();