Code issues  [SOLVED]

Questions about MultiCharts and user contributed studies.
pitrader
Posts: 26
Joined: 20 Apr 2022
Has thanked: 1 time
Been thanked: 1 time

Code issues

Postby pitrader » 22 Apr 2024

I am having trouble with some code that does not compile.
I am running MultiCharts64 Version 15.0 Release (Build 26125).
The indicator is a Smoothed Heikin Ashi PaintBar Study.
I cannot find one that is written for MC so I am trying to
compile one that was written for TS hoping that it is compatible.
Or if anyone knows of this indicator that is written for MC, unfortunately I cannot find it on this site.
The code is shown below. Any help would be appreciated.

Code: Select all

{ Heikin Ashi PaintBarStudy Heikin-Ashi technique for visualization of trend } inputs: PreSmooth(6), PreSmoothType(2), PostSmooth(2), PostSmoothType(3), GradientPeriod(25), Width(2), UpColor(RGB(0,255,125)),DnColor(RGB(255,125,0)); vars: haClose(0),haOpen(0),haHigh(0), haLow(0), smClose(0),smOpen(0),smHigh(0), smLow(0), lwClose(0),lwOpen(0),lwHigh(0), lwLow(0), colorb(0),floatingMax(0), floatingMin(0); // // // // // smOpen = _gaverage(O,PreSmooth,PreSmoothType); smClose = _gaverage(C,PreSmooth,PreSmoothType); smHigh = _gaverage(H,PreSmooth,PreSmoothType); smLow = _gaverage(L,PreSmooth,PreSmoothType); // // // // // if BarNumber = 1 then begin haOpen = smOpen; haClose = (smOpen+smClose+smHigh+smLow)/4; haHigh = MaxList( smHigh, haOpen, haClose); haLow = MinList( smLow, haOpen, haClose); end; if BarNumber > 1 then begin haClose = (smOpen+smClose+smHigh+smLow)/4; haOpen = (haOpen[1] + haClose[1])/2 ; haHigh = MaxList(smHigh, haOpen, haClose); haLow = MinList(smLow, haOpen, haClose); lwClose = _gaverage(haClose,PostSmooth,PostSmoothType); lwOpen = _gaverage(haOpen ,PostSmooth,PostSmoothType); lwHigh = _gaverage(haHigh ,PostSmooth,PostSmoothType); lwLow = _gaverage(haLow ,PostSmooth,PostSmoothType); value3 = (lwClose+lwOpen+lwHigh+lwLow)/4; floatingMax = value3; floatingMin = value3; for value1 = 0 to GradientPeriod-1 begin If floatingMax < value3[value1] then floatingMax = value3[value1]; If floatingMin > value3[value1] then floatingMin = value3[value1]; end; colorb = GradientColor(value3, floatingMin , floatingMax,DnColor ,UpColor); plot1(lwOpen ,"Open"); Setplotcolor(1,colorb); plot2(lwClose,"Close"); Setplotcolor(2,colorb); plot3(lwHigh ,"High"); Setplotcolor(3,colorb); plot4(lwLow ,"Low"); Setplotcolor(4,colorb); end;

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2223 times

Re: Code issues

Postby TJ » 22 Apr 2024

You should post a screen shot of the error message.

pitrader
Posts: 26
Joined: 20 Apr 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Code issues

Postby pitrader » 22 Apr 2024

Here is the screen shot you requested.
Attachments
screen shot.jpg
(147.07 KiB) Not downloaded yet

User avatar
ABC
Posts: 721
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 409 times
Contact:

Re: Code issues

Postby ABC » 23 Apr 2024

Hi pitrader,

check the code of the _gaverage function for any errors when you try to compile it.
For others to be able to say more you would have to include the function code and error messages you receive during the compilation of the function.

Regards,

ABC

pitrader
Posts: 26
Joined: 20 Apr 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Code issues

Postby pitrader » 23 Apr 2024

There is indeed a compiling error within the function. I have a screenshot of the code below with the error message.
Attachments
Function snapshot.jpg
(48.62 KiB) Not downloaded yet

User avatar
BB123
Posts: 69
Joined: 24 Nov 2023
Has thanked: 23 times
Been thanked: 12 times

Re: Code issues

Postby BB123 » 23 Apr 2024

So it seems like your code is calling a function _gaverage( ) .. Do you have that function in your functions folder? If you dont-- then its not going to compile..

pitrader
Posts: 26
Joined: 20 Apr 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Code issues

Postby pitrader » 23 Apr 2024

The function _gaverage apparently is what is giving me the problem because it will not compile due to an error on line 5 as shown in the snapshot above.

User avatar
ABC
Posts: 721
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 409 times
Contact:

Re: Code issues

Postby ABC » 24 Apr 2024

Hi pitrader,

try if removing the four "break;" statements in the function will let you compile the code. They are not required for the switch to work correctly and while including them works in TS it does not work in MC.

Regards,

ABC
There is indeed a compiling error within the function. I have a screenshot of the code below with the error message.

User avatar
BB123
Posts: 69
Joined: 24 Nov 2023
Has thanked: 23 times
Been thanked: 12 times

Re: Code issues

Postby BB123 » 24 Apr 2024

Also go back to the spot you found this code.. and see if they posted the _gaverage function.. Id be surprised if it wasn't somewhere else in the thread.. Only cause without the function-- its not going to compile for anyone.. So others would be asking for it too..

pitrader
Posts: 26
Joined: 20 Apr 2022
Has thanked: 1 time
Been thanked: 1 time

Re: Code issues  [SOLVED]

Postby pitrader » 24 Apr 2024

Thank you ABC it compiled just fine.


Return to “MultiCharts”