[EasyLanguage]パーフェクトオーダーを作る(トレードステーション)
公開日:
:
株式自動売買開発 TradeStation, トレードステーション
今回は久々にプログラミングを触ります。
TradeStationはデフォルトで比較的なインジケーターとストラテジーが内蔵されているため、
デフォルトで搭載されていないテクニカルを探す方が大変だったりします。
今回は「パーフェクトオーダー」がないことに気付いたので、
パーフェクトオーダーを作ってみます。
※パーフェクトオーダーとは、移動平均線をたくさん並べるヤツです。GMMAとも似ています。
inputs:
SuperFastPrice( Close ) [DisplayName = "SuperFastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of super shorter length moving average."],
FastPrice( Close ) [DisplayName = "FastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of shorter length moving average."],
MedPrice( Close ) [DisplayName = "MedPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of medium length moving average."],
SlowPrice( Close ) [DisplayName = "SlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperSlowPrice( Close ) [DisplayName = "SuperSlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperFastLength( 5 ) [DisplayName = "SuperFastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
FastLength( 10 ) [DisplayName = "FastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
MedLength( 15 ) [DisplayName = "MedLength", ToolTip =
"Medium Length. Enter number of bars to use in calculation of medium length moving average."],
SlowLength( 20 ) [DisplayName = "SlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."],
SuperSlowLength( 25 ) [DisplayName = "SuperSlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."],
Displace( 0 ) [DisplayName = "Displace", ToolTip =
"Displacement. Enter the number of bars by which plots will be displaced. Displacement may be positive (left) or negative (right)."];
variables:
SuperFastAvg( 0 ),
FastAvg( 0 ),
MedAvg( 0 ),
SlowAvg( 0 ),
SuperSlowAvg( 0 ),
PriceAndAveragesAlignedUp( false ),
PriceAndAveragesAlignedDn( false );
SuperFastAvg = AverageFC( SuperFastPrice, SuperFastLength );
FastAvg = AverageFC( FastPrice, FastLength );
MedAvg = AverageFC( MedPrice, MedLength );
SlowAvg = AverageFC( SlowPrice, SlowLength );
SuperSlowAvg = AverageFC( SuperSlowPrice, SuperSlowLength );
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( SuperFastAvg, !( "SuperFastAvg" ) );
Plot2[Displace]( FastAvg, !( "FastAvg" ) );
Plot3[Displace]( MedAvg, !( "MedAvg" ) );
Plot4[Displace]( SlowAvg, !( "SlowAvg" ) );
Plot5[Displace]( SuperSlowAvg, !( "SuperSlowAvg" ) );
{ alert criteria }
if AlertEnabled and Displace <= 0 then
begin
PriceAndAveragesAlignedUp = Close > SuperFastAvg and SuperFastAvg > FastAvg and FastAvg > MedAvg
and MedAvg > SlowAvg and SlowAvg > SuperSlowAvg;
PriceAndAveragesAlignedDn = Close < SuperFastAvg and SuperFastAvg < FastAvg and FastAvg < MedAvg
and MedAvg < SlowAvg and SlowAvg < SuperSlowAvg;
if PriceAndAveragesAlignedUp and PriceAndAveragesAlignedUp[1] = false then
Alert( !( "Bullish alert" ) )
else
begin
if PriceAndAveragesAlignedDn and
PriceAndAveragesAlignedDn[1] = false then
Alert( !( "Bearish alert" ) );
end;
end;
end;
といっても特に目新しい内容はありません。
そういえば、PlotX関数はマニュアルを読んだところ、Xは1から99までOKみたいです。
つまり、一つのチャートに対して99個の線や点を入れることができます。
MT4のときは、7個だったので、だいぶ違いますね。
ただ、TradeStationは動作がもっさりしているので、
それだけの負荷に耐えられるのかという疑問の方が先行します。
ここまで来て
「EasyLanguageって本当にシンプルだから、書くことがすぐになくなるんじゃないか」
という思いが強くなるばかりです。
ついでにストラテジーの方も作ってみます。
まずは、買いのストラテジー。
inputs:
SuperFastPrice( Close ) [DisplayName = "SuperFastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of super shorter length moving average."],
FastPrice( Close ) [DisplayName = "FastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of shorter length moving average."],
MedPrice( Close ) [DisplayName = "MedPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of medium length moving average."],
SlowPrice( Close ) [DisplayName = "SlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperSlowPrice( Close ) [DisplayName = "SuperSlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperFastLength( 5 ) [DisplayName = "SuperFastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
FastLength( 10 ) [DisplayName = "FastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
MedLength( 15 ) [DisplayName = "MedLength", ToolTip =
"Medium Length. Enter number of bars to use in calculation of medium length moving average."],
SlowLength( 20 ) [DisplayName = "SlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."],
SuperSlowLength( 25 ) [DisplayName = "SuperSlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."];
variables:
SuperFastAvg( 0 ),
FastAvg( 0 ),
MedAvg( 0 ),
SlowAvg( 0 ),
SuperSlowAvg( 0 ),
PriceAndAveragesAligned( false );
SuperFastAvg = AverageFC( SuperFastPrice, SuperFastLength );
FastAvg = AverageFC( FastPrice, FastLength );
MedAvg = AverageFC( MedPrice, MedLength );
SlowAvg = AverageFC( SlowPrice, SlowLength );
SuperSlowAvg = AverageFC( SuperSlowPrice, SuperSlowLength );
PriceAndAveragesAligned = Close > SuperFastAvg and SuperFastAvg > FastAvg and FastAvg > MedAvg
and MedAvg > SlowAvg and SlowAvg > SuperSlowAvg;
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
if CurrentBar > 1 and PriceAndAveragesAligned and
PriceAndAveragesAligned[1] = false then
Buy ( !( "MA5CrsLE" ) ) next bar at market;
そして、売りのストラテジー。
inputs:
SuperFastPrice( Close ) [DisplayName = "SuperFastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of super shorter length moving average."],
FastPrice( Close ) [DisplayName = "FastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of shorter length moving average."],
MedPrice( Close ) [DisplayName = "MedPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of medium length moving average."],
SlowPrice( Close ) [DisplayName = "SlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperSlowPrice( Close ) [DisplayName = "SuperSlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
SuperFastLength( 5 ) [DisplayName = "SuperFastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
FastLength( 10 ) [DisplayName = "FastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
MedLength( 15 ) [DisplayName = "MedLength", ToolTip =
"Medium Length. Enter number of bars to use in calculation of medium length moving average."],
SlowLength( 20 ) [DisplayName = "SlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."],
SuperSlowLength( 25 ) [DisplayName = "SuperSlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."];
variables:
SuperFastAvg( 0 ),
FastAvg( 0 ),
MedAvg( 0 ),
SlowAvg( 0 ),
SuperSlowAvg( 0 ),
PriceAndAveragesAligned( false );
SuperFastAvg = AverageFC( SuperFastPrice, SuperFastLength );
FastAvg = AverageFC( FastPrice, FastLength );
MedAvg = AverageFC( MedPrice, MedLength );
SlowAvg = AverageFC( SlowPrice, SlowLength );
SuperSlowAvg = AverageFC( SuperSlowPrice, SuperSlowLength );
PriceAndAveragesAligned = Close < SuperFastAvg and SuperFastAvg < FastAvg and FastAvg < MedAvg
and MedAvg < SlowAvg and SlowAvg < SuperSlowAvg;
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
if CurrentBar > 1 and PriceAndAveragesAligned and
PriceAndAveragesAligned[1] = false then
Sell ( !( "MA5CrsLE" ) ) next bar at market;
ドル円に対して適応したので、上手くいかないことは100も承知です。
(パーフェクトオーダーはシグナルの出現が遅れるので、トレンドが続きにくいFXには不向きです)
めっちゃキレイに取れてる…
トレンド系のテクニカルはやっぱり株の方が相性いいですね。
ただ、シグナルが発生するまでにかなり待たなくてはいけないので、
それまで耐えられるかという問題はあると思います。
関連記事
-
-
株の自動売買プログラムを開発する6つのやり方
FX業界ではMT4/MT5のおかげもあり、個人レベルでも自動売買やシステムトレードが盛んにおこなわれ
-
-
初心者のためのEasyLanguage入門(トレードステーション)
これからトレードステーションのストラテジーを開発するためにEasyLanguageをやってみようとい
-
-
日本株の個別銘柄でシステムトレード検証&自動売買(ダウンロードあり)
MT4/MT5というとFXでのトレードプラットフォームの印象が強いですが、株のトレードも可能です。特
-
-
トレードステーションの使い方(初心者)
トレードステーションのチャートの表示方法 TradeStation/トレードステーションは、Met
-
-
[EasyLanguage]ストラテジーのコードを読み解く(トレードステーション)
移動平均線のクロスのストラテジーのプログラミングを見ていきたいと思います。 inputs:




