Forum on trading, automated trading systems and testing trading strategies
If you can't find what you need in the Codebase or the Market, then create a request in Freelance Service.
Hi
Try this example:
// Number of periods since last HIGH. //----------------------------------- int nMyPeriod = 300; // Your time period. double dHigh_Value = 0; // MAX HIGH value. // Array for storing the HIGH value of the BARS double aHigh_Value_Data[]; CopyHigh(Symbol(), Period(), 1, nMyPeriod, aHigh_Value_Data); // Indexnumber for the time that the HIGH value is updated. int nIndexNumber_For_High_Time = 0; for(int i = 0; i < nMyPeriod; i++) { // HIGH value is calculated for the first Time in the LOOP. if(dHigh_Value == 0 || i == 0) { dHigh_Value = aHigh_Value_Data[i]; // Update HIGH Value. nIndexNumber_For_High_Time = (nMyPeriod - i); // Update index time value (reverse the index value, LAST bar is 1). } // Check if NEW HIGH value is highter then MAX High value. if(aHigh_Value_Data[i] > dHigh_Value) { dHigh_Value = aHigh_Value_Data[i]; // Update HIGH Value. nIndexNumber_For_High_Time = (nMyPeriod - i); // Update index time value (reverse the index value, LAST bar is 1). } } // Ratio time value. double dMy_Time_Ratio_Value = 0; // Check if value is greater then 0. if(nMyPeriod > 0) { dMy_Time_Ratio_Value = ((nMyPeriod - nIndexNumber_For_High_Time) * 100) / nMyPeriod; } Alert("High Value is = ", dHigh_Value, " Ratio = ", dMy_Time_Ratio_Value);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How do you code the following formula:
[ (Number of Periods) - (Number of Periods Since Highest High)] * 100
(Number of Periods)
Any help would be sincerely appreciated.