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

Re: [trading] RE: [amibroker] Re: ValueWhen(Ref()) question



PureBytes Links

Trading Reference Links

Thanks Tomasz,
I just assumed that the backtest engine would step through each Buy/Short & check the 
LastValue(ValueWhen(Buy,Close) of the preceding Buy/Short to check if a condition was true 
or not, in the same way it would check  for Applystops etc.
i.e
 Buy#1
Check if Stops hit
Check if  Close less then the Buy#1 Low
True..do something Else next;
Buy#2
Check if Stops hit
Check if  Close less then the Buy#2  Low
True..do something Else next;
Buy#3 etc etc

cheers


----- Original Message ----- 
From: "Tomasz Janeczko" <amibroker@xxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, September 16, 2004 10:41 PM
Subject: Re: [trading] RE: [amibroker] Re: ValueWhen(Ref()) question


> Hello,
>
> But you can access buy/sell/short/cover without any problems !
>
> There were several examples of such codes published on this list
> so I do not know were you are blocked on.
>
> There is also example in the User's Guide.
> I am copying it here for you to follow (it uses simple for loop and references buy and 
> price at last buy).
>
> /* a sample low-level implementation of Profit-target stop in AFL: */
> Buy = Cross( MACD(), Signal() );
>
> priceatbuy=0;
>
> for( i = 0; i < BarCount; i++ )
> {
>     if( priceatbuy == 0 && Buy[ i ] )
>     priceatbuy = BuyPrice[ i ];
>
>     if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
>     {
>       Sell[ i ] = 1;
>       SellPrice[ i ] = 1.1 * priceatbuy;
>       priceatbuy = 0;
>     }
>     else
>       Sell[ i ] = 0;
> }
>
>
> Anyway the support address is SUPPORT[AT]amibroker.com
> and this is the place to ask question if you have problems.
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "Beachie" <beachie41@xxxxxxxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, September 16, 2004 2:09 PM
> Subject: Re: [trading] RE: [amibroker] Re: ValueWhen(Ref()) question
>
>
>> Thanks Herman,
>> I was afraid that would be the answer. I must admit I'm very surprised that such a 
>> basic
>> function as referencing the buy/sell/short/cover array of the signal is not a standard
>> function. Backtesting a Stop & Reverse system   is impossible without resorting to
>> workarounds. eg entering a trade when the low/high of the original signal is taken out.
>> cheers
>>
>>
>> ----- Original Message ----- 
>> From: "Herman van den Bergen" <psytek@xxxxxxxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Thursday, September 16, 2004 9:47 PM
>> Subject: [trading] RE: [amibroker] Re: ValueWhen(Ref()) question
>>
>>
>>> Not quite sure what you are doing ...  buy I think you may have to use a
>>> loop...if you haven't tried loops it is worthwhile to read up on them, they
>>> give you access to the numerical values of each bar.
>>>
>>> best regards,
>>> herman
>>>
>>>
>>>
>>>
>>>  -----Original Message-----
>>>  From: Beachie [mailto:beachie41@xxxxxxxxxxx]
>>>  Sent: Thursday, September 16, 2004 6:23 AM
>>>  To: amibroker@xxxxxxxxxxxxxxx
>>>  Subject: [amibroker] Re: ValueWhen(Ref()) question
>>>
>>>
>>>  OK, I've tried my best, but I now presume that it cannot be done in
>>> Amibroker i.e
>>>  correctly reference the last trade in a backtest ( without resorting to
>>> some sort of
>>>  workaround). I've searched the archives, and despite trying to use
>>> relevant search
>>>  criteria I cannot find a solution.
>>>
>>>  Just to clarify, in case I've not made myself clear, I wish to SAR a trade
>>> if the original
>>>  entry criteria is voided. eg a close under the low of a Buy entry bar.  To
>>> do this ( under
>>>  a backtest) I need to be able to reference the H,L,C,O for that particular
>>> signal.
>>>  As previously posted, using something like "Sell = C <
>>> LastValue(ValueWhen(Buy, Low));"
>>>  only references the very last signal in a backtest, instead of stepping
>>> through each
>>>  signal as it is generated.
>>>  Anyone???
>>>
>>>  ----- Original Message -----
>>>  From: "Beachie" <beachie41@xxxxxxxxxxx>
>>>  To: <amibroker@xxxxxxxxxxxxxxx>
>>>
>>>
>>>  >
>>>  > Not out of the woods yet...
>>>  > The following code works, but only on the very last Buy signal when
>>> running a backtest.
>>>  > How is it possible to have it check each & every Buy signal in a
>>> backtest?
>>>  >
>>>  > Sell = C < LastValue(ValueWhen(Buy, Low));
>>>  >
>>>  > ----- Original Message -----
>>>  > From: "Beachie" <beachie41@xxxxxxxxxxx>
>>>  > To: amibroker@xxxxxxxxxxxxxxx
>>>  >
>>>  >> Thanks Herman!
>>>  >>
>>>  >> ----- Original Message -----
>>>  >> From: "Herman van den Bergen" <psytek@xxxxxxxx>
>>>  >>
>>>  >>
>>>  >>>
>>>  >>> LastValue(valuewhen(Buy,Close));
>>>  >>>
>>>  >>> herman
>>>  >>>  -----Original Message-----
>>>  >>>  From: Beachie [mailto:beachie41@xxxxxxxxxxx]
>>>  >>> >
>>>  >>>  Thanks Anthony....not what I was wanting to hear though :(
>>>  >>>  Do you (or anyone for that matter) have any ideas how I can retrieve
>>> the
>>>  >>> value of the
>>>  >>>  Close of the last Buy that was traded on?
>>>  >>>
>>>  >>>
>>>  >>>  ----- Original Message -----
>>>  >>>  From: "Anthony Faragasso" <ajf1111@xxxxxxxx>
>>>  >>>>
>>>  >>>
>>>  >>>  >I read it as this.....
>>>  >>>  >
>>>  >>>  > Give me the value of the close when the Buy was the day before....
>>>  >>>  > ----- Original Message -----
>>>  >>>  > From: "Beachie" <beachie41@xxxxxxxxxxx>
>>>  >>>  >
>>>  >>>  >
>>>  >>>  >> Just some clarification please for the following:
>>>  >>>  >> ValueWhen(Ref(Buy,-1),C)
>>>  >>>  >> Does this return the Close value of the last time a Buy was
>>> actually
>>>  >>>  >> executed, or does it
>>>  >>>  >> return just the last Buy signal, regardless whether there was
>>> still a
>>>  >>>  >> trade open before
>>>  >>>  >> that? In other words I wish to only reference the last Buy signal
>>> that
>>>  >>>  >> actually caused me
>>>  >>>  >> to enter a trade, despite subsequent Buy signal positives.
>>>
>>>
>>>
>>>  Check AmiBroker web page at:
>>>  http://www.amibroker.com/
>>>
>>>  Check group FAQ at:
>>> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>>>
>>>
>>>        Yahoo! Groups Sponsor
>>>              ADVERTISEMENT
>>>
>>>
>>>
>>>
>>>
>>> ----------------------------------------------------------------------------
>>> --
>>>  Yahoo! Groups Links
>>>
>>>    a.. To visit your group on the web, go to:
>>>    http://groups.yahoo.com/group/amibroker/
>>>
>>>    b.. To unsubscribe from this group, send an email to:
>>>    amibroker-unsubscribe@xxxxxxxxxxxxxxx
>>>
>>>    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>>>
>>>
>>>
>>> [Non-text portions of this message have been removed]
>>>
>>>
>>>
>>>
>>> Check AmiBroker web page at:
>>> http://www.amibroker.com/
>>>
>>> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>>> Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>> Check AmiBroker web page at:
>> http://www.amibroker.com/
>>
>> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> Yahoo! Groups Links
>
>
>
>
>
>
> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

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/