need help to translate a simple indior - Page 3
Page 3 of 733 FirstFirst 123
Results 21 to 23 of 323

Thread: need help to translate a simple indior

  1. #21
    @ 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,

  2. #22
    Bump

    Please help to verify the MT4 code is accurate.

  3. #23
    Hi TimeFreedom,

    If you want ch my attention, please pm me next time. I don't really spend my time combing to loe posts so you will want to point me to it. Seriously, I would not have seen your question if this thread did not click by accident. Looks like the destiny of it, so I will see what I could do. =-RRB-

    first thing is first. Is this likely to be applied to an indior or an EA?

    If it is likely to be in an indior then this line

    num = Close[periodLength-1] - Close[1];

    is going to provide you a problem...

    regards,
    Zen

    p.s., I'm going to PM you to guide you to my reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.