2014年8月26日火曜日

前日高値または安値をブレークしたら、任意の時間だけエントリー注文を出す、ブレークアウトEA

6月10日にブログに載せた前日高値または安値の上下に任意のpips数離した価格に買いまたは売りストップ注文を出すEA (http://expertloungeblog.blogspot.jp/2014/06/ea.html)、に任意の時間だけエントリー注文を出す条件を付けくわえたEAです。前回のEAは日替わり時間を起点に前日の高値と安値を計算して、その日1日中エントリー注文を出す仕様でしたが、今回はエントリー注文を出す時間を指定できる条件を加えました。例えば、パラメータのEntryMinutesを180にすると、9時から180分後の12時までエントリー注文を発注します。12時以降はエントリー注文を取消します。

あくまでMQL4学習のためのサンプルコードです。今回はこのEAがどの通貨ペアやインターバルに最適なのかなど銘柄の推奨になるような、バックテストや最適化の検証結果には触れません。

サンプルをベースにご自身の好きなように変更してみてください。

■エントリールール

新規買
M時からL分までの間、前日高値のNpips上に買いのストップ注文を発注
新規売
M時からL分までの間、前日安値のNpips下に売りのストップ注文を発注

■エグジットルール

決済売
新規買価格よりMpips下に損切りのストップ注文を、Npips上に利益確定の指値注文を発注。また日替わり時間にポジションが残っていれば全決済。
決済買
新規買価格よりMpips上に損切りのストップ注文を、Npips下に利益確定の指値注文を発注。また日替わり時間にポジションが残っていれば全決済。

■コード説明

input double Lots = 0.1;
input int Break = 50;
input int Stop = 300;
input int Profit = 300;
input int StartHour = 7;
input int StartTime = 0;
 

input int EntryStartHour = 9;
input int EntryStartTime = 0;
input int EntryMinutes = 60;


Lots - ロット数設定
Break – 前日の高値/安値計算後、その上下に加算/減算するピップ数で50は5pips
Stop - エントリー約定価格からの損切りpips数で300は30pips
Profit - エントリー約定価格からの利益確定pips数で300は30pips
StartHour – 前日の高値/安値の計算開始時間で7は7時
StartTime – 前日の高値/安値の計算開始時間で0は7時0分
EntryStartHour – エントリー注文の発注開始時間で9 は9時
EntryStartTime – エントリー注文の発注開始時間で0は9時0分
EntryMinutes - エントリー注文の発注開始時間からの分数で60は9時から60分後の10時、120は9時から120分後の11時

sl = MarketInfo(Symbol(), MODE_STOPLEVEL)*p;
ブローカーのストップ注文や指値注文の最低幅(ストップレベル)を確認

positionInfo(longPos, shortPos, pendOrders, openPrice);

買いポジション数、売りポジション数、未約定注文、約定価格を計算


if (timeToSeconds(TimeCurrent()) == (entrystartHourSec + entrystartTimeSec))
現在時間がエントリー開始時間であれば

startedTime = TimeCurrent();

変数に現在時間を格納する

if (timeToSeconds(TimeCurrent()) == (startHourSec + startTimeSec)){
現在時間が日替わり時間であれば(7時の場合には7時から7時1分までの間に)

count++;

ティック数をカウントする

if (longPos > 0 || shortPos > 0)
closePositions();

買いポジションまたは売りポジションがある場合全てのポジションを決済する

if (count == 1){

最初のティックのときに

lastHH = hh;
lastLL = ll;

前日高値と安値を変数に格納する

hh = 0.1;
ll = 9999.0;

本日の高値と安値の計算のために変数を初期値に戻す

if (longPos == 0 && shortPos == 0 && pendOrders == 0 && entryDone == false && entryOK(startedTime)){

買いポジション、売りポジション、未約定注文がない、本日まだエントリーがない、そして指定したエントリー時間内の場合

            if (lastHH > 1){
               lastHH = MathMax(lastHH+breakPoint, Ask + sl);
               longTicket = OrderSend(Symbol(), OP_BUYSTOP, Lots, lastHH , 0, 0, 0, "BBreak", MagicNumber,0,Green);
            }

前日高値とストップレベルを比較して高い方を買いのストップ注文価格にして、買いのストップ注文を発注する

            if (lastLL < 9998.0){
               lastLL = MathMin(lastLL-breakPoint, Bid - sl);
               shortTicket = OrderSend(Symbol(), OP_SELLSTOP, Lots, lastLL , 0, 0, 0, "SBreak", MagicNumber,0,Red);
            }    

前日安値とストップレベルを比較して安い方を売りのストップ注文価格にして、売りのストップ注文を発注する

if (entryOK(startedTime) == false)
指定したエントリー時間外の場合

cancelPendingOrders();
エントリー注文を取消す

if (longPos > 0){

買いのストップ注文が約定して買いポジションを持っている場合

cancelPendingOrders();

売りのストップ注文を取消す

stopPrice = openPrice - stopPoint;
profitPrice = openPrice + profitPoint;

エントリー価格からの損切りと利益確定注文価格の計算

ticketMod = OrderModify(longTicket, openPrice, stopPrice, profitPrice, 0, Blue);

買いポジションに対して、損切りと利益確定注文を発注

if (shortPos > 0){

売りのストップ注文が約定して売りポジションを持っている場合

cancelPendingOrders();

売りのストップ注文を取消す

stopPrice = openPrice + stopPoint;
profitPrice = openPrice - profitPoint;

エントリー価格からの損切りと利益確定注文価格の計算

ticketMod = OrderModify(shortTicket, openPrice, stopPrice, profitPrice, 0, Magenta);

売りポジションに対して、損切りと利益確定注文を発注

hh = MathMax(hh,High[0]);
ll = MathMin(ll,Low[0]);

本日の高値と安値を計算する
以下からはユーザー定義関数で、主に上のメインの計算で使用する
bool entryOK(datetime startedTime1){
   datetime tm = TimeCurrent();
   if (tm - startedTime1 >= 0){
      if (tm - startedTime1 >= EntryMinutes*60){
         return(false);
      }else
         return(true);
   }else{
      if ((tm + (86400 - startedTime1)) >= EntryMinutes*60){
         return(false);
      }else
         return(true);   
   }
}
現在時間がエントリー時間内であることを確認する関数


int timeToSeconds(datetime time){
   int tts = TimeHour(time)*60*60 + TimeMinute(time)*60;
   return(tts);
}

時間を分数に変える計算で次のbreakCalcTimeで使う


void positionInfo(int &longPos, int &shortPos, int &pendOrders, double &openPrice){
   int i;
   for( i=0; i<OrdersTotal(); i++)
   {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
     if(OrderType() == OP_BUY){
        longPos++;
        openPrice = OrderOpenPrice();
     }else
     if(OrderType() == OP_SELL){
        shortPos++;
        openPrice = OrderOpenPrice();
     }else
        pendOrders++;
   }
}

買いポジション数、売りポジション数、未約定注文、約定価格を計算してOnTick()内で使う


void cancelPendingOrders(){
   int i;
   bool ticketDel;
   for( i=OrdersTotal()-1;i>=0;i--){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
      ticketDel = false;
      if (OrderType() != OP_BUY && OrderType() != OP_SELL)
         ticketDel = OrderDelete( OrderTicket() );

   }
}

未約定注文を取消す関数でOnTick()内で使う


void closePositions(){
   int i;
   bool ticketClose;
   for( i=OrdersTotal()-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
      ticketClose = false;
      if (OrderType() == OP_BUY)
         ticketClose = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, Cyan);
      else
      if (OrderType() == OP_SELL)
         ticketClose = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, White);
   }
}

オープンポジションを決済する関数でOnTick()内で使う

■コード全体

input double Lots = 0.1;
input int Break = 50;
input int Stop = 300;
input int Profit = 300;
input int StartHour = 7;
input int StartTime = 0;
input int EntryStartHour = 9;
input int EntryStartTime = 0;
input int EntryMinutes = 60;
input int MagicNumber = 8888;

int startHourSec = StartHour*60*60, startTimeSec = StartTime*60, entrystartHourSec = EntryStartHour*60*60, entrystartTimeSec = EntryStartTime*60,longTicket, shortTicket, ticketMod;
double hh = 0.1, ll = 9999.0, lastHH = 0.1, lastLL = 9999.0, p = Point, breakPoint = Break*p, stopPoint = Stop*p, profitPoint = Profit*p, sl = 0;
static int count = 0;
bool entryDone = false;
datetime startedTime;

void OnTick()
  {
   int longPos, shortPos, pendOrders;
   double openPrice, stopPrice, profitPrice;
  
   sl = MarketInfo(Symbol(), MODE_STOPLEVEL)*p;
   positionInfo(longPos, shortPos, pendOrders, openPrice);
        
   if (timeToSeconds(TimeCurrent()) == (entrystartHourSec + entrystartTimeSec))
      startedTime = TimeCurrent();

   if (timeToSeconds(TimeCurrent()) == (startHourSec + startTimeSec)){
      count++;
      if (longPos > 0 || shortPos > 0)
         closePositions();
      if (count == 1){
         entryDone = False;
         lastHH = hh;
         lastLL = ll;
         hh = 0.1;
         ll = 9999.0;

      }
   }else{
      count = 0;
         if (longPos == 0 && shortPos == 0 && pendOrders == 0 && entryDone == false && entryOK(startedTime)){
            ticketMod = false;
            if (lastHH > 1){
               lastHH = MathMax(lastHH+breakPoint, Ask + sl);
               shortTicket = OrderSend(Symbol(), OP_SELLLIMIT, Lots, lastHH , 0, 0, 0, "BBreak", MagicNumber,0,Green);
            }
            if (lastLL < 9998.0){
               lastLL = MathMin(lastLL-breakPoint, Bid - sl);
               longTicket = OrderSend(Symbol(), OP_BUYLIMIT, Lots, lastLL , 0, 0, 0, "SBreak", MagicNumber,0,Red);
            }     
         }
         if (entryOK(startedTime) == false)
            cancelPendingOrders();
           
         if (longPos > 0){
            cancelPendingOrders();
            stopPrice = openPrice - stopPoint;
            profitPrice = openPrice + profitPoint;
            if (!ticketMod)
               ticketMod = OrderModify(longTicket, openPrice, stopPrice, profitPrice, 0, Blue);
            entryDone = true;
         }else
         if (shortPos > 0){
            cancelPendingOrders();
            stopPrice = openPrice + stopPoint;
            profitPrice = openPrice - profitPoint;
            if (!ticketMod)  
               ticketMod = OrderModify(shortTicket, openPrice, stopPrice, profitPrice, 0, Magenta);
            entryDone = true;
         }
   }
      hh = MathMax(hh,High[0]);
      ll = MathMin(ll,Low[0]); 

}
//+------------------------------------------------------------------+

bool entryOK(datetime startedTime1){
   datetime tm = TimeCurrent();
   if (tm - startedTime1 >= 0){
      if (tm - startedTime1 >= EntryMinutes*60){
         return(false);
      }else
         return(true);
   }else{
      if ((tm + (86400 - startedTime1)) >= EntryMinutes*60){
         return(false);
      }else
         return(true);   
   }
}

int timeToSeconds(datetime time){
   int tts = TimeHour(time)*60*60 + TimeMinute(time)*60;
   return(tts);
}

void positionInfo(int &longPos, int &shortPos, int &pendOrders, double &openPrice){
   int i;
   for( i=0; i<OrdersTotal(); i++)
   {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
     if(OrderType() == OP_BUY){
        longPos++;
        openPrice = OrderOpenPrice();
     }else
     if(OrderType() == OP_SELL){
        shortPos++;
        openPrice = OrderOpenPrice();
     }else
        pendOrders++;
   }
}

void cancelPendingOrders(){
   int i;
   bool ticketDel;
   for( i=OrdersTotal()-1;i>=0;i--){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
      ticketDel = false;
      if (OrderType() != OP_BUY && OrderType() != OP_SELL)
         ticketDel = OrderDelete( OrderTicket() );

   }
}

void closePositions(){
   int i;
   bool ticketClose;
   for( i=OrdersTotal()-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol() != Symbol() && OrderMagicNumber() != MagicNumber) continue;
      ticketClose = false;
      if (OrderType() == OP_BUY)
         ticketClose = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0, Cyan);
      else
      if (OrderType() == OP_SELL)
         ticketClose = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0, White);
   }
}

2014年8月7日木曜日

チャートの表示をスクリプトでカスタマイズ



チャート表示の初期設定は「ツール」→「オプション」→「チャート」設定から変更することができます。しかしここで変更できる設定は最低限の設定だけで、詳細な設定変更は、チャート作成後にチャート上を右クリックして表示されるメニューの「プロパティ」設定から変更する必要があります。またその「プロパティ」設定から変更した設定を次回以降開くチャートにも適用したい場合には、チャート作成後にチャート上を右クリックして表示されるメニューの「定型チャート」→「定型チャートとして保存」設定でテンプレートとして保存して、次回新規チャート作成後に「定型チャート」設定のテンプレートリストから、任意のテンプレートを選択する必要があります。

スクリプトを使えば、少しだけチャート表示設定の操作を速く行うことができます。スクリプトはチャート上で一回だけ実行され、実行後削除されるプログラムです。例えば今回ご紹介するチャート設定を変更するスクリプトをチャートに入れると、上の画像から下の画像のようにチャート設定を一回で、一瞬で変更することができます。




EAを自動運用するにあたり、チャートの足の種類などの設定のは全く関係ないですが、個人的にMT4のチャートの初期設定は見にくいと感じるので(特にグリッド線が邪魔です!!)、チャート設定の変更を行うことができるスクリプトを作ってみました。

コード説明

   ChartShowGridSet(false,0);
チャートのグリッド線を非表示にします。Trueにするとグリッド線を表示します。

   ChartShowAskLineSet(true,0);

Askの線を表示します。「ツール」→「オプション」→「チャート」設定から設定することもできます(初期設定では非表示です)。

   ChartAskColorSet(clrMagenta,0);
Askの線の色をclrMagentaに設定します。色定数は以下のページを参照ください。http://docs.mql4.com/constants/objectconstants/webcolors

   ChartModeSet(1,0);
チャートの足をローソク足に設定します。

   ChartUpColorSet(clrWhite,0);

陽線のヒゲと外枠の色をclrWhiteに設定します。

   ChartDownColorSet(clrWhite,0);

陰線のヒゲと外枠の色をclrWhiteに設定します。

   ChartLineColorSet(clrWhite,0);
同字線の色をclrWhiteに設定します。

   ChartBullColorSet(clrDodgerBlue,0);
陽線の実体の色をclrDodgerBlueに設定します。

   ChartBearColorSet(clrRed,0);
陰線の実体の色をclrRedに設定します。

   ChartShiftSet(true,0);

チャート右端と最新の足の間にスペースを作ります。

   ChartShiftSizeSet(10,0);

チャート右端と最新の足の間のスペースを、チャート幅全体の10パーセントで設置します。

   ChartShowOHLCSet(false,0);
チャート右上の始値、高値、安値、終値情報を非表示にします。

   ChartBackColorSet(clrMidnightBlue,0);
チャート背景色をclrMidnightBlueに設定します。


bool ChartShowGridSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_GRID,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャートのグリッド線の関数です。


bool ChartShowAskLineSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_ASK_LINE,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

Askの線の関数です。

bool ChartAskColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of Ask price line
   if(!ChartSetInteger(chart_ID,CHART_COLOR_ASK,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

Askの線の色の関数です。

    
bool ChartModeSet(const long value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_MODE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャートの足の関数です。


bool ChartUpColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of up bar, its shadow and border of body of a bullish candlestick
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_UP,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

陽線のヒゲと外枠の色の関数です。


bool ChartDownColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of down bar, its shadow and border of bearish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_DOWN,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

陰線のヒゲと外枠の色の関数です。

 
bool ChartLineColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set color of the chart line and Doji candlesticks
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_LINE,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

同字線の色の関数です。


bool ChartBullColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of bullish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CANDLE_BULL,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

陽線の実体の色の関数です。


bool ChartBearColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of bearish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CANDLE_BEAR,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

陰線の実体の色の関数です。


bool ChartShiftSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHIFT,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャート右端と最新の足の間にスペースを作る関数です。


 bool ChartShowOHLCSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_OHLC,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャート右上の始値、高値、安値、終値情報の関数です。


 bool ChartBackColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the chart background color
   if(!ChartSetInteger(chart_ID,CHART_COLOR_BACKGROUND,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャートの背景色の関数です。


bool ChartShiftSizeSet(const double value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetDouble(chart_ID,CHART_SHIFT_SIZE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

チャート右端と最新の足の間に作られたスペースを、チャート全体の幅のパーセンテージで設定する関数です。


コード全体

void OnStart()
  {
//---
   ChartShowGridSet(false,0);
   ChartShowAskLineSet(true,0);
   ChartAskColorSet(clrMagenta,0);
   ChartModeSet(1,0);
   ChartUpColorSet(clrWhite,0);
   ChartDownColorSet(clrWhite,0);
   ChartLineColorSet(clrWhite,0);
   ChartBullColorSet(clrDodgerBlue,0);
   ChartBearColorSet(clrRed,0);
   ChartShiftSet(true,0);
   ChartShiftSizeSet(10,0);
   ChartShowOHLCSet(false,0);
   ChartBackColorSet(clrMidnightBlue,0);
  }
//+------------------------------------------------------------------+

bool ChartShowGridSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_GRID,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

bool ChartShowAskLineSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_ASK_LINE,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartAskColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of Ask price line
   if(!ChartSetInteger(chart_ID,CHART_COLOR_ASK,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
    
bool ChartModeSet(const long value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_MODE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartUpColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of up bar, its shadow and border of body of a bullish candlestick
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_UP,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartDownColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of down bar, its shadow and border of bearish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_DOWN,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  } 
bool ChartLineColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set color of the chart line and Doji candlesticks
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CHART_LINE,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartBullColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of bullish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CANDLE_BULL,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartBearColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the color of bearish candlestick's body
   if(!ChartSetInteger(chart_ID,CHART_COLOR_CANDLE_BEAR,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartShiftSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHIFT,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
 bool ChartShowOHLCSet(const bool value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_SHOW_OHLC,0,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
 bool ChartBackColorSet(const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the chart background color
   if(!ChartSetInteger(chart_ID,CHART_COLOR_BACKGROUND,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
bool ChartShiftSizeSet(const double value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetDouble(chart_ID,CHART_SHIFT_SIZE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }