PureBytes Links
Trading Reference Links
|
While searching the Online message, I found thread
<http://finance.groups.yahoo.com/group/amibroker/messagesearch//group/amibroker/message/62014>Real-Time
Trading System Examples
And Noticed Point 3
3) Custom coding Profit targets, Limit Prices and Stops.
I Have half written a Manual Stop entry Indicator that might be usefull.
(I do stress Might!)
Anyway - SOFAR, You can Manualy set a BuyBar and Buy Price for individual
tickers (Say ones you are currently in trade).
The AFL will write a txt file containing this data. (Via Lock/Set Parameter)
If this file already exists - It loads that instead.
(These files are stored in the /Amibroker/Data/ Folder.)
It will visualy display the BuyBar/Price.
It's still incomplete - So thats why I let you look at it now - Before it
gets to complicated. ;-)
Yet to be written is Display of StopLines and the actual ALERT section.
*Note* I indend the Alert section to Scan through a Watchlist and check
tickers for alert. Obviously, After setting your Stops - You should place the
stock in this watchlist.
Here is the AFL in message as well as attached.
// Manual Stop Entry.
//
//
// Plot Price & Turnover.
Color = IIf(O > C, colorBlack, colorLightYellow);
Plot( Close, "Price", color, styleCandle );
PlotForeign( GetBaseIndex(), GetBaseIndex(), colorAqua, styleLine |
styleThick | styleOwnScale);
Turnover = (V*C);
BarColor =
IIf( Turnover > Ref(Turnover,-1), colorRed , /* up volume */
IIf( Turnover < Ref(Turnover,-1), colorOrange, /* down volume */
colorGreen /*otherwise*/ ));
Plot( Turnover, "Turnover", BarColor, styleHistogram | styleThick |
styleOwnScale);
// Set Default BuyBar & BuyAt etc.
BC = BarCount-1;
BNUM = Cum(1)-1;
SelectedBar = SelectedValue(BarIndex()); // Problem --> See Below.
// Would use Selected Bar for setting BuyBar, Except SelectedValue
is lost
// when Parameters Dialog Box is opened.
BuyBar = Param("1.BuyBar",0,0,5000,1);
BuyAt = Param("2.BuyAt",0,0,100,0.01);
EvenStop = Param("3.EvenStop",2,0,100,1); //Percentage Of Buy Price
ProfitStop = Param("4.ProfitStop",2,0,100,1); //Percentage of Buy Price.
LossStop = Param("5.LossStop",2,0,100,1); //Percentage of Buy Price.
TrailStop = Param("6.TrailStop",2,0,100,1); //Percentage from Highest High
since BuyBar.
// Overide Default BuyBar & BuyAt if previously Set or Write setup.
LockSet = Param("Lock/Set",False,False,True,1);
TrailName = "Data/" + Name()+"~Stop.txt";
if (LockSet == False)
{
fh = fopen( TrailName, "r");
if( fh )
{
BuyBarS = fgets( fh );
BuyAtS = fgets( fh );
BuyBar = StrToNum(BuyBarS);
BuyAt = StrToNum(BuyAtS);
fclose( fh );
TitleS="ReadFile";
}
else
{
printf("Trail Not Set\n");
BuyBar=BC;
BuyAt=C[BuyBar];
TitleS="NoFile";
}
}
else
{
BuyBar = IIf ((BuyBar == 0),BC,BuyBar);
BuyAt = IIf ((BuyAt == 0),C[BuyBar],BuyAt);
TitleS = "SaveFile";
fh = fopen( TrailName, "w");
if( fh )
{
fputs( StrFormat("%.00f\n",BuyBar), fh );
fputs( StrFormat("%.02f\n",BuyAt ), fh );
fclose( fh );
}
}
// Plot Vertical & Horizontal Buy Bar/Price. (Blue/Yellow)
VLine = IIf(BuyBar==BNUM,1,0);
Plot (VLine ,"DateBar", colorBlue, styleHistogram |
styleOwnScale,0,1);
x0 = Buybar-1 ; x1 = BuyBar+1 ;
y0 = BuyAt; y1 = BuyAt;
Hline = LineArray(x0,y0,x1,y1,3);
Plot(HLine ,"PriceBar",colorYellow,styleLine);
// Plot Trade Trend (BuyBar to Current Bar - Blue Dashed Line).
// Plot Break Even Horizontal (Green).
// Plot Loss Stop Horizontal (Red).
// Plot Profit Stop Horizontal (Light Yellow)
// Plot Trail Stop Trend (Highest High to Current Bar - Orange Dashed Line).
// Display "Selected Bars Stats" for set reference.
printf("BuyBar: %.00f",BuyBar);
printf("\nBuyAt : %.02f",BuyAt);
printf("\n\nBarSelected: %.00f",SelectedBar);
printf("\nOpen :%.02f",O);
printf("\nHigh :%.02f",H);
printf("\nLow :%.02f",L);
printf("\nClose :%.02f",C);
printf("\nVolume :%.02f",V);
// Dynamic Title (Reset when Parameters Dialog is Opened).
_N(Title = "\\c29"+
"Trail Stop "+
"\\c32"+ Date()+
"\\c29 Ticker: \\c32"+Name()+
"\\c29 Index: \\c24"+GetBaseIndex()+
"\n"+
"\\c38 Open \\c01"+O+
"\\c38 Hi \\c01"+H+
"\\c38 Low \\c01"+L+
"\\c38 Close \\c01"+C+
"\\c38 TurnOver \\c24"+WriteVal(TurnOver,1)+
"\n" + TitleS +
"\n\\c32SelectedBar: "+ SelectedBar+
"");
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
// Manual Stop Entry.
//
//
// Plot Price & Turnover.
Color = IIf(O > C, colorBlack, colorLightYellow);
Plot( Close, "Price", color, styleCandle );
PlotForeign( GetBaseIndex(), GetBaseIndex(), colorAqua, styleLine | styleThick | styleOwnScale);
Turnover = (V*C);
BarColor =
IIf( Turnover > Ref(Turnover,-1), colorRed , /* up volume */
IIf( Turnover < Ref(Turnover,-1), colorOrange, /* down volume */
colorGreen /*otherwise*/ ));
Plot( Turnover, "Turnover", BarColor, styleHistogram | styleThick | styleOwnScale);
// Set Default BuyBar & BuyAt etc.
BC = BarCount-1;
BNUM = Cum(1)-1;
SelectedBar = SelectedValue(BarIndex()); // Problem --> See Below.
// Would use Selected Bar for setting BuyBar, Except SelectedValue is lost
// when Parameters Dialog Box is opened.
BuyBar = Param("1.BuyBar",0,0,5000,1);
BuyAt = Param("2.BuyAt",0,0,100,0.01);
EvenStop = Param("3.EvenStop",2,0,100,1); //Percentage Of Buy Price
ProfitStop = Param("4.ProfitStop",2,0,100,1); //Percentage of Buy Price.
LossStop = Param("5.LossStop",2,0,100,1); //Percentage of Buy Price.
TrailStop = Param("6.TrailStop",2,0,100,1); //Percentage from Highest High since BuyBar.
// Overide Default BuyBar & BuyAt if previously Set or Write setup.
LockSet = Param("Lock/Set",False,False,True,1);
TrailName = "Data/" + Name()+"~Stop.txt";
if (LockSet == False)
{
fh = fopen( TrailName, "r");
if( fh )
{
BuyBarS = fgets( fh );
BuyAtS = fgets( fh );
BuyBar = StrToNum(BuyBarS);
BuyAt = StrToNum(BuyAtS);
fclose( fh );
TitleS="ReadFile";
}
else
{
printf("Trail Not Set\n");
BuyBar=BC;
BuyAt=C[BuyBar];
TitleS="NoFile";
}
}
else
{
BuyBar = IIf ((BuyBar == 0),BC,BuyBar);
BuyAt = IIf ((BuyAt == 0),C[BuyBar],BuyAt);
TitleS = "SaveFile";
fh = fopen( TrailName, "w");
if( fh )
{
fputs( StrFormat("%.00f\n",BuyBar), fh );
fputs( StrFormat("%.02f\n",BuyAt ), fh );
fclose( fh );
}
}
// Plot Vertical & Horizontal Buy Bar/Price. (Blue/Yellow)
VLine = IIf(BuyBar==BNUM,1,0);
Plot (VLine ,"DateBar", colorBlue, styleHistogram | styleOwnScale,0,1);
x0 = Buybar-1 ; x1 = BuyBar+1 ;
y0 = BuyAt; y1 = BuyAt;
Hline = LineArray(x0,y0,x1,y1,3);
Plot(HLine ,"PriceBar",colorYellow,styleLine);
// Plot Trade Trend (BuyBar to Current Bar - Blue Dashed Line).
// Plot Break Even Horizontal (Green).
// Plot Loss Stop Horizontal (Red).
// Plot Profit Stop Horizontal (Light Yellow)
// Plot Trail Stop Trend (Highest High to Current Bar - Orange Dashed Line).
// Display "Selected Bars Stats" for set reference.
printf("BuyBar: %.00f",BuyBar);
printf("\nBuyAt : %.02f",BuyAt);
printf("\n\nBarSelected: %.00f",SelectedBar);
printf("\nOpen :%.02f",O);
printf("\nHigh :%.02f",H);
printf("\nLow :%.02f",L);
printf("\nClose :%.02f",C);
printf("\nVolume :%.02f",V);
// Dynamic Title (Reset when Parameters Dialog is Opened).
_N(Title = "\\c29"+
"Trail Stop "+
"\\c32"+ Date()+
"\\c29 Ticker: \\c32"+Name()+
"\\c29 Index: \\c24"+GetBaseIndex()+
"\n"+
"\\c38 Open \\c01"+O+
"\\c38 Hi \\c01"+H+
"\\c38 Low \\c01"+L+
"\\c38 Close \\c01"+C+
"\\c38 TurnOver \\c24"+WriteVal(TurnOver,1)+
"\n" + TitleS +
"\n\\c32SelectedBar: "+ SelectedBar+
"");
|