--+------------------------------------------------------------------+ --| Copyright © 2016, Gehtsoft USA LLC | --| http://fxcodebase.com | --| Support our efforts by donating | --| Paypal: https://goo.gl/9Rj74e | --+------------------------------------------------------------------+ --| Developed by : Mario Jemic | --| mario.jemic@gmail.com | --| BitCoin : 15VCJTLaz12Amr7adHSBtL9v8XomURo9RF | --+------------------------------------------------------------------+ function Init() indicator:name("BubbleSort"); indicator:description(""); indicator:requiredSource(core.Bar); indicator:type(core.Indicator); indicator.parameters:addGroup("Calculation"); indicator.parameters:addInteger("Input1", "1.", "", 1); indicator.parameters:addInteger("Input2", "2.", "", 56); indicator.parameters:addInteger("Input3", "3.", "", 100); indicator.parameters:addInteger("Input4", "4.", "", 66); indicator.parameters:addInteger("Input5", "5.", "", 0); end local InputData={}; function Prepare() source = instance.source; InputData[1]={}; InputData[1][1]=instance.parameters.Input1; InputData[1][2]=instance.parameters.Input2; InputData[1][3]=instance.parameters.Input3; InputData[1][4]=instance.parameters.Input4; InputData[1][5]=instance.parameters.Input5; local name = profile:id(); instance:name(name); Sorted= BubbleSort(InputData,1,1, 5 ); core.host:execute ("setStatus", Sorted[1][1].. " + " .. Sorted[1][2].. " + " .. Sorted[1][3].. " + " .. Sorted[1][4].. " + " .. Sorted[1][5]); end function BubbleSort(Data, index,raw, columns) local new=Data; local j,k, temp; local Sort=true; while Sort do Sort=false; for j = 2, columns , 1 do if new[index][j] < new[index][j-1] then Sort=true; for k = 1, raw, 1 do temp= new[k][j-1]; new[k][j-1]= new[k][j]; new[k][j]= temp; end end end end return new; end function Update(period, mode) end