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

RE: [amibroker] Creating an artifical security.



PureBytes Links

Trading Reference Links




I'd 
like to add my thanks to Graham and TJ.
<FONT face=Arial color=#0000ff 
size=2> 
This 
is great stuff and I had been wondering how to do something like this for a long 
time!
<FONT face=Arial color=#0000ff 
size=2> 
Thanks 
also to Bll for bringing this up!!
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>d

  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: Tomasz Janeczko 
  [mailto:amibroker@xxxxxx] Sent: Wednesday, February 05, 2003 3:45 
  AMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] 
  Creating an artifical security.
  Graham,
   
  By the way DateNum()==LastValue(DateNum())
  works good for EOD only databases.
   
  To make it work for all databases (including intraday) you 
  would either use
  Cum(1) == LastValue( Cum(1) )
   
  or (in newer versions):
  DateTime() == LastValue(DateTime())
   
  or 
  BarIndex() == LastValue(BarIndex()) 
  Best regards,Tomasz Janeczkoamibroker.com
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    <A title=gkavanag@xxxxxxxxxxxxxx 
    href="">Graham 
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Sent: Wednesday, February 05, 2003 9:30 
    AM
    Subject: RE: [amibroker] Creating an 
    artifical security.
    
    
    <SPAN lang=EN-AU 
    >Thanks for the compliment Tomasz
    <SPAN lang=EN-AU 
    >Have been thinking about this one myself today and 
    considered it unnecessary to produce the composite unless needed for some 
    reason. I have simplified the code a bit, and then made more complex with 
    adding the trading tick and the available range of modifying the last price 
    values <SPAN lang=EN-AU 
    >J
    <SPAN lang=EN-AU 
    > 
    <SPAN 
    lang=EN-AU 
    >//allow 
    for minimum trading ticks
    <SPAN 
    lang=EN-AU 
    >tick = 
    <SPAN lang=EN-AU 
    >0.5<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >;
    <SPAN 
    lang=EN-AU 
    > 
    <SPAN 
    lang=EN-AU 
    >xo = 
    <SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >O<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >do = 
    <SPAN lang=EN-AU 
    >round<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(xo*<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >0.2<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >O<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    > = 
    <SPAN lang=EN-AU 
    >IIf<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()==<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Param<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"O"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,xo,xo-do,xo+do,tick),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Ref<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >O<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >1<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >));
    <SPAN 
    lang=EN-AU 
    >xh = 
    <SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >H<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >dh = 
    <SPAN lang=EN-AU 
    >round<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(xh*<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >0.2<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >H<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    > = 
    <SPAN lang=EN-AU 
    >IIf<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()==<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Param<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"H"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,xh,xh-dh,xh+dh,tick),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Ref<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >H<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >1<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >));
    <SPAN 
    lang=EN-AU 
    >xl= 
    <SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >L<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >dl = 
    <SPAN lang=EN-AU 
    >round<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(xl*<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >0.2<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >L<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    > = 
    <SPAN lang=EN-AU 
    >IIf<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()==<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Param<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"L"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,xl,xl-dl,xl+dl,tick),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Ref<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >L<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >1<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >));
    <SPAN 
    lang=EN-AU 
    >xc = 
    <SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >C<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >dc = 
    <SPAN lang=EN-AU 
    >round<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(xc*<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >0.2<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >C<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    > = 
    <SPAN lang=EN-AU 
    >IIf<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()==<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >LastValue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >DateNum<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >()),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Param<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"C"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,xc,xc-dc,xc+dc,tick),<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >Ref<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >C<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >1<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >));
    <SPAN 
    lang=EN-AU 
    > 
    <SPAN 
    lang=EN-AU 
    > 
    <SPAN 
    lang=EN-AU 
    >Plot<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >( 
    <SPAN lang=EN-AU 
    >EMA<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    > 
    (<SPAN lang=EN-AU 
    >C<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >10<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >),<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"EMA"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >colorBlue<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >styleLine<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >Plot<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >C<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"chart"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >colorBlack<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >styleCandle<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU 
    >Plot<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=blue size=2><SPAN lang=EN-AU 
    >StochD<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >(<FONT 
    face="Courier New" color=fuchsia size=2><SPAN lang=EN-AU 
    >14<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >),<FONT 
    face="Courier New" color=#cc4466 size=2><SPAN lang=EN-AU 
    >"stochD"<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >colorGreen<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >,<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >styleLine<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >+<FONT 
    face="Courier New" color=red size=2><SPAN lang=EN-AU 
    >styleOwnScale<FONT 
    face="Courier New" color=black size=2><SPAN lang=EN-AU 
    >);
    <SPAN 
    lang=EN-AU >Plot<FONT 
    color=black>(<FONT 
    color=blue>StochK<FONT 
    color=black>(<FONT 
    color=fuchsia>14<FONT 
    color=black>),<FONT 
    color=#cc4466><SPAN lang=EN-AU 
    >"stochK"<SPAN 
    lang=EN-AU >,<SPAN 
    lang=EN-AU >colorRed<SPAN 
    lang=EN-AU >,<SPAN 
    lang=EN-AU >styleLine<SPAN 
    lang=EN-AU >+<SPAN 
    lang=EN-AU >styleOwnScale<FONT 
    color=black>);
    <SPAN 
    lang=EN-AU > 
    <SPAN lang=EN-AU 
    >Cheers,
    <SPAN lang=EN-AU 
    >Graham
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    > 
    <SPAN 
    >-----Original Message-----From: Tomasz Janeczko 
    [mailto:amibroker@xxxxxx] Sent: Wednesday, 5 February 2003 3:51 
    PMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] Creating an 
    artifical security.
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Bill,
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Graham already presented the code and it is 
    nice.
    <SPAN lang=EN-AU 
    >But I started to wonder if it wouldn't be easier for 
    you to use 
    <SPAN lang=EN-AU 
    >Foreign/Ref function instead. I mean instead of 
    creating artificial ticker
    <SPAN lang=EN-AU 
    >and then using it somewhere else
    <SPAN lang=EN-AU 
    >use
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Dummy = Ref( Foreign("Original Security", "C" ), -1 
    );
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >in the *final* indicator you want to 
    create.
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >To change the last day data simply 
    use:
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Dummy = Ref( Foreign("Original Security", "C" ), -1 
    );
    <SPAN lang=EN-AU 
    >Dummy = IIF( Cum(1) == LastValue( Cum(1) ), 
    FINALDAYVALUE, Dummy );
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >(in most recent version 4.28 it can be also coded 
    using BarIndex() :)
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Dummy = IIF( BarIndex() == LastValue( BarIndex() ), 
    FINALDAYVALUE, Dummy );
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Best regards,
    <SPAN lang=EN-AU 
    >Tomasz Janeczko
    <SPAN lang=EN-AU 
    >amibroker.com
    <SPAN lang=EN-AU 
    >----- Original Message ----- 
    <SPAN lang=EN-AU 
    >From: <wbarack@xxxxxxxxx>
    <SPAN lang=EN-AU 
    >To: 
    <amibroker@xxxxxxxxxxxxxxx>
    <SPAN lang=EN-AU 
    >Sent: Tuesday, February 04, 2003 9:30 
    PM
    <SPAN lang=EN-AU 
    >Subject: [amibroker] Creating an artifical 
    security.
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >> Help! I want to be able to create a security 
    that has all data 
    <SPAN lang=EN-AU 
    >> shifted back in time by one day and then be 
    able to put in my best 
    <SPAN lang=EN-AU 
    >> guess for the final day's 
    data.
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Shifting can be done, I think, using the ref 
    function.
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Dummy = ref(original 
    security,-1)
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> But how can I plug in the final days data. I 
    can't quite figure that 
    <SPAN lang=EN-AU 
    >> one out. Any great ideas out 
    there?
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Bill
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Post AmiQuote-related messages ONLY to: 
    amiquote@xxxxxxxxxxxxxxx 
    <SPAN lang=EN-AU 
    >> (Web page: 
    http://groups.yahoo.com/group/amiquote/messages/)
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Check group FAQ at: 
    http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> Your use of Yahoo! Groups is subject to 
    http://docs.yahoo.com/info/terms/ 
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    >> 
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Post AmiQuote-related messages ONLY to: 
    amiquote@xxxxxxxxxxxxxxx 
    <SPAN lang=EN-AU 
    >(Web page: 
    http://groups.yahoo.com/group/amiquote/messages/)
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Check group FAQ at: 
    http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    
    <SPAN lang=EN-AU 
    > 
    <SPAN lang=EN-AU 
    >Your use of Yahoo! Groups is subject to 
    http://docs.yahoo.com/info/terms/ 
    <SPAN lang=EN-AU 
    > 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. 
    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









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.