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

RE: [Metastockusers] Re: An Easy Solution to BarsSinceEntry, EntryPrice, PREV, etc.


  • To: <metastock@xxxxxxxxxxxxx>
  • Subject: RE: [Metastockusers] Re: An Easy Solution to BarsSinceEntry, EntryPrice, PREV, etc.
  • From: "Dave Nadeau" <dave_nadeau@xxxxxxxxx>
  • Date: Tue, 4 Sep 2001 20:15:41 -0700
  • In-reply-to: <9n37fn+bevn@xxxxxxxxxxx>

PureBytes Links

Trading Reference Links

Stephane,

Here's an example of how I think this .dll would work, and how it
could be used.

Let's say you want to code a breakout system, entering as the market
opens, using Donchian Channels.  (Price=HHV(last 10 bars) for example.
I'll stick to the long side only.)

Your trading signal would be TradSig:=Open>Ref(HHV(High,10),-1);
Let's say your system enters at the Open + 1 point on a Buy Stop
order.  You want to save this value for further and future
calcualtions.  But, if this market is trending upwards, the Open
TradSig will continue to be true: that is, the open will often keep
breaking the previous 10 bar highs.  Buy you don't want that original
entry value to be reset each time it does that.

Value1:=If(TradeSig,Open+1,0);  {This establishes the value that you
want to store}
Value2:=If(TradeSig,1,If(ExitLongSig,0,-99));  {Assumes you have an
Exit Long Signal defined}

EntryStopValue:= creative_catchy_name_for_dll_here(Value1,Value2);
{This returns the remembered value from the .dll--or if it's the first
Value2=1 meaning an entry after some previous bar's Value2=0 meaning
an exit, then it will take the Value1 that is passed and return it.}

You then have EntryStopValue for your use in the Metastock code in
calculations in later bars.  You can do the same with Value1:=Cum(1),
which will remember the bar number that you entered on.

EntryBarNum:=creative_catchy_name_for_dll_here(Value1,Value2);

Then later in Metastock code, you could say Cum(1)-EntryBarNum to get
the number of bars in a trade.

The logic of the .dll would work something like this:

If Value2 is =1 then
	If TradeFlag=True then begin
		Remember=Value1;
		TradeFlag=False;
End;

If Value2 is =0 then
		Remember=0;
		TradeFlag=True;

Return;

It's that simple!  The hard part is to get all the coding and syntax
correct for the Metastock .dll form in C++ or Delphi or PowerBasic.

================
Dave Nadeau
Fort Collins, CO



> -----Original Message-----
> From: Stephane Carrasset [mailto:nena@xxxxxxxxx]
> Sent: Tuesday, September 04, 2001 2:45 PM
> To: Metastockusers@xxxxxxxxxxxxxxx
> Subject: [Metastockusers] Re: An Easy Solution to BarsSinceEntry,
> EntryPrice, PREV, etc.
>
>
> Dave,
>
> Not clear for me and my poor english,
> could you give an example with a simple trading system ( mov
> crossoverà)
>
> stephane
> > and is competent in one of the programming languages it uses
> > (PowerBasic, Delphi, C++).  I would do this myself, but I'm not
> > competent in any of those languages...or rather, I'm not a
> programmer
> > at all really...
> >


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com