• Get $40 off VIP by signing up for a free account! Sign Up

Fibonacci Indicator From MQ4

555-26

New member
Hey everyone. Someone can rewrite the indicator code from mq4 to TOS. Very good at drawing channels.
Code:
*/
#property copyright "ATEI,Pupo,Dimanchik"
#property link      "[email protected]"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Green
#property indicator_color5 Green
#property indicator_color6 Green
#property indicator_color7 Green

extern string SeparatorVol = " Настройки индикатора VolProfit ";
extern int CountBarsForAverage = 89;
extern int PeriodShift = 0;
extern string SeparatorSAKS = " Настройки индикатора SAKSChanell";
extern bool AutoLevel = FALSE;
extern int EMAPeriod = 233;
extern int LevelR1 = 40;
extern int LevelR2 = 40;
extern int LevelR3 = 40;
extern int LevelS1 = 40;
extern int LevelS2 = 40;
extern int LevelS3 = 40;
double gd_132 = 40.0;
double gd_140 = 40.0;
double gd_148 = 40.0;
double gd_156 = 40.0;
double gd_164 = 40.0;
double gd_172 = 40.0;
double gda_180[];
double gda_184[];
double gda_188[];
double gda_192[];
double gda_196[];
double gda_200[];
double gda_204[];
int gi_208;
int gi_212;
int gi_216;
double gd_220 = 0.0;
double gd_228 = 0.0;
double gd_236 = 0.0;
string gsa_244[] = {"", "M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN1"};
int gia_248[] = {0, 1, 5, 15, 30, 60, 240, 1440, 10080, 43200};
int gi_252;
string gs_256;

int init() {
   gi_252 = gia_248[ArrayBsearch(gia_248, Period()) + PeriodShift];
   gs_256 = gsa_244[ArrayBsearch(gia_248, Period()) + PeriodShift];
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, gda_180);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, gda_184);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, gda_188);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, gda_192);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, gda_196);
   SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(5, gda_200);
   SetIndexStyle(6, DRAW_LINE);
   SetIndexBuffer(6, gda_204);
   IndicatorShortName(Symbol() + "(" + Period() + "): ");
   SetIndexLabel(0, "МА" + DoubleToStr(EMAPeriod, 0));
   SetIndexLabel(1, "R1 ");
   SetIndexLabel(2, "R2 ");
   SetIndexLabel(3, "R3 ");
   SetIndexLabel(4, "S1 ");
   SetIndexLabel(5, "S2 ");
   SetIndexLabel(6, "S3 ");
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_0 = IndicatorCounted();
   double ld_4 = Ask - Bid;
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0 -= 10;
   gi_212 = Bars - li_0;
   int li_12 = 6;
   int li_16 = 3;
   if (AutoLevel == FALSE) {
      for (gi_208 = 0; gi_208 < gi_212; gi_208++) {
         gda_180[gi_208] = iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_CLOSE, gi_208);
         gda_184[gi_208] = gda_180[gi_208] + NormalizeDouble(LevelR1 * Point, Digits);
         gda_188[gi_208] = gda_184[gi_208] + NormalizeDouble(LevelR2 * Point, Digits);
         gda_192[gi_208] = gda_188[gi_208] + NormalizeDouble(LevelR3 * Point, Digits);
         gda_196[gi_208] = gda_180[gi_208] - NormalizeDouble(LevelS1 * Point, Digits);
         gda_200[gi_208] = gda_196[gi_208] - NormalizeDouble(LevelS2 * Point, Digits);
         gda_204[gi_208] = gda_200[gi_208] - NormalizeDouble(LevelS3 * Point, Digits);
      }
   } else {
      for (gi_208 = 0; gi_208 < gi_212; gi_208++) {
         gd_220 = 0;
         gd_228 = 0;
         for (gi_216 = CountBarsForAverage; gi_216 > 0; gi_216--) {
            gd_220 += MathAbs(iHigh(Symbol(), gi_252, gi_216 + gi_208) - iLow(Symbol(), gi_252, gi_216 + gi_208));
            if (gd_228 < MathAbs(iHigh(Symbol(), gi_252, gi_216 + gi_208) - iLow(Symbol(), gi_252, gi_216 + gi_208))) gd_228 = MathAbs(iHigh(Symbol(), gi_252, gi_216 + gi_208) - iLow(Symbol(), gi_252, gi_216 + gi_208));
         }
         gd_236 = gd_220 / CountBarsForAverage;
         gd_132 = gd_236;
         gd_140 = gd_132;
         gd_148 = gd_132;
         gd_156 = gd_132;
         gd_164 = gd_132;
         gd_172 = gd_132;
         gda_180[gi_208] = NormalizeDouble(iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_CLOSE, gi_208), Digits);
         gda_184[gi_208] = NormalizeDouble(gda_180[gi_208] + gd_132, Digits);
         gda_188[gi_208] = gda_184[gi_208] + NormalizeDouble(gd_140, Digits);
         gda_192[gi_208] = gda_188[gi_208] + NormalizeDouble(gd_148, Digits);
         gda_196[gi_208] = gda_180[gi_208] - NormalizeDouble(gd_156, Digits);
         gda_200[gi_208] = gda_196[gi_208] - NormalizeDouble(gd_164, Digits);
         gda_204[gi_208] = gda_200[gi_208] - NormalizeDouble(gd_172, Digits);
      }
   }
   return (0);
}
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
337 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top