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

RE: [amibroker] Re: Why wont this code allow short trades???



PureBytes Links

Trading Reference Links

I didn't have time to get through all your code, but I did see that
problem. Instead of min to max, change your initialization parameter of
Lowsinceshort from 0 to 100000. It's never finding the first Low because
you are always comparing to 0. If you change to Max it will never find
subsequent lows.
--
Terry
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of orionsturtle
Sent: Friday, July 14, 2006 19:45
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Why wont this code allow short trades???

I have had the positions set to short since the first post. I have 
dicovered on thing though. I  changed Min to Max in this line and I 
generated 13 trades. Not really sure why yet but at least i can 
start to see some results that may give further clues to the fix. 
Thanks for the advice...

Lowsinceshort= Min( Low[ i ], Lowsinceshort); //Min to max generates 
13 trades???

OT




--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> 
wrote:
>
> > If I select that setting it tells me to consult the help files. 
I do 
> > not have any buy signals in this code.
> 
> If you do not have buys then obviously you should 
select "Positions: SHORT" only.
> Also you may run "SCAN" first to make sure if any signals are 
generated at all.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "orionsturtle" <orionsturtle@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Friday, July 14, 2006 10:09 PM
> Subject: [amibroker] Re: Why wont this code allow short trades???
> 
> 
> > If I select that setting it tells me to consult the help files. 
I do 
> > not have any buy signals in this code. I want to just make the 
> > shorts work. Here is the whole code if you care to take a look. 
I 
> > don't get a single trade in the report. I do have this working 
on 
> > the longs and I thought it would be fairly straight forward in 
> > switching it to work with shorts but I am missing something???
> > -------------------------------------------
> > Short = Cross( MA( C, 10 ), MA( C, 5 ) ); 
> > Cover = 0 ; 
> > 
> > FirstProfitTarget = .05; // profit 
> > SecondProfitTarget = .1; // in percent 
> > TrailingStop = .1; // also in percent 
> > Icing = .03 ;
> > 
> > priceatshort=0;
> > Lowsinceshort=0;
> > exit = 0; 
> > /*--------------------------------Short code---------------------
----
> > ---------*/
> > 
> > for( i = 0; i < BarCount; i++ ) 
> > { 
> > if( priceatshort == 0 AND Short[ i ] ) 
> >    { 
> >       priceatshort = ShortPrice[ i ]; 
> >    } 
> > if( priceatshort > 0 ) 
> >    { 
> >       Lowsinceshort= Min( Low[ i ], Lowsinceshort); 
> >       //PT1
> >      if( exit == 0 AND Low[ i ] <= ( 1 - FirstProfitTarget * 
0.01 ) 
> > * priceatshort) 
> >       { 
> >         exit = 1; 
> >   ShortPrice[i] = ( 1 - FirstProfitTarget * 0.01 ) * 
> > priceatshort;  
> >         Short[ i ] = sigScaleOut; 
> >       } 
> > 
> >      //PT2
> >      if( exit == 1 AND Low[ i ] <= ( 1 - SecondProfitTarget * 
> > 0.01 ) * priceatshort)  
> >       { 
> >         exit = 2; 
> >         ShortPrice[ i ] = ( 1 - SecondProfitTarget * 0.01 ) * 
> > priceatshort    ; 
> >   Short[ i ] = sigScaleOut; 
> >       } 
> > 
> >     //PT3 Icing
> >   if( exit == 2 AND Close[ i ] >= ( 1 + Icing * 0.01 ) * 
> > Lowsinceshort) 
> >       { 
> >        exit = 3; 
> >        CoverPrice[ i ] = ( 1 + Icing * 0.01 ) * Lowsinceshort ; 
> >       } 
> > 
> >      //Trail Stop Loss
> >      if( High[ i ] >= ( 1 + TrailingStop * 0.01 ) * 
Lowsinceshort ) 
> >       { 
> >         exit = 4;    
> >         CoverPrice[ i ] = ( 1 + TrailingStop * 0.01 ) * 
> > Lowsinceshort ; 
> >       } 
> > 
> >      //Reset for the next loop
> >      if( exit >= 3 ) 
> >       { 
> >         Short[ i ] = 0; 
> >         Cover[ i ] = exit + 1; // mark appropriate exit code 
> >         exit = 0; 
> >         priceatshort= 0; // reset price 
> >         Lowsinceshort = 0; 
> >       } 
> >    } 
> > } 
> > 
> > SetPositionSize( 50, spsPercentOfEquity ); /*Initial % of equity 
to 
> > be traded.*/
> > SetPositionSize( 50, spsPercentOfPosition * ( Short == 
> > sigScaleOut ) ); /* percentage to scale out when PT's are hit*/
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@> 
> > wrote:
> >>
> >> Go to AA settings and make sure that you have selected 
> > Postions: "Long and short"
> >> 
> >> Best regards,
> >> Tomasz Janeczko
> >> amibroker.com
> >> ----- Original Message ----- 
> >> From: "orionsturtle" <orionsturtle@>
> >> To: <amibroker@xxxxxxxxxxxxxxx>
> >> Sent: Friday, July 14, 2006 8:08 PM
> >> Subject: [amibroker] Why wont this code allow short trades???
> >> 
> >> 
> >> >I tried to make this help file code work on the short side, 
but 
> > it 
> >> > never even enters into a single trade. I did set the backtest 
> >> > positions to short. Could someone please just take a quick 
look 
> > at 
> >> > this small piece of code and maybe you can see why it wont 
trade 
> >> > short. I believe it is something simple but I can't seem to 
find 
> >> > it.Thank you.
> >> > ---------------------------
> >> > Short = Cross( MA( C, 10 ), MA( C, 5 ) ); 
> >> > Cover = 0 ; 
> >> > priceatshort=0;
> >> > Lowsinceshort=0;
> >> > exit = 0; 
> >> > 
> >> > for( i = 0; i < BarCount; i++ ) 
> >> > { 
> >> >   if( priceatshort == 0 AND Short[ i ] ) 
> >> >    { 
> >> >       priceatshort = ShortPrice[ i ]; 
> >> >    } 
> >> >   if( priceatshort > 0 ) 
> >> >    { 
> >> >       Lowsinceshort= Min( Low[ i ], Lowsinceshort); 
> >> >      //PT1
> >> >      if( exit == 0 AND Low[ i ] <= ( 1 - FirstProfitTarget * 
> > 0.01 ) 
> >> > * priceatshort) 
> >> >       { 
> >> >         exit = 1; 
> >> >   ShortPrice[i] = ( 1 - FirstProfitTarget * 0.01 ) * 
> >> > priceatshort;  
> >> >         Short[ i ] = sigScaleOut; 
> >> >       } 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 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 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 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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links