#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#define GV_NAME "TestGlobalVariableSet"
#define GV_VALUE 1.23456
//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- クライアント端末グローバル変数GV_NAMEに新しいGV_VALUE値を設定する
//--- 変数が存在しない場合は作成する
if(GlobalVariableSet(GV_NAME, GV_VALUE)==0)
{
Print("GlobalVariableSet() failed. Error ", GetLastError());
return;
}
//--- 結果を確認して操作ログに出力する
double value=0;
if(GlobalVariableGet(GV_NAME, value))
{
PrintFormat("The global variable of the client terminal named \"%s\" is set to %.5f", GV_NAME, value);
}
/*
結果:
The global variable of the client terminal named "TestGlobalVariableSet" is set to 1.23456
*/
}
|