@ Disposition;
Could you please help me with converting the subsequent Tradestation code to MT4:
Inserted Code Choppy Market Index Function This function returns a value from 0 to 100. A lesser value denotes higher market indecisiveness (choppiness), whereas a higher value denotes a trending market. The single input is the number of pubs that we look back. Inputs: periodLength(Numeric); Vars: num(0),denom(1); if(periodLengthlt;gt;0) then begin denom = Highest(High,periodLength) -- Lowest(Low,periodLength); num = Close#91;periodLength-1Number93; -- Close; num = AbsValue(num); ChoppyMarketIndex = 0.0; if(denomlt;gt;0) then ChoppyMarketIndex = num/demon*100; end; Did you notice this function was made up of different purposes (building blocks)? We calculated the denom (denominator) by employing the Highest and Lowest functions. We calculated the num (numerator) by utilizing AbsValue (returns the absolute value of a number) functions. The only perplexing snippet of code in this function is probably:
Inserted Code Close#91;periodLength-1#93; -- Close you might be asking why we subtracted 1 in the periodLength. This is a superb question. Should you incorporate the closing price to some calculation, then the final price 30 days past would be referenced by Close[29]. Bear in mind that Close[1] is yesterday's closing price not today's. Since we need our index to flow between 0 and positive 100, we remove the negative sign of a down move in the market. We are only interested in distances that are absolute.
This is what I came up with, but not sure it is coded correctly:
Inserted Code dual ChoppyMarketIndex(int periodLength) double num = 0; double denom = 0 if(periodLength ! = 0) denom = High#91;iHighest(Symbol(),PERIOD_D1,MODE_HIGH,peri odLength,0)#93; - Low#91;iLowest(Symbol(),PERIOD_D1,MODE_LOW,periodL ength,0)Number93;; num = Close#91;periodLength-1#93; - Close#91;1#93;; num = MathAbs(num); //denom = MathAbs(denom); if(denom ! = 0) return(NormalizeDouble(num/denom*100,0));
Thanks Beforehand,