Building an indicator for the scanner. [SOLVED]  [SOLVED]

Questions about MultiCharts and user contributed studies.
biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Building an indicator for the scanner. [SOLVED]

Postby biffhero » 29 Oct 2020

I'm not sure this is the right way to do this or not. I am looking at the scanner, and I want to add a filter column, so that the best ideas sort to the top.

I realize I can sort on multiple columns, by control+clicking on the additional columns. This works well, but I'm thinking that EasyLanguage is more flexible.

Here is what I have, so far. If this is completely insane, and there's this one amazing author that I am missing out on, I'm really interested in hearing it. As a matter of fact, I have a little voice telling me that I should be using three arrays and looping through each of them in one central loop.

Thanks,
Rob

Code: Select all

{ Build a script for scanner values. Basically, a script that takes different parameters and filters out the items I don't want. Higher values are better. I think a bitmask is in order here. Bits, from least significant to most significant. ----------+ ---------+| --------+|| -------+||| |||| -----+ |||| min vol ----|| |||| min prc ---+|| |||| max prc --+||| |||| 0000 0000 1 - one bit 2 - two bit 3 - three bit 4 - four bit 5 - five bit 6 - Min Volume 7 - Min price 8 - Max price The highest score anyone can get is 255. } Inputs: filterPrice(close), doMinVolFilter(1), doMinPriceFilter(1), doMaxPriceFilter(1), minVolume(1000000), minPrice(4), maxPrice(12); Variables: oneBitMultiplier(1), twoBitMultiplier(1), threeBitMultiplier(1), fourBitMultiplier(1), fiveBitMultiplier(1), maxPriceMultiplier(1), minPriceMultiplier(1), minVolMultiplier(1), finalValue(0), oneBit(0), twoBit(1), threeBit(2), fourBit(3), fiveBit(4), minVolBit(5), minPriceBit(6), maxPriceBit(7); if (LastBarOnChart) then begin // If the price is too high if (doMaxPriceFilter = 1) then begin if (filterPrice >= maxPrice) then maxPriceMultiplier = 0; end; // If the price is too low if (doMinPriceFilter = 1) then begin if (filterPrice <= minPrice) then minPriceMultiplier = 0; end; // If the volume is too low if (doMinVolFilter = 1) then begin if (dailyVolume <= minVolume) then minVolMultiplier = 0; end; finalValue = finalValue + (power(2, oneBit) * oneBitMultiplier); finalValue = finalValue + (power(2, twoBit) * twoBitMultiplier); finalValue = finalValue + (power(2, threeBit) * threeBitMultiplier); finalValue = finalValue + (power(2, fourBit) * fourBitMultiplier); finalValue = finalValue + (power(2, fiveBit) * fiveBitMultiplier); finalValue = finalValue + (power(2, minVolBit) * minVolMultiplier); finalValue = finalValue + (power(2, minPriceBit) * minPriceMultiplier); finalValue = finalValue + (power(2, maxPriceBit) * maxPriceMultiplier); plot1(finalValue); setPlotColor(1, Color_DimGrey); if (finalValue >= 255) then begin setPlotColor(1, Color_Green); end else if (finalValue >= 223) then begin setPlotColor(1, Color_LightSeaGreen); end else if (finalValue >= 191) then begin setPlotColor(1, Color_ForestGreen); end; end;
Last edited by biffhero on 08 Nov 2020, edited 1 time in total.

biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Re: Building an indicator for the scanner.

Postby biffhero » 30 Oct 2020

What is the correct way to set my number to no decimal places in the scanner? I don't think that clicking in the UI is the right way, as it is so painful to have to go and get some clicking to be accurate.

I found this way, but I don't think it is the best way. Is this the right way?

Code: Select all

fvStr = leftStr(numToStr(finalValue, 0), 3); plot1(fvStr);
Thank you,
Rob

biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Re: Building an indicator for the scanner.

Postby biffhero » 08 Nov 2020

I believe the correct way is as follows:

Code: Select all

finalValue = round(finalValue, 4);

biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Re: Building an indicator for the scanner. [SOLVED]  [SOLVED]

Postby biffhero » 08 Nov 2020

Here is where I am now, and I'm going to mark this "solved".

Code: Select all

{ Build a script for scanner values. Basically, a script that takes different parameters and filters out the items I don't want. Higher values are better. I think a bitmask is in order here. Bits, from least significant to most significant. ----------+ ---------+| --------+|| -------+||| |||| -----+ |||| min vol ----|| |||| min prc ---+|| |||| max prc --+||| |||| 0000 0000 1 - one bit 2 - two bit 3 - three bit 4 - four bit 5 - Min Ma bit 6 - Min Volume 7 - Min price 8 - Max price The highest score anyone can get is 255. I am going to divide the final score by 255 so that we can get a number between 0 and 1. TODO : Generate maxValue from a length of an array. Currently maxValue is hardcoded to 255, which is (power(2, 8) - 1). This will allow us to grow or shrink the array of evaluators at will, without having to keep maxValue up to date. } inputs: filterPrice(close), doMinVolFilter(1), doMinPriceFilter(1), doMaxPriceFilter(1), doMinMaFilter(1), minVolume(1000000), minPrice(4), maxPrice(12), minMaFilterLen(200), minMaFilterPrice(close); variables: oneBitMultiplier(1), twoBitMultiplier(1), threeBitMultiplier(1), fourBitMultiplier(1), minMaMultiplier(1), maxPriceMultiplier(1), minPriceMultiplier(1), minVolMultiplier(1), finalValue(0), oneBit(0), twoBit(1), threeBit(2), fourBit(3), minMaBit(4), minVolBit(5), minPriceBit(6), maxPriceBit(7), maxValue(255), j(0), minMaFilterVar0(0); arrays: indexNames[6](""), indexValues[6](0); finalValue = 0; // If the price is too high if (doMaxPriceFilter = 1) then begin if (filterPrice >= maxPrice) then maxPriceMultiplier = 0; end; // If the price is too low if (doMinPriceFilter = 1) then begin if (filterPrice <= minPrice) then minPriceMultiplier = 0; end; // If the volume is too low if (doMinVolFilter = 1) then begin if (dailyVolume <= minVolume) then minVolMultiplier = 0; end; // If the price is below the 200 EMA // maFilterVar0 = AverageFC( minMaFilterPrice, minMaFilterLen) ; if (doMinMaFilter = 1) then begin minMaFilterVar0 = XAverage( minMaFilterPrice, minMaFilterLen ) ; if (close < minMaFilterVar0) then minMaMultiplier = 0; end; finalValue = finalValue + (power(2, oneBit) * oneBitMultiplier); finalValue = finalValue + (power(2, twoBit) * twoBitMultiplier); finalValue = finalValue + (power(2, threeBit) * threeBitMultiplier); finalValue = finalValue + (power(2, fourBit) * fourBitMultiplier); finalValue = finalValue + (power(2, minMaBit) * minMaMultiplier); finalValue = finalValue + (power(2, minVolBit) * minVolMultiplier); finalValue = finalValue + (power(2, minPriceBit) * minPriceMultiplier); finalValue = finalValue + (power(2, maxPriceBit) * maxPriceMultiplier); indexNames[0] = "$TICK"; indexValues[0] = 255; indexNames[1] = "$VIX.X"; indexValues[1] = 254; indexNames[2] = "$ADD"; indexValues[2] = 253; indexNames[3] = "$PCVA"; indexValues[3] = 252; indexNames[4] = "$VOLSPD"; indexValues[4] = 251; indexNames[5] = "$TRIN"; indexValues[5] = 250; indexNames[6] = "SPY"; indexValues[6] = 249; for j = 0 to array_getmaxindex(indexNames) begin if (symbol = (indexNames[j])) then finalValue = indexValues[j]; end; // TODO : hardcoding '8' here is suboptimal. // 1. Use a list / array. // 2. Get the length of that array. // finalValue = finalValue / ((power(2, 8) - 1)); finalValue = finalValue / maxValue; finalValue = round(finalValue, 4); plot1(finalValue); value1 = (gradientcolor(finalValue, 0, 1, red, green)); setPlotColor(1, value1);


Return to “MultiCharts”