Genetic Algorithm "WindowSize" Error Message
조회 수: 6 (최근 30일)
이전 댓글 표시
Greetings,
I'm trying for the first time to run a genetic algorithm optimization for an algorithmic trading university project. My fitness function returns a negative sharpe-ratio, and the goal is to find the best set of parameters that minimize the negative sharpe ratio. I have 4 decision parameters. When I try to run the optimization, I get the error message:
"The value of 'WindowSize' is invalid. Expected %K Periods to be integer-valued". Unfortunately, i do not understand the error message, I already searched in Google but did not find a similar problem. I have attached a screenshot with the Error Message. Other than defining the number of variables and the constraints, I have not made any changes to the default settings.
Below you find my objective function. The objective function seems to work properly. I used 2 nestled function I created called "leadlag" and "rsi_strat" which generate trading signals that are either 1 or -1. Any help is greatly appreciated!!!
%%MA + RSI strategy
function[sh]=marsi(decision)
%import Open, High Low Close data
load('data.mat')
%get Closing Prices
Close=data(:,1);
lead=decision(1); % define shorter Moving Average
lag=lead+decision(2); % define longer Moving Average
thresh=decision(3); % define threshhold for Relative strengh Index
frame=decision(4); % define lookbackwindow for Relative strengh Index
%creates trading signal based on moving averages
[sig1,~,~]=leadlag(Close,lead,lag);
%creates trading signal based on RSI
[sig2,~,~]=rsi_strat(Close,thresh,frame);
s=(sig1+sig2)/2; %creates new trading signal if previous signals are equal
r = [0; s(1:end-1).*diff(Close)]; %calculates returns from strategy
sh = -sqrt(250)*sharpe(r,0); % calculates negative sharpe ratio
댓글 수: 2
Alan Weiss
2020년 1월 10일
Please show us your ga call and any options that you set.
Alan Weiss
MATLAB mathematical toolbox documentation
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!