MultiInstrument

Author: Copyright � 2010, Vladimir Hlystov
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each barSeries array that contains close prices for each bar
0 Views
0 Downloads
0 Favorites
MultiInstrument
//+------------------------------------------------------------------+
//|                                              MultiInstrument.mq4 |
//|                               Copyright © 2010, Vladimir Hlystov |
//|                                         http://cmillion.narod.ru |
//|                         
âûâîëèò äðóãîé èíñòðóìåíò â òåêóùåå îêíî |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Vladimir Hlystov"
#property link      "http://cmillion.narod.ru"

#property indicator_chart_window
extern color color1 =Blue;
extern color color2 =Red;
extern string simbol="GCJ0";//"SILVER";

//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll(0,OBJ_TREND);
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int BarsWind=WindowFirstVisibleBar();
   int Bar = iHighest(NULL,0,MODE_HIGH,BarsWind,0);
   double High_Win = High[Bar];
   Bar = iLowest(NULL,0,MODE_LOW,BarsWind,0);
   double Low_Win  = Low[Bar];
   Bar = iHighest(simbol,0,MODE_HIGH,BarsWind,0);
   double H=iHigh(simbol,0,Bar);
   Bar = iLowest(simbol,0,MODE_LOW,BarsWind,0);
   double L=iLow(simbol,0,Bar);
   double OpenBar,CloseBar,LowBar,HighBar;
   string nameCandle;
   int Digit = MarketInfo(simbol,MODE_DIGITS);
   for(int i=BarsWind; i>=0; i--)
   {
      OpenBar = iOpen (simbol,0,i);
      CloseBar= iClose(simbol,0,i);
      LowBar  = iLow  (simbol,0,i);
      HighBar = iHigh (simbol,0,i);
      nameCandle=StringConcatenate(simbol," ",TimeToStr(Time[i],TIME_DATE|TIME_MINUTES));
      //," O",DoubleToStr(OpenBar,Digit)," H",DoubleToStr(HighBar,Digit)," L",
      //DoubleToStr(LowBar,Digit)," C",DoubleToStr(CloseBar,Digit));
      OpenBar =(OpenBar -L)/(H-L)*(High_Win-Low_Win)+Low_Win;
      CloseBar=(CloseBar-L)/(H-L)*(High_Win-Low_Win)+Low_Win;
      LowBar  =(LowBar  -L)/(H-L)*(High_Win-Low_Win)+Low_Win;
      HighBar =(HighBar -L)/(H-L)*(High_Win-Low_Win)+Low_Win;
      ObjectDelete(nameCandle);
      ObjectCreate(nameCandle, OBJ_TREND,0,Time[i],LowBar,Time[i],HighBar,0,0);
      ObjectSet   (nameCandle, OBJPROP_WIDTH, 1);
      if (OpenBar>CloseBar) ObjectSet   (nameCandle, OBJPROP_COLOR, color1);  
      else ObjectSet   (nameCandle, OBJPROP_COLOR, color2);  
      ObjectSet   (nameCandle, OBJPROP_RAY,   false);
      nameCandle=StringConcatenate(nameCandle," Body");
      ObjectDelete(nameCandle);
      ObjectCreate(nameCandle, OBJ_TREND,0,Time[i],OpenBar,Time[i],CloseBar,0,0);
      ObjectSet   (nameCandle, OBJPROP_WIDTH, 4);
      if (OpenBar>CloseBar) ObjectSet   (nameCandle, OBJPROP_COLOR, color1);  
      else ObjectSet   (nameCandle, OBJPROP_COLOR, color2);  
      ObjectSet   (nameCandle, OBJPROP_RAY,   false);
   }
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---