株価トレンド
平成最後のプログラミングです(°_°)
株たんの株価トレンドのこんな感じの作りたかったけど...
矢印めんどっ!でレーダースクリーン用のこんな感じのになりましたw
短期25、中期75、長期200で初期設定、入力項目で変更可能
平均線の向きは考慮してないので位置だけでステージ判断
方向性も考慮するなら平均線の直近2つを比較すれば大丈夫だと思います
例:Avg[0] > Avg[1]
段階は6段階、上昇3段階、下降3段階
上昇(赤字)
1:短期>長期、長期>中期(上昇初期)
2:短期>中期、中期>長期(上昇中期)
3:中期>短期、短期>長期(上昇後期)
下降(青字)
4:中期>長期、長期>短期(下降初期)
5:長期>中期、中期>短期(下降中期)
6:長期>短期、短期>中期(下降後期)
株価が移動平均より上の場合は背景色を青、下の場合は赤
どのくらい離れているか分かるように乖離率を追加
※ 乖離部分のプロパティはパーセント、段階は数字で少数ゼロ
2番目の長期的に下がりすぎて、短期的にちょっとリバぽいのがわかります
いくつかチャート見ましたが、このインジケータだけでは判断に乏しいです
同じ段階でも似たようなチャートもあれば全然違うチャートもあります
簡単なプログラムだと同じ段階と判断されてしまうのはストラテジー作るうえでは難しい所以かもしれません
移動平均線の位置や株価の位置だけではなかなか今後の方向性は分かりづらいですね(´д`;)
段階が変わる時、トレンドが出ている場合等、
現在の段階や方向性はある程度判断できるので、
他の指標と組み合わせて使ってみて下さい
プログラム
inputs:
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."],
FastLength( 25 ) [DisplayName = "FastLength", ToolTip = "Enter number of bars to use in calculation of shorter length moving average."],
MedLength( 75 ) [DisplayName = "MedLength", ToolTip = "Enter number of bars to use in calculation of medium length moving average."],
SlowLength( 200 ) [DisplayName = "SlowLength", 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)."];
vars:
FastAvg( 0 ), //短期移動平均
MedAvg( 0 ), //中期移動平均
SlowAvg( 0 ), //長期移動平均
Stage( 0 ), //段階
PriceAndAveragesAlignedUp( false ),
PriceAndAveragesAlignedDn( false );
FastAvg = AverageFC( FastPrice, FastLength );
MedAvg = AverageFC( MedPrice, MedLength );
SlowAvg = AverageFC( SlowPrice, SlowLength );
//移動平均並び順でステージ判断
if FastAvg > SlowAvg and SlowAvg > MedAvg then Stage = 1; //上昇初期
if FastAvg > MedAvg and MedAvg > SlowAvg then Stage = 2; //上昇中期
if MedAvg > FastAvg and FastAvg > SlowAvg then Stage = 3; //上昇後期
if MedAvg > SlowAvg and SlowAvg > FastAvg then Stage = 4; //下降初期
if SlowAvg > MedAvg and MedAvg > FastAvg then Stage = 5; //下降中期
if SlowAvg > FastAvg and FastAvg > MedAvg then Stage = 6; //下降後期
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then begin
Plot1[Displace]( FastAvg, !( "短期" ) );
if FastAvg <> 0 then Plot4[Displace]( (( Close - FastAvg ) / FastAvg ), !( "短期乖離" ) );
Plot2[Displace]( MedAvg, !( "中期" ) );
if MedAvg <> 0 then Plot5[Displace]( (( Close - MedAvg ) / MedAvg ), !( "中期乖離" ) );
Plot3[Displace]( SlowAvg, !( "長期" ) );
if SlowAvg <> 0 then Plot6[Displace]( (( Close - SlowAvg ) / SlowAvg ), !( "長期乖離" ) );
Plot7[Displace]( Stage, !( "段階" ) );
//株価位置により背景色分け
if Close > FastAvg then setplotBGcolor( 1 , DarkBlue ) else if Close < FastAvg then setplotBGcolor( 1 , DarkRed );
if Close > MedAvg then setplotBGcolor( 2 , DarkBlue ) else if Close < MedAvg then setplotBGcolor( 2 , DarkRed );
if Close > SlowAvg then setplotBGcolor( 3 , DarkBlue ) else if Close < SlowAvg then setplotBGcolor( 3 , DarkRed );
if Plot4 > 0 then setplotBGcolor( 4 , DarkBlue ) else if Plot4 < 0 then setplotBGcolor( 4 , DarkRed );
if Plot5 > 0 then setplotBGcolor( 5 , DarkBlue ) else if Plot5 < 0 then setplotBGcolor( 5 , DarkRed );
if Plot6 > 0 then setplotBGcolor( 6 , DarkBlue ) else if Plot6 < 0 then setplotBGcolor( 6 , DarkRed );
//段階により色分け
if Stage = 1 or Stage = 2 or Stage = 3 then setplotcolor( 7 , UpColorDefault ) else if Stage = 4 or Stage = 5 or Stage = 6 then setplotcolor( 7 , DownColorDefault );
{ alert criteria }
if AlertEnabled and Displace <= 0 then begin
PriceAndAveragesAlignedUp = Close > FastAvg and FastAvg > MedAvg and MedAvg > SlowAvg;
PriceAndAveragesAlignedDn = Close < FastAvg and FastAvg < MedAvg and MedAvg < SlowAvg;
if PriceAndAveragesAlignedUp and PriceAndAveragesAlignedUp[1] = false then Alert( !( "Bullish alert" ) )
else if PriceAndAveragesAlignedDn and PriceAndAveragesAlignedDn[1] = false then Alert( !( "Bearish alert" ) );
end;
end;
いいなと思ったら応援しよう!
サポートされると喜んでアイスを買っちゃいます!٩(๑❛ᴗ❛๑)۶