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

Re: [amibroker] Re: Identify bar for actual Buy



PureBytes Links

Trading Reference Links

Hello,

By default you are operating on ARRAYS not on single values.

A must-read for everyone starting out:
http://www.amibroker.com/guide/h_understandafl.html

In short: RECURSIVE calculations need a FOR loop and [] operator
http://www.amibroker.com/guide/keyword/for.html

"For" loop and array subscript operator [] gives you acces
to INDIVIDUAL values.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Graham Johnson" <grahamj@xxxxxxxxxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, January 27, 2008 8:00 AM
Subject: [amibroker] Re: Identify bar for actual Buy


> Hi
> 
> The bottom line with this is that I want to be able to set a stop and 
> have control over it.
> 
> After thinking it through, I decided that the first step was to set 
> the stop for the first Buy signal and keep it at the same value until 
> a Sell signal and then set it to 0 again.
> 
> Seemed like a great theory but the stop value is reset at each bar 
> and therefore does not maintain a constant value.  Maybe it is a 
> mindset thing - my professional experience was with procedural 
> languages and AFL taxes my thinking processes sometimes - maybe 
> something about teaching an old dog new tricks...
> 
> Anyway, the snippet of code for setting the stop is as follows
> 
> Buy = Ref(vaValidEntry,-1) AND Low <= Ref(vaLimitEntry, -1);
> BuyPrice = Min(Open, Ref(vaLimitEntry, -1));
> vaIStopVal = ATR(vISATRPer) * vISMult;
> vaInitStop = 0;
> vaInitStop = IIf(((Buy == 1) AND (Ref(vaInitStop, -1) == 0)) , 
> BuyPrice - (Ref(vaIStopVal, -1)), Ref(vaInitStop, -1));
> _TRACE(" | buy: " + Buy + " | stop: " + vaInitStop + " | PrevStop: " 
> + Ref(vaInitStop, -1));
> 
> Any ideas as to where I've gone wrong and why it is resetting the 
> value each bar, please.
> 
> Graham
> 
>> I'm sure that a solution for this has been on the forum, but - 
> after 
>> much searching......
>> 
>> Code is for a Long system that does not pyramid.
>> 
>> I am looking to manually code the disaster stop, so need to be able 
> to 
>> set the stop on the day that the trade is actually entered, and not 
>> have the water muddied by subsequent signals that are not taken 
> because 
>> the system does not pyramid.
>> 
>> I know that the ApplyStop function is available, but I need to 
> acquire 
>> the technique for controlling stops programatically.
>> 
>> Hopefully, this is clear.
>> 
>> Graham
>>
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> Yahoo! Groups Links
> 
> 
> 


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/