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

[amibroker] Re: Help to convert code



PureBytes Links

Trading Reference Links



Thanks much - did the trick!!!

After shooting a few other bugs and nice-ifying a bit, here's my final version of the code.  It appears to work as intended now.

LongLeg = Param( "LongLeg", 35, 1, 200, 1 );
ShortLeg = Param( "ShortLeg", 5, 1, 100, 1 );
MultiLeg = Param( "MultiLeg", 10, 1, 200, 1 );
MultiW = Param( "MultiW", 1, 0, 2, .01 );
BClr = ParamColor( "Band Color", colorRed );

ShortWeight = 2 / ( ShortLeg + 1 );
LongWeight = 2 / ( LongLeg + 1 );

SyncShort[ 0 ] = Close[ 0 ];
SyncLong[ 0 ] = Close[ 0 ];

for( i = 1; i < BarCount; i++ )
    {
        SyncShort[ i ] = SyncShort[ i - 1 ] * (1 - ShortWeight) + (ShortWeight * Close[ i ]);
        SyncLong[ i ] = SyncLong[ i - 1 ] * (1 - LongWeight) + (LongWeight * Close[ i ]);
    };

MultiOsc = (100 * ( (SyncShort / SyncLong) - 1) );

Plot( MultiOsc, _DEFAULT_NAME(), ParamColor( "MO Color", colorBlue ), ParamStyle("Style") );

MultiWeight = 2/(MultiLeg + 1);

SyncMulti[ 0 ] = MultiOsc[ 0 ];

for( i = 1; i < BarCount; i++ )
    {
        SyncMulti[ i ] = (abs(SyncMulti[ i - 1 ]) * (1 - MultiWeight)) + (MultiWeight * MultiOsc[ i ]);
    };

MultiHigh = SyncMulti * MultiW;
MultiLow = -1 * MultiHigh;

Plot( MultiHigh, "MH", BClr, ParamStyle("Style") );
Plot( MultiLow, "ML", BClr, ParamStyle("Style") );



--- In amibroker@xxxxxxxxxxxxxxx, Tony Grimes <Tonez.Email@xxx> wrote:
>
> Try Changing:
>
> Ref( SyncShort, -1 ) to SyncShort[i-1]
> Ref( SyncLong, -1 ) to SyncLong[i-1]
>
> Should take care of your errors.
>
> On Wed, Jun 10, 2009 at 7:05 AM, lxman77 lxman77@xxx wrote:
>
> >
> >
> > Hello All,
> >
> > I am trying to convert the following code to AFL:
> >
> > [LegacyColorValue = true];
> >
> > Input: LongLeg(35), ShortLeg(5), MultiLeg(10), MultiW(1);
> > Var: SyncShort(0), SyncLong(0), SyncMulti(0);
> > Var: TempSyncS(0), TempSyncL(0), TempSyncM(0), MultiOsc(0);
> > Var: LongWeight(0), ShortWeight(0), MultiWeight(0), MultiHigh(0),
> > MultiLow(0);
> > var: DateLock(980116);
> >
> > ShortWeight = 2/(ShortLeg + 1);
> > LongWeight = 2/(LongLeg + 1);
> >
> > if TempSyncS = 0 then Begin
> > SyncShort = Close;
> > SyncLong = Close;
> > end
> > Else Begin
> > SyncShort = TempSyncS * (1 - ShortWeight) + (ShortWeight * Close);
> > SyncLong = TempSyncL * (1 - LongWeight) + (LongWeight * Close);
> > end;
> >
> > TempSyncS = SyncShort;
> > TempSyncL = SyncLong;
> >
> > MultiOsc = (100 * ( (SyncShort / SyncLong) - 1) );
> > plot1(MultiOsc, "MO");
> >
> > MultiWeight = 2/(MultiLeg + 1);
> >
> > if TempSyncM = 0 then
> > SyncMulti = MultiOsc
> > Else
> > SyncMulti = (AbsValue(TempSyncM) * (1 - MultiWeight)) + (MultiWeight *
> > MultiOsc);
> >
> > TempSyncM = SyncMulti;
> >
> > MultiHigh = SyncMulti * MultiW;
> > MultiLow = -1 * MultiHigh;
> >
> > Plot2(MultiHigh,"MH");
> > Plot3(MultiLow,"ML");
> >
> > Print("MO:", MultiOsc, " MH: ", MultiHigh, " ML: ", MultiLow);
> >
> > I am not sure what the original code is, Metatrader, EasyLanguage,
> > something like that. Anyway, this is what I have so far:
> >
> > _SECTION_BEGIN("Rubber Band Indicator");
> > SetChartOptions(0,0,chartGrid30|chartGrid70);
> > LongLeg = Param( "LongLeg", 35, 1, 200, 1 );
> > ShortLeg = Param( "ShortLeg", 5, 1, 200, 1 );
> > MultiLeg = Param( "MultiLeg", 10, 1, 200, 1 );
> > MultiW = Param( "MultiW", 1, 1, 200, 1 );
> >
> > ShortWeight = 2 / ( ShortLeg + 1 );
> > LongWeight = 2 / ( LongLeg + 1 );
> >
> > SyncShort[ 0 ] = Close[ 0 ];
> > SyncLong[ 0 ] = Close[ 0 ];
> >
> > for( i = 1; i < BarCount; i++ )
> > {
> > SyncShort[ i ] = Ref( SyncShort, -1 ) * (1 - ShortWeight) + (ShortWeight *
> > Close[ i ]);
> > SyncLong[ i ] = Ref( SyncLong, -1 ) * (1 - LongWeight) + (LongWeight *
> > Close[ i ]);
> > };
> >
> > MultiOsc = (100 * ( (SyncShort / SyncLong) - 1) );
> >
> > Plot( MultiOsc, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
> > ParamStyle("Style") );
> >
> > MultiWeight = 2/(MultiLeg + 1);
> >
> > TempSyncM = MultiOsc;
> >
> > SyncMulti = (abs(TempSyncM) * (1 - MultiWeight)) + (MultiWeight *
> > MultiOsc);
> > TempSyncM = SyncMulti;
> >
> > MultiHigh = SyncMulti * MultiW;
> > MultiLow = -1 * MultiHigh;
> >
> > Plot( MultiHigh, "MH", ParamColor( "Color", colorCycle ),
> > ParamStyle("Style") );
> > Plot( MultiLow, "ML", ParamColor( "Color", colorCycle ),
> > ParamStyle("Style") );
> > _SECTION_END();
> >
> > When I check it, I get the newbie error, Error 8 on lines 16 and 17. I do
> > not understand why, because I believe I am passing an element, and not an
> > array through the = operator.
> >
> > Help please. Thanks in advance.
> >
> >
> >
>


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___