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

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

スポンサーサイト

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

StSlowRangefilterSmaWoHL

Stratergy Traderで使用しているソースコードです

ストラテジー
StSlowRangefilterSmaWoHL

StochasticSlowRangefilterの改善版です
変更点は以下になります

1 overboughtラインの上での買いエントリーの禁止
2 oversoldラインの下での売りエントリーの禁止

********************************

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

namespace Broker.StrategyLanguage.Strategy {
public class StSlowRangefilterSmaWoHL : 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 StSlowRangefilterSmaWoHL(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; }
}



private ISeries m_price;
private int m_SMAlength = 20;
private Average m_average1;
private SeriesVar m_updown;


private ISeries price{
get { return m_price; }
}

[Input]
public int SMAlength{
get { return m_SMAlength; }
set { m_SMAlength = 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);

m_average1 = new Average(this);
m_updown = 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;

m_price = Bars.Close;
m_average1.price = price;
m_average1.length = new SeriesExpression(delegate { return SMAlength; });

m_updown.DefaultValue = 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);

m_updown.Value = m_average1[0]-m_average1[1] ;


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

if (StrategyInfo.MarketPosition < 0){

if ( Functions.CrossesOver(this, m_oslowk, m_oslowd) ){

m_OrderExshort.Generate();
}

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


if (StrategyInfo.MarketPosition >0){

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_avgrange, m_range[0])){

if ((Functions.DoubleGreater(m_overbought,m_oslowd[0]))
&& (Functions.CrossesOver(this, m_oslowk, m_oslowd))
&& (Functions.DoubleGreater(m_updown[0], 0))){

m_OrderBuy.Generate();
}

if ((Functions.DoubleGreater(m_oslowd[0],m_oversold))
&& (Functions.CrossesUnder(this, m_oslowk, m_oslowd))
&& (Functions.DoubleGreater(0, m_updown[0]))){

 m_OrderSell.Generate();
  }
}


if (Functions.DoubleGreaterEquals(m_range[0], m_avgrange)){

if ((Functions.DoubleGreater(m_overbought,m_oslowd[0]))
&& (Functions.CrossesOver(this, m_oslowk, m_oslowd))){

m_OrderBuy.Generate();
}

if ((Functions.DoubleGreater(m_oslowd[0],m_oversold))
&& (Functions.CrossesUnder(this, m_oslowk, m_oslowd))){

m_OrderSell.Generate();
}
}
}
}
}
}


[当サイトで使っている自動売買システム]

FXCMはMT4よりも優れていると言っています

ストラテジートレーダー概要

ストラテジートレーダーβ版利用ガイド

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





[相場の流れは]
FX ポータル
陳さん  ドルの行くへ
今井さん ユーロドルの下値目途
西原宏一 ヘッジファンドとユーロドル
松田さん ユーロドルと欧州金融
吉田さん 雇用統計後のドル
スポンサーサイト

コメント

コメントの投稿


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

トラックバック

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

FC2Ad

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