ThinkOrSwim function equivalent in MQL

ThinkOrSwim function equivalent in MQL

Manage alerts

Loading saved threads...

Reza Nasimi · External communityPost link
External question — Stack Overflow Stack Exchange Author: Reza Nasimi Original post: https://stackoverflow.com/questions/69042260 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have never heard of ThinkOrSwrim till yesterday when someone asked me to convert a ThinkOrSwim script to an MQL4 indicator. A part of the code is as follows: input length = 21; input price = close; input ATRs=1; input trueRangeAverageType = AverageType.WILDERS; def flag; def EMA = ExpAverage(close, length); def shift1 = ATRs * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); I want to ask you to kindly check and let me know if my understanding is correct. input ATRs=1; // This should be a multiplier for ATR, then I think I should give it a double //type for more flexible control. input trueRangeAverageType = AverageType.WILDERS; //As far as I understood, wilders is the same as SMMA in MQL. . def shift1 = ATRs * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); Here is the main piece of this code which I need your help with. My understanding is as follows ATRs ==>> Just a multiplier I think the rest of this line is calculating the ATR, right? If so, then I can see that I cannot simply convert this to iATR (in mql), because we are not able to choose MA Methode of ATR in mql4. Then I think first I have to put the "True Range" of each bar in an array and then use this array as a price source to get the averages. MQL4: for(int i = 0; i < rates_total; i++) { data[i] = iATR(_Symbol, TF_1, 1, i); } for(int i = 0; i < limit; i++) { ExtBuffer[i] = iMAOnArray(data, 0, Inplenght, 0, InpMAMethod, i); } If I'm in the right way yet, Then I think the iATR period has to be 1, to have the TrueRange of each bar and not the average of the TrueRanges. And then have the variable length (from thinkOrSwim inputs) as the period parameter for iMAOnArray. I would appreciate any help with it. Regards Edit: I forgot to ask you something, why should the programmer who wrote this thinkscript code call this variable shift1 ?
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Reza Nasimi Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/69042260 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have never heard of ThinkOrSwrim till yesterday when someone asked me to convert a ThinkOrSwim script to an MQL4 indicator. A part of the code is as follows: input length = 21; input price = close; input ATRs=1; input trueRangeAverageType = AverageType.WILDERS; def flag; def EMA = ExpAverage(close, length); def shift1 = ATRs * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); I want to ask you to kindly check and let me know if my understanding is correct. input ATRs=1; // This should be a multiplier for ATR, then I think I should give it a double //type for more flexible control. input trueRangeAverageType = AverageType.WILDERS; //As far as I understood, wilders is the same as SMMA in MQL. . def shift1 = ATRs * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); Here is the main piece of this code which I need your help with. My understanding is as follows ATRs ==>> Just a multiplier I think the rest of this line is calculating the ATR, right? If so, then I can see that I cannot simply convert this to iATR (in mql), because we are not able to choose MA Methode of ATR in mql4. Then I think first I have to put the "True Range" of each bar in an array and then use this array as a price source to get the averages. MQL4: for(int i = 0; i < rates_total; i++) { data[i] = iATR(_Symbol, TF_1, 1, i); } for(int i = 0; i < limit; i++) { ExtBuffer[i] = iMAOnArray(data, 0, Inplenght, 0, InpMAMethod, i); } If I'm in the right way yet, Then I think the iATR period has to be 1, to have the TrueRange of each bar and not the average of the TrueRanges. And then have the variable length (from thinkOrSwim inputs) as the period parameter for iMAOnArray. I would appreciate any help with it. Regards Edit: I forgot to ask you something, why should the programmer who wrote this thinkscript code call this variable shift1 ?

Cancel quote

Checking account access…