All Projects → mkjiau → MFLL

mkjiau / MFLL

Licence: other
Use fuzzy logic control with PL/EL in MultiCharts

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to MFLL

golden eye
a quantitative trading system(股指交易)
Stars: ✭ 17 (-10.53%)
Mutual labels:  quantitative-finance
q4q
Source Code for "Q for Quants"
Stars: ✭ 22 (+15.79%)
Mutual labels:  quantitative-finance
QuoraBooks
A GitHub repo for Quant Finance resources
Stars: ✭ 17 (-10.53%)
Mutual labels:  quantitative-finance
lifelib
Python package of actuarial models, tools, examples and learning materials.
Stars: ✭ 94 (+394.74%)
Mutual labels:  quantitative-finance
RISKIM
Assets' Risk Management Using Mean-Variance Opt Based On Mult-Factors Trending Prediction
Stars: ✭ 25 (+31.58%)
Mutual labels:  quantitative-finance
portfolio allocation js
A JavaScript library to allocate and optimize financial portfolios.
Stars: ✭ 145 (+663.16%)
Mutual labels:  quantitative-finance
random
This is all my random garbage.
Stars: ✭ 23 (+21.05%)
Mutual labels:  quantitative-finance
support resistance line
A well-tuned algorithm to generate & draw support/resistance line on time series. 根据时间序列自动生成支撑线压力线
Stars: ✭ 53 (+178.95%)
Mutual labels:  quantitative-finance
Beibo
🤖 Predict the stock market with AI 用AI预测股票市场
Stars: ✭ 46 (+142.11%)
Mutual labels:  quantitative-finance
storage
Multi-Factor Least Squares Monte Carlo energy storage valuation model (Python and .NET).
Stars: ✭ 24 (+26.32%)
Mutual labels:  quantitative-finance
course codes
VNPY 2020 Python数字货币量化交易视频教程课程代码和资料
Stars: ✭ 143 (+652.63%)
Mutual labels:  quantitative-finance
ProjectReward
A software to shortlist and find the best options spread available for a given stock and help it visualise using payoff graphs.
Stars: ✭ 57 (+200%)
Mutual labels:  quantitative-finance
Quant-Finance
Some notebooks with powerful trading strategies.
Stars: ✭ 42 (+121.05%)
Mutual labels:  quantitative-finance
tradestation-python-api
A Python Client library for the TradeStation API.
Stars: ✭ 69 (+263.16%)
Mutual labels:  tradestation
okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Stars: ✭ 87 (+357.89%)
Mutual labels:  quantitative-finance
quant-jobs-zurich
A list of companies of possible interest for mathematicians (or related) that are looking for a job in quantitative finance in Zurich.
Stars: ✭ 59 (+210.53%)
Mutual labels:  quantitative-finance
ib dl
Historical market data downloader using Interactive Brokers TWS
Stars: ✭ 43 (+126.32%)
Mutual labels:  quantitative-finance
qwack
A modern quantitative finance framework that makes the complex simple
Stars: ✭ 18 (-5.26%)
Mutual labels:  quantitative-finance
AltoTrader
Automated crypto currency trading bot
Stars: ✭ 29 (+52.63%)
Mutual labels:  quantitative-finance
PyFENG
Python Financial ENGineering (PyFENG package in PyPI.org)
Stars: ✭ 51 (+168.42%)
Mutual labels:  quantitative-finance

MultiCharts Fuzzy Logic Library (MFLL)

Extended from C/C++ library of FFLL, MFLL allows you to apply fuzzy control engine for your trading strategy design in MultiCharts. You will write Fuzzy Control Language (FCL) with PL/EL during strategy development.

How to use MFLL?

Go to Installation folder, then follow the instructions as below:

  1. Download MFLLAPI.dll and MFLL_MC.pla
  2. Put .dll in C:\Program Files\TS Support\MultiCharts64
  3. Click .pla to import PL/EL-wrapped APIs for use
  4. Done. Get started with MFLL.

You also can download the source codes and compile MFLLAPI.dll yourself to be compatiable with your MultiCharts.

Write FCL Directly in PL/EL

Multi-API Formation
vars: fcl("");

fcl = Text(
"FUNCTION_BLOCK", NewLine,
NewLine,
"VAR_INPUT", NewLine,
"RSI	REAL; (* RANGE(0 .. 100) *)", NewLine,
"Bias	REAL; (* RANGE(-100 .. 100) *)", NewLine,
"END_VAR", NewLine,
NewLine,
"VAR_OUTPUT", NewLine,
"Action	REAL; (* RANGE(-2 .. 2) *)", NewLine,
"END_VAR", NewLine,
NewLine,
"FUZZIFY RSI", NewLine,
"TERM Small  := (0, 0) (0, 1) (50, 0) ;", NewLine,
"TERM Middle := (10, 0) (50, 1) (70, 0) ;", NewLine,
"TERM Large  := (30, 0) (100, 1) (100, 0) ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"FUZZIFY Bias", NewLine, 
"TERM Negative  := (-100, 0) (-100, 1) (50, 0) ;", NewLine,
"TERM Zero := (-80, 0) (-35, 1) (5, 1) (50, 0) ;", NewLine,
"TERM Positive  := (-50, 0) (100, 1) (100, 0) ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"FUZZIFY Action", NewLine,
"TERM Short   := -1 ;", NewLine,
"TERM Neutral := 0 ;", NewLine,
"TERM Long    := 1 ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"DEFUZZIFY valve", NewLine,
"METHOD: MoM;", NewLine,
"END_DEFUZZIFY", NewLine,
NewLine,
"RULEBLOCK first", NewLine,
"AND:MIN;", NewLine,
"ACCUM:MAX;", NewLine,
"RULE 0: IF Large AND Positive THEN Long;", NewLine,
"RULE 1: IF Large AND Zero THEN Long;", NewLine,
"RULE 2: IF Large AND Negative THEN Long ;", NewLine,
"RULE 3: IF Middle AND Positive THEN Long ;", NewLine,
"RULE 4: IF Middle AND Zero THEN Long ;", NewLine,
"RULE 5: IF Middle AND Negative THEN Short ;", NewLine,
"RULE 6: IF Small AND Positive THEN Neutral;", NewLine,
"RULE 7: IF Small AND Zero THEN Short ;", NewLine,
"RULE 8: IF Small AND Negative THEN Short ;", NewLine, 
"END_RULEBLOCK", NewLine,
NewLine,
"END_FUNCTION_BLOCK", NewLine
);


{ Configure Fuzzy Control Engine }

vars: model(-1), child(-1);

if model = -1 then begin 
   model = MFLLNewModel();
   MFLLLoadFCLString(model, fcl);
   child = MFLLNewChild(model);
end;

MFLLSetValue(model,child,0, RSI(C,14)); // input RSI indicator (built-in)
MFLLSetValue(model,child,1, Bias(C,30)); // input Bias indicator (custom)


{ Trading Signal }

vars: Action(0);

Action = MFLLGetOutputValue(model,child);

if MP <> 1 and Action = 1 then buy ("fuzzy-LE") next bar at market; 
if MP <>-1 and Action =-1 then sellshort ("fuzzy-SE") next bar at market;

if Action = 0 then begin
   if MP > 0 then sell ("fuzzy-LX") next bar at market;
   if MP < 0 then buytocover ("fuzzy-SX") next bar at market;
end;
Single-API Formation
vars: fcl("");

fcl = Text(
"FUNCTION_BLOCK", NewLine,
NewLine,
"VAR_INPUT", NewLine,
"RSI	REAL; (* RANGE(0 .. 100) *)", NewLine,
"Bias	REAL; (* RANGE(-100 .. 100) *)", NewLine,
"END_VAR", NewLine,
NewLine,
"VAR_OUTPUT", NewLine,
"Action	REAL; (* RANGE(-2 .. 2) *)", NewLine,
"END_VAR", NewLine,
NewLine,
"FUZZIFY RSI", NewLine,
"TERM Small  := (0, 0) (0, 1) (50, 0) ;", NewLine,
"TERM Middle := (10, 0) (50, 1) (70, 0) ;", NewLine,
"TERM Large  := (30, 0) (100, 1) (100, 0) ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"FUZZIFY Bias", NewLine, 
"TERM Negative  := (-100, 0) (-100, 1) (50, 0) ;", NewLine,
"TERM Zero := (-80, 0) (-35, 1) (5, 1) (50, 0) ;", NewLine,
"TERM Positive  := (-50, 0) (100, 1) (100, 0) ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"FUZZIFY Action", NewLine,
"TERM Short   := -1 ;", NewLine,
"TERM Neutral := 0 ;", NewLine,
"TERM Long    := 1 ;", NewLine,
"END_FUZZIFY", NewLine,
NewLine,
"DEFUZZIFY valve", NewLine,
"METHOD: MoM;", NewLine,
"END_DEFUZZIFY", NewLine,
NewLine,
"RULEBLOCK first", NewLine,
"AND:MIN;", NewLine,
"ACCUM:MAX;", NewLine,
"RULE 0: IF Large AND Positive THEN Long;", NewLine,
"RULE 1: IF Large AND Zero THEN Long;", NewLine,
"RULE 2: IF Large AND Negative THEN Long ;", NewLine,
"RULE 3: IF Middle AND Positive THEN Long ;", NewLine,
"RULE 4: IF Middle AND Zero THEN Long ;", NewLine,
"RULE 5: IF Middle AND Negative THEN Short ;", NewLine,
"RULE 6: IF Small AND Positive THEN Neutral;", NewLine,
"RULE 7: IF Small AND Zero THEN Short ;", NewLine,
"RULE 8: IF Small AND Negative THEN Short ;", NewLine, 
"END_RULEBLOCK", NewLine,
NewLine,
"END_FUNCTION_BLOCK", NewLine
);


Array: double FuzzyInputs[2](0.0);

FuzzyInputs[0] = RSI(C,14); // input RSI indicator (built-in)
FuzzyInputs[1] = Bias(C,30); // input Bias indicator (custom)


{ Trading Signal }

vars: Action(0);

Action = MFLLFuzzyInference(fcl, FuzzyInputs);

if MP <> 1 and Action = 1 then buy ("fuzzy-LE") next bar at market; 
if MP <>-1 and Action =-1 then sellshort ("fuzzy-SE") next bar at market;

if Action = 0 then begin
   if MP > 0 then sell ("fuzzy-LX") next bar at market;
   if MP < 0 then buytocover ("fuzzy-SX") next bar at market;
end;

Load FCL file into PL/EL

Multi-API Formation
{ Configure Fuzzy Control Engine }

vars: model(-1), child(-1);

if model = -1 then begin 
   model = MFLLNewModel();
   MFLLLoadFCLFile(model, "PATH\TO\FCL_FILE");
   child = MFLLNewChild(model);
end;

MFLLSetValue(model,child,0, RSI(C,14)); // input RSI indicator (built-in)
MFLLSetValue(model,child,1, Bias(C,30)); // input Bias indicator (custom)


{ Trading Signal }

vars: Action(0);

Action = MFLLGetOutputValue(model,child);

if MP <> 1 and Action = 1 then buy ("fuzzy-LE") next bar at market; 
if MP <>-1 and Action =-1 then sellshort ("fuzzy-SE") next bar at market;

if Action = 0 then begin
   if MP > 0 then sell ("fuzzy-LX") next bar at market;
   if MP < 0 then buytocover ("fuzzy-SX") next bar at market;
end;
Single-API Formation
Array: double FuzzyInputs[2](0.0);

FuzzyInputs[0] = RSI(C,14); // input RSI indicator (built-in)
FuzzyInputs[1] = Bias(C,30); // input Bias indicator (custom)


{ Trading Signal }

vars: Action(0);

Action = MFLLFuzzyInferenceByFile("PATH\TO\FCL_FILE", FuzzyInputs);

if MP <> 1 and Action = 1 then buy ("fuzzy-LE") next bar at market; 
if MP <>-1 and Action =-1 then sellshort ("fuzzy-SE") next bar at market;

if Action = 0 then begin
   if MP > 0 then sell ("fuzzy-LX") next bar at market;
   if MP < 0 then buytocover ("fuzzy-SX") next bar at market;
end;

see Examples folder to find an example of rsi-and-bias.fcl for FCL_FILE that's just a text file written in FCL.

Copyright

© 2019-present Ming-Kai Jiau.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].