General question about computational speed

Questions about MultiCharts and user contributed studies.
User avatar
joebone
Posts: 175
Joined: 05 Sep 2018
Has thanked: 53 times
Been thanked: 4 times

General question about computational speed

Postby joebone » 20 Dec 2022

Hello,
I am looking for a more experienced programmer in hopes to find a faster solution.

I am looking to trim off any fat on my signals to help them optimize faster. something that I use a lot of is the Pivot function. I linked it below for reference. This function is extremely useful but I am trying to increase the speed of my signal to cut down on optimization time.

I have been trying to think of a solution that doesn't loop back. Trying to think of a way to use calculations that could roll forward on the current bar rather than having to constantly loop backwards.

I feel like I am getting close but I haven't been able to figure it out yet. All I would need is a true false statement once the right side of the pivot is completed.

Any Ideas?

Code: Select all

inputs: PriceValue( numericseries ), Len( numericsimple ), LeftStrength( numericsimple ), RightStrength( numericsimple ), Instance( numericsimple ), HiLo( numericsimple ), oPivotPriceValue( numericref ), oPivotBar( numericref ) ; variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ), var4( false ), var5( false ) ; var3 = 0 ; var5 = false ; var1 = RightStrength ; while var1 < Len and var5 = false begin var0 = PriceValue[var1] ; var4 = true ; var2 = var1 + 1 ; while var4 = true and var2 - var1 <= LeftStrength begin condition1 = ( HiLo = 1 and var0 < PriceValue[var2] ) or ( HiLo = -1 and var0 > PriceValue[var2] ) ; if condition1 then var4 = false else var2 = var2 + 1 ; end ; var2 = var1 - 1 ; while var4 = true and var1 - var2 <= RightStrength begin condition1 = ( HiLo = 1 and var0 <= PriceValue[var2] ) or ( HiLo = -1 and var0 >= PriceValue[var2] ) ; if condition1 then var4 = false else var2 = var2 - 1 ; end ; if var4 = true then var3 = var3 + 1 ; if var3 = Instance then var5 = true else var1 = var1 + 1 ; end ; if var5 = true then begin oPivotPriceValue = var0 ; oPivotBar = var1 + ExecOffset ; Pivot = 1 ; end else begin oPivotPriceValue = -1 ; oPivotBar = -1 ; Pivot = -1 ; end ;

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

Re: General question about computational speed

Postby TJ » 21 Dec 2022


User avatar
joebone
Posts: 175
Joined: 05 Sep 2018
Has thanked: 53 times
Been thanked: 4 times

Re: General question about computational speed

Postby joebone » 21 Dec 2022

Thanks TJ, I will go in and do that to try and better understand the MC code here. Before I doubt its speed that makes perfect sense.


Return to “MultiCharts”