Well it seems to work on an index but not on a basket of ETFs. Strange....
If it does not work for you you may upload an APX file (analysis project file).
And what list of ETFs are you applying it to.
Well it seems to work on an index but not on a basket of ETFs. Strange....
If it does not work for you you may upload an APX file (analysis project file).
Back to time periodicy...
I am now trying to find every fortnight. The code below when plotted does the job fine, however when put into a trading system no trades are taken. I don't know why.
Code:// Days of the week timeDayName = DayOfWeek(); // Every Friday checkEndWeek = timeDayName < Ref( timeDayName, -1 ); // Every fortnight checkEndWeekCount = Cum( checkEndWeek ); checkEndFortnight = checkEndWeek AND ( checkEndWeekCount % 2 == 0 );
This is for a rotational trading system and after running the backtest with detailed log it shows scoring weekly but no trades are taken which is a clue I guess. Any help appreciated.
And what list of ETFs are you applying it to.
I think you are getting what you want, but just so you know that you are identifying Monday or the Start of the Week not the "EndWeek" or end of a week (usually a Friday). Your variables are all named "End...." implying to me at least a Friday or end of a week.
Ok next question...
My version of AmiBroker is 6.00.2 and doesn't have the option to do Monte Carlo Simulations using daily equity. Is this a feature in newer releases? See link below for what I am talking about.
https://www.amibroker.com/guide/h_montecarlo.html
// Bar counter
bars = 0;
for( i = 0; i < BarCount; i++ )
{
if( bars > 0 ) bars[i++];
if( Buy ) bars= 1;
if( Sell ) bars= 0;
}
Why is my bar counter not working?
Code:// Bar counter bars = 0; for( i = 0; i < BarCount; i++ ) { if( bars > 0 ) bars[i++]; if( Buy ) bars= 1; if( Sell ) bars= 0; }
I only want to count bars while I'm in a trade.
Why is my bar counter not working?
Code:// Bar counter bars = 0; for( i = 0; i < BarCount; i++ ) { if( bars > 0 ) bars[i++]; if( Buy ) bars= 1; if( Sell ) bars= 0; }
I only want to count bars while I'm in a trade.
barsarr[i] = bars;
You code is not correct that's why it is not working.
First of all Buy and Sell variables are arrays! You need to use subscript operator in order to access elements of an array.
Secondly use flag initialized to false:
if buy then flag is set to true, if sell flag is set to false.
If sell the reset bars counter.
In addition add if statement checking for true flag and where you count bars in trade;
last but not least create barsarr variable to store bars counter at each array index.
Code:barsarr[i] = bars;
The next thing is: you don't need loop as you can make bar counter with existing functions Flip() and BarsSince().
By that one it is meant like thisIn addition add if statement checking for true flag and where you count bars in trade;
if( flag )
bars++;
Looping.
Need someone to step me through it with explanations. Can't seem to follow the tutorials.
Yeh he did thanks - a PDF. That's what I'm having difficulty with.Didn't Great Pig put out some great info on looping some years ago? Will have to go digging....
What do you want to achieve?
What do you want to achieve?
Is you loop problem solved actually? If you are just waiting for copy&paste ready codes then Portfoliobuilder and me will save our time responding next time.
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.