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

Re: [Metastockusers] Re: Storing price on opening a trade



PureBytes Links

Trading Reference Links

Steve


> Thanx Roy, sorry not 2 come back 2 U sooner but I've been trying 2
> get my head around the PREV command. Also, I think I may B losing my
> vision, how I couldn't C the Value When command in the manual when
> it's in alphabetical order is beyond me. Humble apologies!
>
> I'm assuming that the PREV comand applies itself to the nearest
> previous indicator or expression in the code so I think what your
> code does is the following:

PREV is the previous bars value of the current variable.

> If the previous occurrence of Trade <= 0 then
>    set Trade to the value of EnterLong
> else
>    if (close >= the most recent open * 1.2 when Trade = 0
>    or close >= the most recent open 0.9 when Trade = 0
>    or CloseLong =1 then
>       set Trade to -1
>    else
>       set Trade to +1

Sometimes it helps to think of PREV as Ref("current variable",-1)

You can't write it that way because Ref() is inappropriate for a variable that hasn't already been
defined for the current bar, but thinking of it that way might help. The variable has been processed
for the previous bar (unless this is the first bar of a chart) so PREV is a real value.

Thinking in terms of Ref() the timing for exit decision making expressions is a little different. To
keep the timing of events corrrect you must remember that PREV is not the current value of the
current variable, but the PREVious bars value of the current variable.

  if (close >= the most recent open * 1.2 when Ref(Trade,-1) = 0
 or close >= the most recent open 0.9 when Ref(Trade,-1) = 0

You're not interested in the last bar that Trade was reset, Trade=0, but the first bar that Trade
was set
ValueWhen(1,Ref(Trade,-1) = 0, C ). This is the bar AFTER Trade was last at zero, i.e. value when
previous bar was zero and current was not zero, ValueWhen(1,PREV=0, C ).

> Frankly, I'm still not sure what 'Trade < 0;' & 'Abs(Trade)*ValueWhen
> (1,Trade+Alert(Trade=0,2)=2,O); actually does as the Trade variable
> is being set in the previous command.

It just creates a visible plot of when the latch is set (and the value that it is effectively
remembering) and when it is reset. It's irrelevant to the function of the code but an aid to help
you see on your charts just what the latch is doing. ABS(Trade), for example, is true when the latch
is set, and stays true on the bar that the latch swings negative to signal a reset. The negative
swing can easily be picked up logically (by "Trade<0"), but the negative swing is just a visual pain
that ABS() converts back to a positive.

> That being said, I've used my own 'Enterlong' code & the indicator
> works a treat if the last Abs line is commented out, I'm just not
> completely sure how. ;~}

As I said above, that's there just for visual use. My "Trade Stop" series of indicators have several
visual plots to show just what is happening. The various plots are

Trade active and entry value plotted as a straight line
Profit target price plotted as a stright line.
Stoploss price polotted as a straight line.
Exit signal plotted as binary or price spike.

The last signal plotted is the only one used by code calling this indicator. Unnamed variables prior
to the last plot can't be called by other formulas, and neither do they have any use other than as a
visual plot when the indicator is dropped onto a chart. However, a visual plot is the most effective
diagnostic tool there is, because it allows you to litterally "see" what's happening inside the
indicator.

Regards

Roy




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/zMEolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Metastockusers/

<*> To unsubscribe from this group, send an email to:
    Metastockusers-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/