using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Strategy { public class RBreakerTS : BaseStrategyAdvisor {
private int m_plength = 20;
private int m_ylength = 2;
private int m_exlength = 10;
private int m_stopmargin = 100;
private int m_trailstep = 100;
private double m_Profit_Target_Amount = 1000;
private SeriesVar< Double> m_lowerband;
private SeriesVar< Double> m_upperband;
public RBreakerTS(object _ctx):base(_ctx){}
[Input] public int plength{ get { return m_plength; } set { m_plength = value; } }
[Input] public int ylength{ get { return m_ylength; } set { m_ylength = value; } } [Input] public int exlength{ get { return m_exlength; } set { m_exlength = value; } } [Input] public int stopmargin{ get { return m_stopmargin; } set { m_stopmargin = value; } } [Input] public int trailstep{ get { return m_trailstep; } set { m_trailstep = value; } } [Input] public double Profit_Target_Amount{ get { return m_Profit_Target_Amount; } set { m_Profit_Target_Amount = value; } }
if (StrategyInfo.MarketPosition <= 0){ if ((Functions.DoubleGreater( m_lowerband[0],Bars.Close[0]) ) & (Functions.DoubleGreater(m_mybarL, ylength))){ buy_order.Generate(m_lowerband[0]); m_entrybarB = Bars.CurrentBar; } }
if (StrategyInfo.MarketPosition >= 0){ if ((Functions.DoubleGreater(Bars.Close[0],m_upperband[0]) ) & (Functions.DoubleGreater(m_mybarH, ylength))){ sell_order.Generate(m_upperband[0]); m_entrybarS = Bars.CurrentBar; } }
if (StrategyInfo.MarketPosition > 0){
if (Bars.CurrentBar==(m_entrybarB+1)){ if (Functions.DoubleLess(Bars.Low[0],Bars.Low[1])){ m_stopB=Bars.Low[0]; } if (Functions.DoubleLessEquals(Bars.Low[1],Bars.Low[0])){ m_stopB=Bars.Low[1]; } }
if ((Functions.DoubleGreater(Bars.High[0],m_upperband[0])) & (Functions.DoubleGreater(m_upperband[0],CurrentPosition.OpenTrades[0].Entry.Price))){ m_stopB = m_stopB+(m_trailstep*Bars.Point); }
if (Bars.CurrentBar==(m_entrybarS+1)){ if (Functions.DoubleGreater(Bars.High[0],Bars.High[1])){ m_stopS=Bars.High[0]; } if (Functions.DoubleGreaterEquals(Bars.High[1],Bars.High[0])){ m_stopS=Bars.High[1]; } }
if ((Functions.DoubleLess(Bars.Low[0],m_lowerband[0])) & (Functions.DoubleLess(m_lowerband[0],CurrentPosition.OpenTrades[0].Entry.Price))){ m_stopS = m_stopS-(m_trailstep*Bars.Point); }
if (Functions.DoubleGreater(m_exlength,(Bars.CurrentBar - m_entrybarS))){ Exshort_order.Generate(m_stopS+m_stopmargin*Bars.Point); } else { ExitS_order.Generate(); } } if (Functions.DoubleGreater(Profit_Target_Amount, 0)){ GenerateProfitTarget(Profit_Target_Amount); } } } }
int market_posはEntryLots、double avg_priceはEntryPriceに対応します double max_opは良く分かりませんが、最大利益価格(Maximum Position Profit Amount)だとすると 前回紹介したSTの機能と一致します(未確認です)
とりあえず入力項目を整理すると ************************
EntryPrice: そのポジションの価格を入力します
EntryLots: ロット数を入力します 買いはプラス、売りはマイナスにします
**********************************
using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Strategy { public class SetInitialPosition : BaseStrategyAdvisor {
public SetInitialPosition(object _ctx):base(_ctx){}
private double entryPrice = 1; private int entryLots = 1;
using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Strategy { public class StSlowAdxr : BaseStrategyAdvisor {
private ISeries< Double> m_priceh;
private ISeries< Double> m_pricel;
private ISeries< Double> 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< Double> m_ofastk;
private SeriesVar< Double> m_ofastd;
private SeriesVar< Double> m_oslowk;
private SeriesVar< Double> m_oslowd;
public Stochastic m_StochasticSlow1;
public StSlowAdxr(object _ctx): base(_ctx){}
private IMarketOrder m_OrderBuy;
private IMarketOrder m_OrderSell;
private IMarketOrder m_OrderExlong;
private IMarketOrder m_OrderExshort;
private ISeries< Double> priceh{ get { return m_priceh; } }
private ISeries< Double> pricel{ get { return m_pricel; } }
private ISeries< Double> 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 = 14;
private DirMovement m_dirmovement1;
private double m_value2;
private SimpleVar< Double> m_odmiplus;
private SimpleVar< Double> m_odmiminus;
private SeriesVar< Double> m_odmi;
private SeriesVar< Double> m_oadx;
private SeriesVar< Double> m_oadxr;
private SeriesVar< Double> m_ovolty;
[Input] public int length{ get { return m_length; } set { m_length = value; } }
private int m_adxlevel = 20;
private double m_Profit_Target_Amount = 3000;
private double m_Stop_Amount = 1100;
[Input] public int adxlevel{ get { return m_adxlevel; } set { m_adxlevel = value; } } [Input] public double Profit_Target_Amount{ get { return m_Profit_Target_Amount; } set { m_Profit_Target_Amount = value; } } [Input] public double Stop_Amount{ get { return m_Stop_Amount; } set { m_Stop_Amount = value; } }
protected override void Construct() {
m_stochastic1 = new Stochastic(this); m_ofastk = new SeriesVar< Double>(this); m_ofastd = new SeriesVar< Double>(this); m_oslowk = new SeriesVar< Double>(this); m_oslowd = new SeriesVar< Double>(this);
using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Strategy { public class StSlowRangeHigh : BaseStrategyAdvisor {
private ISeries< Double> m_priceh;
private ISeries< Double> m_pricel;
private ISeries< Double> 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< Double> m_ofastk;
private SeriesVar< Double> m_ofastd;
private SeriesVar< Double> m_oslowk;
private SeriesVar< Double> m_oslowd;
public Stochastic m_StochasticSlow1;
public StSlowRangeHigh(object _ctx): base(_ctx){}
private IMarketOrder m_OrderBuy;
private IMarketOrder m_OrderSell;
private IMarketOrder m_OrderExlong;
private IMarketOrder m_OrderExshort;
private ISeries< Double> priceh{ get { return m_priceh; } }
private ISeries< Double> pricel{ get { return m_pricel; } }
private ISeries< Double> 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_avglevel = 600;
private double m_avgrange;
private SeriesVar< Double> m_lowerband;
private SeriesVar< Double> m_upperband;
private SeriesVar< Double> m_range;
private double m_Profit_Target_Amount = 5000;
private double m_Stop_Amount = 1100;
[Input] public int length{ get { return m_length; } set { m_length = value; } } [Input] public int avglength{ get { return m_avglength; } set { m_avglength = value; } }
[Input] public double avglevel{ get { return m_avglevel; } set { m_avglevel = value; } } [Input] public double Profit_Target_Amount{ get { return m_Profit_Target_Amount; } set { m_Profit_Target_Amount = value; } } [Input] public double Stop_Amount{ get { return m_Stop_Amount; } set { m_Stop_Amount = value; } }
protected override void Construct() {
m_stochastic1 = new Stochastic(this); m_ofastk = new SeriesVar< Double>(this); m_ofastd = new SeriesVar< Double>(this); m_oslowk = new SeriesVar< Double>(this); m_oslowd = new SeriesVar< Double>(this);
using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Strategy { public class RBreakerS2 : BaseStrategyAdvisor {
private int m_plength = 20;
private int m_ylength = 2;
private int m_exlength = 10;
private int m_stopmargin = 100;
private SeriesVar< Double> m_lowerband;
private SeriesVar< Double> m_upperband;
public RBreakerS2(object _ctx):base(_ctx){}
[Input] public int plength{ get { return m_plength; } set { m_plength = value; } }
[Input] public int ylength{ get { return m_ylength; } set { m_ylength = value; } } [Input] public int exlength{ get { return m_exlength; } set { m_exlength = value; } } [Input] public int stopmargin{ get { return m_stopmargin; } set { m_stopmargin = value; } }
if (Bars.CurrentBar==(m_entrybarB+1)){ if (Functions.DoubleLess(Bars.Low[0],Bars.Low[1])){ m_stopB=Bars.Low[0]; } if (Functions.DoubleLessEquals(Bars.Low[1],Bars.Low[0])){ m_stopB=Bars.Low[1]; } }
if (Bars.CurrentBar==(m_entrybarS+1)){ if (Functions.DoubleGreater(Bars.High[0],Bars.High[1])){ m_stopS=Bars.High[0]; } if (Functions.DoubleGreaterEquals(Bars.High[1],Bars.High[0])){ m_stopS=Bars.High[1]; } }
using System; using System.Drawing; using Broker.StrategyLanguage.Function.BuiltIn; using Fx2GoCommon;
namespace Broker.StrategyLanguage.Indicator { public class RangefilterM : BaseIndicator { private int m_length = 20;
private int m_avglength = 40;
private double m_avgmulti = 1;
private int m_delay = 0;
private double m_avgrange;
private double m_avgrangeM;
private SeriesVar< Double> m_lowerband;
private SeriesVar< Double> m_upperband;
private SeriesVar< Double> m_range;
private IPlot Plot3; private IPlot Plot4;
public RangefilterM(object ctx) : base(ctx) {}
[Input] public int length{ get { return m_length; } set { m_length = value; } } [Input] public int avglength{ get { return m_avglength; } set { m_avglength = value; } } [Input] public double avgmulti{ get { return m_avgmulti; } set { m_avgmulti = value; } } [Input] public int delay{ get { return m_delay; } set { m_delay = value; } }
protected override void Construct(){ m_lowerband = new SeriesVar< Double>(this); m_upperband = new SeriesVar< Double>(this); m_range = new SeriesVar< Double>(this);