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

[amibroker] Help to convert code



PureBytes Links

Trading Reference Links

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/

Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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

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