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

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



PureBytes Links

Trading Reference Links

I agree with Herman, loops are probably required. Regular AFL executes
entire arrays as they are encountered in the code so these arrays computed
first can know nothing about arrays computed farther down in your code.
Sounds like you need to compute each bar of each array so you can change the
next bar of an array higher up in your code. For example, I was trying to
write some trade rules that depended on whether I was currently in a Buy or
Short trade. You canšt know this with array based formulas since the trade
conditions are executed first for ALL bars, then the Buy/Short arrays are
evaluated for ALL bars. With a loop you can evaluate the trade condition for
a given day, execute the Buy/Short for that bar and then test the conditions
for the next day knowing that youšre now on a buy or short.

You can also record on what bars trades were made so you can reference
values of previous bars in your loop as follows:
If (valueofarrayX[Entry[i-1]] AND ...)
Cond[i] = True;
...
Buy[i] = Cond[i];
Entry[i] = i; //remembers what bar the Buy was True

Hope that makes sense.

Terry
--

> 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
>  
> <http://us.ard.yahoo.com/SIG=1293cpfea/M=295196.4901138.6071305.3001176/D=grou
> ps/S=1705632198:HM/EXP=1095416590/A=2128215/R=0/SIG=10se96mf6/*http://companio
> n.yahoo.com>  
> 
> 
> 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
> <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
> *  
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/> .
> 


-- 
Terry



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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/