FX取引ルール確立のために

取引方針が定まらぬ臆病者の外国為替証拠金取引の行方。 取引ルールの柱にテクニカルな売買サインを導入中。システム開発状況を全て公開。

スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

StochasticSlowRangefilterOnly

ストラテジー
StochasticSlowRangefilterOnly

    ******************************
using System;
using System.Drawing;
using Broker.StrategyLanguage.Function.BuiltIn;
using Fx2GoCommon;

namespace Broker.StrategyLanguage.Strategy {
public class StochasticSlowRangefilterOnly : BaseStrategyAdvisor
{

private ISeries m_priceh;

private ISeries m_pricel;

private ISeries m_pricec;

private int m_stochlength = 14;

private int m_smoothinglength1 = 3;

private int m_smoothinglength2 = 3;

private int m_smoothingtype = 1;

private double m_oversold = 20;

private double m_overbought = 80;

private Stochastic m_stochastic1;

private double m_value1;

private SeriesVar m_ofastk;

private SeriesVar m_ofastd;

private SeriesVar m_oslowk;

private SeriesVar m_oslowd;

public Stochastic m_StochasticSlow1;


public StochasticSlowRangefilterOnly(object _ctx):
base(_ctx){}

private IMarketOrder m_OrderBuy;

private IMarketOrder m_OrderSell;

private IMarketOrder m_OrderExlong;

private IMarketOrder m_OrderExshort;

private ISeries priceh{
get { return m_priceh; }
}

private ISeries pricel{
get { return m_pricel; }
}

private ISeries pricec{
get { return m_pricec; }
}

[Input]
public int stochlength{
get { return m_stochlength; }
set { m_stochlength = value; }
}

[Input]
public int smoothinglength1{
get { return m_smoothinglength1; }
set { m_smoothinglength1 = value; }
}

[Input]
public int smoothinglength2{
get { return m_smoothinglength2; }
set { m_smoothinglength2 = value; }
}

[Input]
public int smoothingtype{
get { return m_smoothingtype; }
set { m_smoothingtype = value; }
}

[Input]
public double oversold{
get { return m_oversold; }
set { m_oversold = value; }
}

[Input]
public double overbought{
get { return m_overbought; }
set { m_overbought = value; }
}


private int m_length = 20;
private int m_avglength = 40;

private double m_avgrange;

private SeriesVar m_lowerband;

private SeriesVar m_upperband;

private SeriesVar m_range;

[Input]
public int length{
get { return m_length; }
set { m_length = value; }
}
[Input]
public int avglength{
get { return m_avglength; }
set { m_avglength = value; }
}




protected override void Construct() {

m_stochastic1 = new Stochastic(this);
m_ofastk = new SeriesVar(this);
m_ofastd = new SeriesVar(this);
m_oslowk = new SeriesVar(this);
m_oslowd = new SeriesVar(this);

m_OrderBuy = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Default, "BUY", OrderAction.Buy));
m_OrderSell =
OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Default, "SELL", OrderAction.SellShort));
m_OrderExlong = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Default, "EXL", OrderAction.Sell));
m_OrderExshort = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Default, "EXS", OrderAction.BuyToCover));

m_lowerband = new SeriesVar(this);
m_upperband = new SeriesVar(this);
m_range = new SeriesVar(this);
}




protected override void Initialize() {

m_priceh = Bars.High;
m_pricel = Bars.Low;
m_pricec = Bars.Close;
m_stochastic1.priceh = priceh;
m_stochastic1.pricel = pricel;
m_stochastic1.pricec = pricec;
m_stochastic1.stochlength = new SeriesExpression(delegate { return stochlength; });
m_stochastic1.length1 = new SeriesExpression(delegate { return smoothinglength1; });
m_stochastic1.length2 = new SeriesExpression(delegate { return smoothinglength2; });
m_stochastic1.smoothingtype = new SeriesExpression(delegate { return smoothingtype; });
m_stochastic1.ofastk = m_ofastk;
m_stochastic1.ofastd = m_ofastd;
m_stochastic1.oslowk = m_oslowk;
m_stochastic1.oslowd = m_oslowd;
m_value1 = default(double);
m_ofastk.DefaultValue = 0;
m_ofastd.DefaultValue = 0;
m_oslowk.DefaultValue = 0;
m_oslowd.DefaultValue = 0;

m_lowerband.DefaultValue = 0;
m_upperband.DefaultValue = 0;
m_range.DefaultValue = 0;
m_avgrange = 0;
}



protected override void Execute(){

m_value1 = m_stochastic1[0];

m_lowerband.Value = Functions.Lowest(Bars.Low, length, 0);
m_upperband.Value = Functions.Highest(Bars.High, length, 0);
m_range.Value = m_upperband.Value - m_lowerband.Value ;
m_avgrange = Functions.Average(m_range, avglength);


if (Functions.DoubleGreater(Bars.CurrentBar, 2)){

if ( Functions.CrossesOver(this, m_oslowk, m_oslowd) ){
m_OrderExshort.Generate();
}

if ( Functions.CrossesUnder(this, m_oslowk, m_oslowd) ){
m_OrderExlong.Generate();
}

if (( Functions.DoubleGreater( m_oslowk[0], m_overbought))
&&(Functions.DoubleGreater( m_overbought,m_oslowk[1] ))){
m_OrderExlong.Generate();
}

if ((Functions.DoubleGreater( m_oversold,m_oslowk[0]))
&&( Functions.DoubleGreater(m_oslowk[1],m_oversold))){
m_OrderExshort.Generate();
}


if (Functions.DoubleGreater(m_range[0], m_avgrange)){
if ((Functions.CrossesOver(this, m_oslowk, m_oslowd) )){
m_OrderBuy.Generate();
  }

if ((Functions.CrossesUnder(this, m_oslowk, m_oslowd) )){
m_OrderSell.Generate();
  }
}
}
}
}
}


[他の自動売買サイトを探す]
人気blogランキング





[当サイトで使っている自動売買システム]
FXCMはMT4よりも優れていると言っています
ストラテジートレーダー概要
ストラテジートレーダーβ版利用ガイド

[相場の流れは]
FX ポータル
今井さん アイルランドの運命
陳さん  スペインとユーロ
西原宏一 ユーロドルの下落予想
松田さん ドル円売りは小さく
吉田さん 金利とユーロ危機
スポンサーサイト

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック

トラックバックURLはこちら
http://fxrun.blog55.fc2.com/tb.php/1662-fcab41ec
この記事にトラックバックする(FC2ブログユーザー)

FC2Ad

上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。