[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Current trade profit



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Hello,
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>Perhaps this code helps you. It is intended to be be used with zero trade 
delays: SetTradeDelays(0,0,0,0); I use prices instead of equities to allo me to 
separate Lond and Short trades.
<FONT face=Arial color=#0000ff 
size=2> 
Good 
luck,
<FONT face=Arial color=#0000ff 
size=2>Herman.
/<SPAN 
class=421233620-09092003>/ Your zero delay system here 
LE=<FONT 
size=2>ValueWhen<FONT 
color=#8b0000>(Buy<FONT 
size=2>,<FONT 
color=#ff0000>BuyPrice<FONT 
color=#8b0000>);LX=<FONT 
color=#0000ff>ValueWhen<FONT 
color=#8b0000>(Sell<FONT 
size=2>,<FONT 
color=#ff0000>SellPrice<FONT 
color=#8b0000>);LP=IIf<FONT 
size=2>(<FONT 
color=#ff0000>Sell<FONT 
color=#8b0000>,LX-LE,0<FONT 
size=2>);PLP=LP/LE*<FONT 
color=#ff00ff>100;<SPAN 
class=421233620-09092003> SE=<FONT 
color=#0000ff>ValueWhen<FONT 
color=#8b0000>(Short<FONT 
size=2>,<FONT 
color=#ff0000>ShortPrice<FONT 
color=#8b0000>);SX=<FONT 
color=#0000ff>ValueWhen<FONT 
color=#8b0000>(Cover<FONT 
size=2>,<FONT 
color=#ff0000>CoverPrice<FONT 
color=#8b0000>);SP=IIf<FONT 
size=2>(<FONT 
color=#ff0000>Cover<FONT 
color=#8b0000>,SE-SX,0<FONT 
size=2>);<FONT 
color=#8b0000>PSP=SP/SE*100<FONT 
color=#8b0000>; 

// Plot profit bars<FONT 
color=#0000ff>Plot(<FONT 
color=#0000ff>IIf(<FONT 
color=#0000ff>IsEmpty<FONT 
color=#8b0000>(PLP),0<FONT 
color=#8b0000>,PLP),"LongProfit"<FONT 
color=#8b0000>,colorGreen<FONT 
size=2>,2<FONT 
color=#8b0000>|<FONT 
color=#ff0000>styleOwnScale<FONT 
color=#8b0000>|styleArea<FONT 
size=2>|<FONT 
color=#ff0000>styleNoLabel<FONT 
color=#8b0000>,-20<FONT 
color=#8b0000>,10<FONT 
color=#8b0000>);Plot<FONT 
size=2>(0<FONT 
color=#8b0000>,"0"<FONT 
color=#8b0000>,colorGreen<FONT 
size=2>,1<FONT 
color=#8b0000>|<FONT 
color=#ff0000>styleOwnScale<FONT 
color=#8b0000>|styleNoLabel<FONT 
size=2>,-20<FONT 
color=#8b0000>,10<FONT 
color=#8b0000>);Plot<FONT 
size=2>(<FONT 
color=#0000ff>IIf<FONT 
color=#8b0000>(IsEmpty<FONT 
size=2>(PSP),0<FONT 
color=#8b0000>,PSP),"ShortProfit"<FONT 
color=#8b0000>,4<FONT 
color=#8b0000>,2<FONT 
color=#8b0000>|<FONT 
color=#ff0000>styleOwnScale<FONT 
color=#8b0000>|styleArea<FONT 
size=2>|<FONT 
color=#ff0000>styleNoLabel<FONT 
color=#8b0000>,-10<FONT 
color=#8b0000>,20<FONT 
color=#8b0000>);Plot<FONT 
size=2>(0<FONT 
color=#8b0000>,"0"<FONT 
color=#8b0000>,colorRed<FONT 
size=2>,1<FONT 
color=#8b0000>|<FONT 
color=#ff0000>styleOwnScale<FONT 
color=#8b0000>|styleNoLabel<FONT 
size=2>,-10<FONT 
color=#8b0000>,20<FONT 
color=#8b0000>);

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: emarco 
  [mailto:emarco@xxxxxxxxxxxxxxx]Sent: Tuesday, September 09, 2003 
  10:28 AMTo: amibroker@xxxxxxxxxxxxxxxCc: Anthony 
  Faragasso; walt; GrahamSubject: [amibroker] Current trade 
  profit
  
  HI
  I am trying to code the current profit of a trade in the 
  system tester. I want to plot current profit of a trade .
  Problems with my code:
  Does not reset to cero after each trade resumes.
  Thank for your help
   
  InLong = Flip( Buy, 
  Sell OR Short );
  InShort = Flip( Short, 
  Buy OR Cover );
  State = IIf( InLong, <FONT 
  color=#ff00ff>1, IIf( InShort, -<FONT 
  color=#ff00ff>1, 0 ));
  E = Equity();
  pos= IIf(state==<FONT 
  color=#ff00ff>1,1,<FONT 
  color=#0000ff>IIf(state==-1,<FONT 
  color=#ff00ff>0,Equity()<FONT 
  face="Courier New">==<FONT face="Courier New" 
  color=#ff00ff>0));
  Lastbar = Cum(<FONT 
  color=#ff00ff>1) == LastValue( <FONT 
  color=#0000ff>Cum(1) );<FONT 
  color=#0000ff>
  Plot<FONT 
  color=#000000>(IIf<FONT 
  color=#000000>(LastBar AND pos,(E-<FONT 
  color=#0000ff>ValueWhen<FONT 
  color=#000000>(Buy,E)),-(<FONT 
  color=#0000ff>ValueWhen(Short,E) 
  -E)),"Current Profit"<FONT 
  color=#000000>,9<FONT 
  color=#000000>,2<FONT 
  color=#000000>+4<FONT 
  color=#000000>);Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.