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

RE: [amibroker] Re: Nth Profitable Open



PureBytes Links

Trading Reference Links

This works a charm J Many thanks for pasting this: At the moment I’m out-posted in a country which doesn’t allow web access to Yahoo Groups, which means that I cannot browse the archives! Only can send/receive emails to the group via POP3 email. (and I only joined a couple of months ago)

 

Following is the code modified to fit my original requirement.

 

There is still one outstanding issue however! With this code, the trades on the first 10 days exit unconditionally as follows : trades on the first day exit after 1 day, trades on the second day exit after 2 days, and so on, until we’re on the 10th day, after which the system reacts as expected. Can’t understand why it’s doing that! Can anybody enlighten me?

 

Buy=1;

BuyPrice=Open;

 

for( i = 0; i < BarCount; i++ ) {

       if( entryBar == -1 AND Buy[ i ] ) {

              entryBar = i;

       }

       if(           entryBar != -1       //Buy Signal Exists

                     AND (

                           (i > entryBar+10 AND Open[ i ] > BuyPrice[ entryBar ]) //More than 10 bars and profit

                           OR

                           (i > entryBar+20 AND Open[ i ] < BuyPrice[ entryBar ]) //More than 20 bars and loss

                     )

              ) {   

              Sell[ i ] = 1;

              SellPrice[ i ] = Open[ i ];

              entryBar = -1;

       }

       else {

              Sell[ i ] = 0;

       }

};

 

Cheers,

Claude

 

 


From: Thomas Chan [mailto:tchan@xxxxxxxxxx]
Sent: Friday, March 25, 2005 08:21
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Nth Profitable Open

 

 

Here you go!

 

/* your original entry conditions - not need to modify */
Buy=H > O + Ref(H - L,-1);
BuyPrice=Max(O, Ref(H - L,-1) + TickSize);

entrybar = -1;

for( i = 0; i < BarCount; i++ )
{
if( entrybar == -1 AND Buy[ i ] )
{
entrybar = i;
}

if( entrybar != -1 AND i > entrybar + 1 AND Open[ i ] > Close[ entrybar ] )
{
Sell[ i ] = 1;
SellPrice[ i ] = Open[ i ];
entrybar = -1;
}
else
{
Sell[ i ] = 0;
}
}

 

Thomas

 


From: alex huynh [mailto:ahuynh7@xxxxxxxxx]
Sent: Thursday, March 24, 2005 5:16 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Re: Nth Profitable Open

share share share or place on the library.

 

happy bunny wunny :)

Owen Davies <owen5819@xxxxxxxxxxxx> wrote:

Claude Caruana wrote:

>My only comment about this is that exRemSpan would work fine on simple fixed
>nBar exits, but not necessarily on more complex conditions e.g.
>
>Exit after 5 bars if loss
>Exit after 20 bars if profit
>
Believe me, I know!

The solution requires looping, which I have yet to master. Six months or
so ago, Tomasz was kind enough to supply code for a long exit on the
first profitable open after a 1-bar delay. Unfortunately, a short time
later the machine I was using died, and the code remains trapped on the
old hard drive; I haven't had time to pull the drive and move it over to
the new box yet. You should be able to find the code in the archives. No
doubt it can be modified for a variable delay and short trades, if you wish.

Best of luck.

Owen Davies


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



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com




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







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 Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links