Posted By: danatrader
trainroutine return & store / reuse - 02/02/20 14:27
Hi,
I try to establish a subroutine / function that measures market cycle length in train mode.
Already somwhat working.
So I call the following:
The function itself contains the following:
Now the question is, how to store the return value global and make it available for
???
I try to establish a subroutine / function that measures market cycle length in train mode.
Already somwhat working.
So I call the following:
Code
// double portfolio loop while(asset(loop("EUR/USD"))) if(Train){ traincycles(); } while(algo(loop("TRND"))) { Margin = 0.5 * OptimalF * Capital; if(Algo == "TRND") tradeTrend();
The function itself contains the following:
Code
function traincycles() { vars Prices = series(priceClose()); int Cycle = optimize(10, 1, 55, 1); int CycleFast = optimize(10, 1, Cycle, 1); int TrendCycle = (Cycle+CycleFast)/2; vars Signals = series(ReFlex(Prices,Cycle)); vars SignalsFast = series(ReFlex(Prices,CycleFast)); //Good Cycle Train Algo II if(SignalsFast[0] > 0 && Signals[0] > 0) enterShort(); if(SignalsFast[0] < 0 && Signals[0] < 0) enterLong(); return(TrendCycle); }
Now the question is, how to store the return value global and make it available for
Code
while(algo(loop("TRND"))) { Margin = 0.5 * OptimalF * Capital; if(Algo == "TRND") tradeTrend();
???