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

[amibroker] Re: Detecting an Open Position with AFL?



PureBytes Links

Trading Reference Links


OK, here's what I've done.

I ran a bunch of Explorations to check the values of various 
functions and variables at every bar to see where they evaluated as 
true or false, if they were Boolean like Buy and Sell, and at what 
numerical value if they were non-Booleans like Open and Close.

So, I think I now know why my code was having problems, and what 
I'll need to do going forward to get my system to perform the way I 
want it to.

Regards,

--- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
> 
> Look into ApplyStop ... It'll handle most if not all of what you 
have 
> there.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "The Webmaster" 
> <maintainer_wiz@xxxx> wrote:
> > 
> > Here's my code that's supposed to exit at either my stop-loss 
price 
> > level or my profit target, whichever comes first.  However, it's 
> not 
> > working as I had planned.  Is this not the right approach to do 
> this?
> > 
> > Furthermore, I haven't added in the code yet, but for sells 
> > triggered by my sell-stop price level I not only want to sell 
one 
> > contract to offset the long position, but now I want to be short 
> one 
> > contract.  
> > 
> > Any ideas about what I'm doing wrong in my code?
> > If this can be done without using a loop please let me know as I 
> > haven't seen any good complex examples of buy/sell conditions 
which 
> > don't use loops.  Again, thanks.
> > 
> > //Profit Target and Stop Loss conditions to exit the trade
> > for( i = 0; i < BarCount; i++ )
> > {
> > if  ( Buy[i] == 1 && High[i] >= (1 + Profit_Target/100) * 
BuyPrice
> > [i])
> > {
> > 	Sell[i] = 1;
> > 	SellPrice[i] = (1 + Profit_Target/100) * BuyPrice[i];
> > }
> > if ( Buy[i] == 1 && Low[i] <= (1 - MAE_Threshold/100) * BuyPrice
[i])
> > {
> > 	Sell[i] = 1;
> > 	SellPrice = (1 - MAE_Threshold/100) * BuyPrice[i];
> > }
> > else
> > 	Sell[i] = 0;
> > }
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Christoper" <turkey@xxxx> 
wrote:
> > > 
> > > Look, I'm don't know what you're trying to do...
> > > 
> > > But in AB, just set your "Sell" conditions and then AB will 
make 
> > sure
> > > you're "in" before that Sell condition is triggered.  You 
don't 
> > really
> > > need to know when you're in.
> > > 
> > > Basically I don't know if such a function exists, and I don't 
see 
> > how
> > > that would be used.  Can you give us a little more of an idea 
of 
> > what
> > > you're trying to do?
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "The Webmaster"
> > > <maintainer_wiz@xxxx> wrote:
> > > > 
> > > > Is there a function to detect the open trading position of a 
> bar?
> > > > 
> > > > I'm trying to use a for loop to check certain conditions 
which 
> > would 
> > > > exit my long and go short.  However, it's not working 
because I 
> > > > think my coding assumptions about how this array programming 
> > thing 
> > > > works are incorrect.
> > > > 
> > > > If it's not already available, AB should add an AFL function 
or 
> > > > variable called Position which would return the open 
position 
> of 
> > the 
> > > > bar.  Just like in Trade Station's EasyLanguage.  AB has 
> > potential, 
> > > > but they should really look to Easy Language as a guide to 
> > improving 
> > > > AFL.





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/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/