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

[amibroker] Coding An Indicator



PureBytes Links

Trading Reference Links



Hello All,

I am trying to convert this code to AB.

[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);

The code that I have come up with in AB is this, which executes without error:

_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", .5, 0, 10, .5 );

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

SyncShort = C;
SyncLong = C;

SyncShort = Ref( SyncShort, -1 ) * (1 - ShortWeight) + (ShortWeight * C);
SyncLong = Ref( SyncLong, -1 ) * (1 - LongWeight) + (LongWeight * C);

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

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

MultiWeight = 2/(MultiLeg  + 1);

TempSyncM = MultiOsc;

SyncMulti = (abs(TempSyncM) * (1 - MultiWeight)) + (MultiWeight * Ref( MultiOsc, -1 ));
/*TempSyncM = SyncMulti;*/

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

Plot( MultiHigh, "MH", ParamColor( "Multi Color", colorBlack ), ParamStyle("Style") );
Plot( MultiLow, "ML", ParamColor( "Multi Color", colorBlack ), ParamStyle("Style") );
_SECTION_END();

The difficulty is that while the indicator is similar, it is not displaying as it should.  Whereas the original plot is smooth and useful the one that results in AB is full of noise and useless.

I am sure that the issue is coming up in the array processing aspects of AB.  There is nothing wrong with AB, I just am not using the proper syntax to accomplish what needs to be done correctly.

I would attach screenshots of the indicator as it should be and as it is showing up in AB, but I do not know how to do that with these groups.

Please if someone could help me out I would appreciate it greatly.  I have converted the code to TradingSolutions and it works fine there.  If it would be of any use I could also post the formulas that I used for that.

Thanks in advance,

Michael


__._,_.___


**** 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

__,_._,___