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

[amibroker] Re: AmiBroker under attack :-)



PureBytes Links

Trading Reference Links

This code (at least in my testing) goes short after the first 2k of
profit, then continues to close the short positions and reopen them
(still short) with each additional 2k of profit.

Could someone kindly provide a tweak to make the positions flip-flop
between short and long with each new 2k of profit?  (My efforts must
be missing the obvious!)


--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>
> Hello,
> 
> One of AmiBroker users brought this to my attention:
> 
> http://forum.tssupport.com/viewtopic.php?t=6058
> 
> Rarely I see so much nonsense posted about AmiBroker.
> 
> Below is the AFL that does what MC people were thinking is
"impossible" in AB:
> 
> 
> SetPositionSize( 10000, spsValue ); // dollar value of each position 
> 
> Buy = True; // just open long trade at very first bar of test 
> Sell = Short = Cover = False; // the rest done in custom backtester
code. 
> 
> SetOption("MaxOpenPositions", 2 ); 
> 
> SetOption("UseCustomBacktestProc", True ); 
> 
> if( Status("action") == actionPortfolio ) 
> { 
>   bo = GetBacktesterObject(); 
> 
>   bo.PreProcess(); // Initialize backtester 
> 
>   for(bar=0; bar < BarCount; bar++) 
>   { 
>    bo.ProcessTradeSignals( bar ); 
>    
>    totalprofit = 0; 
>    for( pos = bo.GetFirstOpenPos(); pos; pos = bo.GetNextOpenPos() ) 
>    { 
>     totalprofit += pos.GetProfit(); 
>    } 
> 
>    if( totalprofit > 2000 ) 
>    { 
>       for( pos = bo.GetFirstOpenPos(); pos;  ) 
>          { 
>           price = pos.GetPrice( bar + 1, "O" ); 
>           symb = pos.Symbol; 
> 
>          pos = bo.GetNextOpenPos(); 
>           
>          bo.ExitTrade( bar + 1, symb, price ); // exit long 
>           bo.EnterTrade( bar + 1, symb, False, price, 10000 ); //
enter short 
>        } 
>    } 
>   } 
>   bo.PostProcess(); // Finalize backtester 
> } 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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/