Loop in strategy

Questions about MultiCharts and user contributed studies.
Drogo
Posts: 14
Joined: 11 Oct 2012
Has thanked: 2 times

Loop in strategy

Postby Drogo » 11 Aug 2014

Hi I Use loop in strategy to compare prices aprox. 500 bars back. In side loop I make decision to make an order.
Problem is that the strategy works live or if i use playback. It is not possible to do backtest.

Example:

Code: Select all

Vars: BuySignal(false), Counter1(0), Counter2(0);
Array: arrnumber1[64](0), arrnumber2[20](0),
// I have some numbers in arrays

For Counter1 = 0 to 63
begin
For counter2 = 0 to 19
begin
If low = open + arrnumber1[Counter1] / arrnumber2[counter2] then BuySignal = true else BuySignal = false;
end;
end;

If BuySignal and marketposition = 0 then
begin
buy next bar at market;
BuySignal = false;
End;


setstoploss(1000);
setprofittarget(1000);
Is there any solution how to do backtest or rewrite the code?
Thank You.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Loop in strategy

Postby Henry MultiСharts » 12 Aug 2014

Hello Drogo,

What do you mean exactly by "It is not possible to do backtest"? Do you get any message?

Drogo
Posts: 14
Joined: 11 Oct 2012
Has thanked: 2 times

Re: Loop in strategy

Postby Drogo » 12 Aug 2014

Hello Henry,

There is not any message. Optimization process works, but the Optimization report is empty(full of zeros).

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Loop in strategy

Postby Henry MultiСharts » 13 Aug 2014

Hello Henry,

There is not any message. Optimization process works, but the Optimization report is empty(full of zeros).
Please validate your code conditions. You can find a debugging logic example here.


Return to “MultiCharts”