PureBytes Links
Trading Reference Links
|
Steve,
Thanks for your efforts. I see what you did, but I am not sure I
know enough to understand whether gets me where I need to go.
However, by initially setting "Trend" equal to "EWOsc", I don't think
that is it. "Trend" should only have one of three values: 0, 1 or -
1, depending on whether the trend is none, up or down.
I know I am sailing into rough territory, but I didn't know how to
get AFL to handle a case where I needed my variable to have an
initial value before it got used.
Dave
--- In amibroker@xxxx, Steve Wiser <slwiserr@xxxx> wrote:
> Dave:
>
> I took a look at your code and found a few things that I would do
> differently. But there are couple of items that I just don't
understand
> and I highlighted those below it your code area. What I did was
delete the
> parts that I did not understand and made the other stuff work.
Here is the
> code that I changed yours into with liberties. Note I removed the
spaces
> between the function and its "( i )" part at several locations. I
also
> removed the open and closed parenthesis for the IF functions. You
can add
> back in the parts that I took out to make your indicator do what
you
> wanted. I also added an initialization for the "trend" to make
this an
> array. The "trend" items inside the if functions were made arrays
instead
> of constants.
>
> I was just playing with your code mostly hoping that this would
help you
> finish it.
>
> Steve
>
> _________________________________
> EnableScript("VBScript");
>
> EWAP=(high + low)/2;
> EWOsc=( ma( EWAP, 5 ) - ma( EWAP, 35 ));
> length=80;
> trigger=0.70;
> EWOscpeak=hhv( EWOsc, length );
> EWOsctrough=llv( EWOsc, length );
>
>
> <%
>
> EWOsc = AFL("EWOsc")
> EWOscpeak = AFL("EWOscpeak")
> EWOsctrough = AFL("EWOsctrough")
> length = AFL("length")
> trigger = AFL("trigger")
> Trend = EWOsc // this was added..
>
> ' this variable specifies the trend determined by EWOsc
> Trend( 0 ) = 0
> ' line 10
> ' iterate along the array
> for i = 0 to UBound( EWOsc )
>
> ' Set initial Trend at zero and look for up trend
> if EWOsc( i ) = EWOscpeak( i ) AND Trend(i) = 0 then
> Trend( i ) = 1
> end if
>
> ' Set initial Trend at zero and look for down trend
> if EWOsc( i ) = EWOsctrough( i ) AND Trend(i) = 0 then '
line 20
> Trend( i ) = -1
> end if
>
> ' Look for change from downtrend to uptrend
> if EWOsctrough( i ) < 0 AND Trend(i) = -1 AND EWOsc( i ) >
> -1 then // note one item left out here
> Trend( i ) = 1
> end if
>
> ' Look for change from uptrend to downtrend line 30
> if EWOscpeak( i ) > 0 AND Trend(i) = 1 AND EWOsc( i ) <
> -1 then // note one item left out here
> Trend( i ) = 1
> end if
>
> next
>
> AFL("Trend") = Trend
>
> %>
>
> graph1=Trend;
> title=name() + " Trend" + writeval( graph1 );
> ______________________________________
>
> At 04:04 PM 6/27/01 -0400, you wrote:
> >Dear Tomasz,
> >
> >I am trying my first attempt at using scripting and felt I needed
to
> >because of my need to iterate through this array. Can you
determine why
> >this is causing me VBScript error messages? I know scripting is
slower but
> >unless you tell me otherwise, I don't think what I want to do is
allowed in
> >current version of AFL.
> >
> >Thanks,
> >
> >Dave Beaudoin
> >
> >***********************
> >
> >EnableScript("VBScript");
> >
> >EWAP=(high + low)/2;
> >EWOsc=( ma( EWAP, 5 ) - ma( EWAP, 35 ));
> >length=80;
> >trigger=0.70;
> >EWOscpeak=hhv( EWOsc, length );
> >EWOsctrough=llv( EWOsc, length );
> >
> >
> ><%
> >
> >EWOsc = AFL("EWOsc")
> >EWOscpeak = AFL("EWOscpeak")
> >EWOsctrough = AFL("EWOsctrough")
> >length = AFL("length")
> >trigger = AFL("trigger")
> >
> >' this variable specifies the trend determined by EWOsc
> >Trend ( 0 ) = 0
> >
> >' iterate along the array
> >for i = 0 to UBound( EWOsc )
> >
> >' Set initial Trend at zero and look for up trend
> >if( EWOsc( i ) = EWOscpeak ( i ) ) AND Trend=0 then
> >Trend( i ) = 1
> >end if
> >
> >' Set initial Trend at zero and look for down trend
> >if( EWOsc ( i ) = EWOsctrough ( i ) ) AND Trend=0 then
> >Trend( i ) = -1
> >end if
> >
> >' Look for change from downtrend to uptrend
> >if( EWOsctrough ( i ) < 0 ) AND Trend=-1 AND (EWOsc ( i ) > -1 *
trigger *
> >EWOsctrough ( i ) ) then
> >Trend( i ) = 1
> >end if
> >
> >' Look for change from uptrend to downtrend
> >if( EWOscpeak ( i ) > 0 ) AND Trend=1 AND (EWOsc ( i ) < -1 *
trigger *
> >EWOscpeak ( i ) ) then
> >Trend( i ) = 1
> >end if
> >
> >next
> >
> >AFL("Trend") = Trend
> >
> >%>
> >
> >graph1=Trend;
> >title=name() + " Trend" + writeval( graph1 );
|