![見出し画像](https://assets.st-note.com/production/uploads/images/117883170/rectangle_large_type_2_2bedbbebbffffb7c647b0d8d491ef195.jpeg?width=1200)
ZigZag
//<<<<<>>>>><<<<<>>>>><< ZigZag >><<<<<>>>>><<<<<>>>>>
input group "ZigZag"
input int select_ZigZag_set_value = 0; //ZigZagの設定値(0,1,2)
int ZigZag_Handle;
double ZigZagBuf[];
double arrays[30];//ZigZag格納用
//--- 構造体の宣言
struct ZigZag_set_value
{
int Depth;
int Deviation;
int BackStep;
string Name;
};
//--- インスタンスの生成
ZigZag_set_value ZigZag_value[3]=
{
{13,5,3,"normal_ZigZag"},//配列[0]に代入される値
{26,5,3,"middle_ZigZag"},//配列[1]に代入される値
{40,5,3,"long_ZigZag"},//配列[2]に代入される値
};
OnInit()
ZigZag_Handle = iCustom(_Symbol,_Period,"Examples\\ZigZag",ZigZag_value[select_ZigZag_set_value].Depth,ZigZag_value[select_ZigZag_set_value].Deviation,ZigZag_value[select_ZigZag_set_value].BackStep);
OnTick()
ZigZag_dataget();//zigzag価格をarray[]に格納する
Print(arrays[0]);//一つ目のZigZag値をPrintする
ZigZag_dataget()
//+------------------------------------------------------------------+
//| zigzag価格をarray[]に格納する |
//+------------------------------------------------------------------+
void ZigZag_dataget()
{
ArraySetAsSeries(ZigZagBuf,true);
CopyBuffer(ZigZag_Handle,0,0,5000,ZigZagBuf);
int array_count = 0;
//ZigZagの価格が0以外(天底)の場合に、配列に入れなおす
for(int i=0; i<5000; i++)
{
if(ZigZagBuf[i]!=0)
{
arrays[array_count] = ZigZagBuf[i];
if(array_count == 29)
break;
array_count+=1;
}
}
ArrayPrint(arrays);
}
MQL5コード一覧はコチラ