PureBytes Links
Trading Reference Links
|
I'm getting the following error when using the code:
Line 139, Column 29:
"Pyramid Conditions Met = "+WriteIf
((Shares*AvgEntry+PyramidShares*LongBasePrice)-
((Shares+PyramidShares)*(StopPoint-
TrailStop)) <= (AccountEquity *0.015),"\\c32YES\\c-1","NO");
----------------------------------------------------------------------
-----------------------------------------------------------^
Variable 'longbaseprice' used without having been initialized.
How do I resolve this? TIA.
rgds, Pal
--- In amibroker@xxxxxxxxxxxxxxx, "Tony/Dianne" <awenos@xxxx> wrote:
> Dingo,
>
> Following up with stock data entry.
>
> To start, set up a symbol in AB, such as ~SGMS, and give it a full
name, Trade Data. I always give it
> an index attribute so I can filter it out easily from any AA or IB
work .
>
> I enter the data into the same spreadsheet I use for Portfolio
data.
>
> Data Field Data Item
> Ticker ~SGMS
> Date Y/M/D
> Open Average Entry Share Price
(average in the event of a pyramid)
> High Not Used
> Low Stop Loss
> Close Average Exit Share Price
> Volume # Shares
> O Interest A code #, explained below.
>
> In data items where there is no entry, such as High, I enter .0001
which helps me control
> displayed values in an indicator. I do not account for
commissions, but could easily do so
> by using the High field or entering the Entry Price net of
commissions
>
> Codes
> 1 Bought this date
> 2 Sold this date
> 10 Enter this on the day after a Buy (controls certain plots)
> 20 Enter this on the day after a Sell (controls certain plots)
>
>
> Here is some code I use with the above.
>
> AvgEntry = Foreign("~"+Name(),"Open");
>
> StopLoss = Foreign("~"+Name(),"Low");
>
> AvgExit = Foreign("~"+Name(),"Close");
>
> Shares = Foreign("~"+Name(),"Volume");
>
> Code = Foreign("~"+Name(),"Interest");
>
> StopLoss = IIf(Code == 20,Null, Stoploss);
>
> TrailStop = ATR(40) * 4;
>
> GraphXSpace =5;
>
> Plot(Close,Name(),colorGreen,64); //Plots a chart of the current
symbol
>
> Plot(StopLoss,"Stop Loss",colorRed,1); //Plots the stoploss
>
> PlotShapes(IIf(Code ==
1,shapeUpArrow,shapeNone),colorDarkGreen,0,Low); //Plots arrow on
buy date
>
> PlotShapes(IIf(Code ==
2,shapeDownArrow,shapeNone),colorRed,0,High); //Plots arrow on sell
date
>
> PlotShapes(IIf(Code ==
1,shapeSmallCircle,shapeNone),colorBlack,0,AvgEntry,0); //Plots
actual buy price
>
> PlotShapes(IIf(Code ==
2,shapeSmallCircle,shapeNone),colorBlack,0,AvgExit,0); //Plots
actual sell price
>
> I use this chart to track progress of my trades. It will also
serve as a historical record of the trade events.
> I use this in conjuction with an indicator pane (code below).
>
> AvgEntry = Foreign("~"+Name(),"Open");
>
> StopLoss = Foreign("~"+Name(),"Low");
>
> AvgExit = Foreign("~"+Name(),"Close");
>
> Shares = Foreign("~"+Name(),"Volume");
>
> Code = Foreign("~"+Name(),"Interest");
>
> TrailStop = ATR(40) * 4;
>
> AccountEquity = Foreign("~PORT","HIGH",1);
>
> AccountCash = Foreign("~PORT","Volume",1);
>
> StopPoint = HighestSince(Code ==1,High,1);
>
> PyramidShares =(round(Shares*1.5/10)*10) - Shares;
>
> GraphXSpace = 10;
>
> Title = Name() +" " + FullName() +" LONG TRADE MANAGEMENT DATA PANE
Date " + Date()+"\n"+
>
> "Open = "+WriteVal(Open,1.2)+
>
> " High = "+WriteVal(High,1.2)+
>
> " Low = "+WriteVal(Low,1.2)+
>
> " Close ="+WriteVal(Close,1.2) +
>
> " Change ="+WriteVal(Close-Ref(Close,-1),6.2)+
>
> " Volume = "+WriteVal(Volume,6.0)+ "\n" +
>
> "Entry Price = " + WriteVal(AvgEntry,6.2) +
>
> " Exit Price = " + WriteVal(AvgExit,6.2) +
>
> " Shares Pur. = " +WriteVal(Shares,6.0)+
>
> " Stop Loss =" + WriteVal(StopLoss,6.2) +
>
> " ATR(40) =" + WriteVal(ATR(40),6.2) +
>
> " Proj. Stop Loss ="+ WriteVal(StopPoint-TrailStop,6.2)+"\n"+
>
> "\\c32Projected Position % Gain/Loss if stopped = \\c-1"+ WriteVal
(((StopLoss/AvgEntry)-1)*100,6.2)+
>
> " Portfolio Equity = "+ WriteVal(AccountEquity,6.0)+ "\n"+
>
> "Current Position % Gain/Loss = " + WriteVal(((Close/AvgEntry)-1)
*100,6.2)+
>
> " Portfolio Cash = "+ WriteVal(AccountCash,6.0)+
>
> "\nPortfolio % Gain/Loss = "+WriteVal(((AccountEquity/25000)-1)
*100,1.2)+
>
> " Current DD % = "+ WriteVal(((AccountEquity/Highest
(AccountEquity))-1)*100,1.2)+"\n"+
>
> "Pyramid Shares Allowed = " + WriteVal(PyramidShares,1.0)+" "+
>
> "Pyramid Conditions Met = "+WriteIf
((Shares*AvgEntry+PyramidShares*LongBasePrice)-
>
> ((Shares+PyramidShares)*
(StopPoint- TrailStop)) <= (AccountEquity *0.015),"\\c32YES\\c-
1","NO");
>
> This indicator is just a single, long Title statement. It provides
me with daily information I use to manage
> open trades.
>
> Hope this helps
>
> Regards,
>
> Tony
------------------------ 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
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|