MQL4 EAからチャートにインジケータを追加する。 - ページ 5

 

トレーディング、自動売買システム、トレーディング戦略のテストに関するフォーラム

MQL4 EAからチャートにインジケータを追加する

アラン・ヴェリエン 2016.02.13 11:39

#import "user32.dll"
int RegisterWindowMessageW(string MessageName);
int PostMessageW(int hwnd,int msg,int wparam,uchar &Name[]);
#import

#define  INDICATOR_NAME "Indicator_name"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void StartCustomIndicator(int hWnd,string IndicatorName,bool AutomaticallyAcceptDefaults=false)
  {
   uchar name2[];
   StringToCharArray(IndicatorName,name2,0,StringLen(IndicatorName));

   int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message");
   int r=PostMessageW(hWnd,MessageNumber,15,name2);
   Sleep(10);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
// In my code where I launch the indicator
   int hWnd=WindowHandle(Symbol(),0);
   StartCustomIndicator(hWnd,INDICATOR_NAME);

   return(INIT_SUCCEEDED);
  }

こんにちは、皆さん

上記のコードはエキスパートで動作しますが、上記のコードをインジケーターで使用するにはどうすればよいですか?

お願いします。

 
MT4でEAを使用してチャートからインジケータを削除することは可能でしょうか?OnDenit() 数の中で、いくつかのコードを記述することができます。
 
Abdul Manan:
MT4でEAを使用してチャートからインジケータを削除することは可能でしょうか?OnDenit()関数の 中で、いくつかのコードを記述することができます。

指定されたチャートウィンドウから指定された名前のインジケータを削除します。このコマンドは、チャートメッセージキューに追加され、前のコマンドがすべて処理された後にのみ実行されます。

boolChartIndicatorDelete()
longchart_id,// チャート ID
intsub_window,// サブウィンドウの番号
const stringindicator_shortname// インジケーターの短い名前
);

パラメータ

チャートID

[in] チャートID。0 は現在のチャートを表します。

sub_window

[in] チャートサブウィンドウの番号。0はメインチャートサブウィンドウを表します。

const indicator_shortname

[IndicatorSetString() 関数でINDICATOR_SHORTNAMEpropertyに 設定されたインジケータのショートネームです。 指標のショートネームを取得するには、ChartIndicatorName() 関数を使用します。

戻り値

コマンドがチャートキューに追加された場合はtrueを、そうでない場合はfalseを返します。エラー詳細を 得るには、GetLastError() 関数を使用してください。

ChartIndicatorDelete - 图表操作 - MQL4参考
ChartIndicatorDelete - 图表操作 - MQL4参考
  • docs.mql4.com
Removes an indicator with a specified name from the specified chart window. The command is added to chart message queue and executed only after all previous commands have been processed. If the short name of an indicator is not set explicitly, then the name of the file containing the source code of the indicator will be specified during...
 
Alain Verleyen:
バックテスト 時にEAからチャートに自動でインジケータを貼り付ける方法はありますか?
 
int OnInit()
  {
//---
// In my code where I launch the indicator
   int hWnd=WindowHandle(Symbol(),0);
   StartCustomIndicator(hWnd,INDICATOR_NAME);

   return(INIT_SUCCEEDED);
  }


This code work, but only in OnInit section. If i try transfer it to section CHARTEVENT_OBJECT_CLICK for launch with key, nothing happend. Can you help me ?
 
こんにちは、私は同じコードを使用して、1つのEAから2つの指標をロードすることができません。
 
このスレッドは私にとって非常に役に立ちましたが、そこまでたどり着けませんでした -- このスレッド(https://www.forexfactory.com/showthread.php?p=12764287#)をご覧ください。ここでの対話が終わったところを拾っています。
 
Kray:

皆さん、こんにちは。

Georgiy Liashchenkoに感謝し、AutomaticallyAcceptDefaults ("true "の場合)を使ってインジケータを直接チャートに追加する彼のコードのアップグレード版を共有したいと思います

エキスパートからインジケータを挿入する必要がある方々のお役に立てれば幸いです。

注1:カスタム・インジケータの場合、Windowsの名前を変更する必要があります。

注2:15文字以上のインジケータを使用しないでください(".ex4 "の前)。

こんにちは、私はこれを得た

user32.dll::RegisterWindowMessageW'を呼び出すことができません。

誰か私を助けることができますか?


 
Alain Verleyen:

私はこの問題はありません(私が投稿したコードで)。

hWndが0と異なることを確認してください。

また、スリープの値を50または100に増やしてみてください。

親愛なるアラン。

私はあなたのコードを使用して、開いている すべてのチャートに 1つのインジケータを追加しましたが、それは私がEAを実行したチャートにのみ追加されました。

ここにコードがありますが、同じインジケータをすべてのチャートに追加するようにコードを修正してもらえますか?

よろしくお願いします。

ちなみに(EAとしてもスクリプトとしても試してみましたが、どちらも1つのチャートにしかインジケータは追加されませんでした) :)

よろしくお願いします。



#import "user32.dll"

int RegisterWindowMessageW(string MessageName);

int PostMessageW(int hwnd,int msg,int wparam,uchar &Name[]);

#import


#define INDICATOR_NAME "CCI_FILTER6C" (インジケータ名)


int NOS ;

string suffix="";

string symbol[30];

long chartid[30];


//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+


int OnStart()

{

NOS=10;

suffix="c";

シンボル[0] = "AUDCAD" + サフィックス ;

シンボル[1] = "AUDCHF" + suffix ;

symbol[2] = "AUDJPY" + suffix;

symbol[3] = "AUDNZD" + suffix; symbol[4] = "AUDNZD" + suffix;

記号[4] = "AUDUSD" + サフィックス ;

symbol[5] = "CADJPY" + suffix ;

symbol[6] = "CHFJPY" + サフィックス;

symbol[7] = "EURAUD" + suffix ;

記号[8] = "EURCAD" + サフィックス ;

symbol[9] = "EURCHF" + suffix;

for(int is=0;is<NOS;is++)

{

int hWnd=WindowHandle(symbol[is],PERIOD_M30);

StartCustomIndicator(hWnd,INDICATOR_NAME)を実行します。

}

return(0);

}

void StartCustomIndicator(int hWnd,string IndicatorName,bool AutomaticallyAcceptDefaults=true)

{

uchar name2[];

StringToCharArray(IndicatorName,name2,0,StringLen(IndicatorName));


int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message");

int r=PostMessageW(hWnd,MessageNumber,15,name2).Sleep(100);。

Sleep(100);

}

 
Abdul Manan:
こんにちは、私は同じコードを使って1つのEAから2つの指標をロードすることができません。

同じEAから複数のインディケータを追加する方法を見つけた方はいらっしゃいますか?


私は同じEAから2つのhttps://docs.mql4.com/indicators/ima を追加したいです。


感謝

理由: