- Joined
- 30 June 2007
- Posts
- 7,200
- Reactions
- 1,226
Chops code returns true or false for the buy line, not a number.
Optimize should be assigned to a variable to make the code more readable.
By the way chops, I know where you're headed with this and there's no edge, unfortunately.
Hi = High > Ref(HHV(High,250),-1);
Lo = Low < Ref(LLV(Low,250),-1);
HiLoDifference = Hi - Lo;
Buy = 0;
AddToComposite(HiLoDifference,"~HiLoDifference","X",atcFlagDefaults = 7);
NHNL = Foreign("~HiLoDifference","C",True);
Plot(NHNL, "New high new low index", colorGreen,styleLine);
I'm trying to create composite index but every time I got error after validating the code in AmiBroker 6.00 for the line 5:
"Error 55. Invalid assignment. The identifier is read-only (constant) and can not be written to."
Code:Hi = High > Ref(HHV(High,250),-1); Lo = Low < Ref(LLV(Low,250),-1); HiLoDifference = Hi - Lo; Buy = 0; AddToComposite(HiLoDifference,"~HiLoDifference","X",atcFlagDefaults = 7); NHNL = Foreign("~HiLoDifference","C",True); Plot(NHNL, "New high new low index", colorGreen,styleLine);
What is interesting I did everything as on tutorial:
https://www.youtube.com/watch?v=nGiRNbOOjlA
I suppose that something has changed in the newest versions of AmiBroker but not sure.
printf( "The type of atcFlagDefaults is: " + typeof( atcFlagDefaults ) );
printf( "\natcFlagDefaults returns following value: %g", atcFlagDefaults );
AddToComposite(HiLoDifference,"~HiLoDifference","X", atcFlagDefaults);
AddToComposite(HiLoDifference,"~HiLoDifference","X", 7);
AddToComposite(HiLoDifference,"~HiLoDifference","X", flag = 7);
AddToComposite(HiLoDifference,"~HiLoDifference","X", flag = atcFlagDefaults);
AddToComposite(HiLoDifference,"~HiLoDifference","X", flag7 = 7);
There has nothing changed.
atcFlagDefaults = Close;
Also my previous post was not precious enough.
SetBacktestMode( backtestRegularRaw );
SetOption("MaxOpenPositions", 100 );
SetTradeDelays(0,0,0,0);
FixedDollarAmount = 10000;
PositionSize = FixedDollarAmount;
MonthBegin = Month() != Ref( Month(), -1 );
FirstPurchase = Cum( MonthBegin ) == 1;
Buy = IIf( MonthBegin, sigScaleIn, 0 ); // each month increase position
Sell = 0; // we do not sell
BuyPrice=SellPrice = O;
I would like to create DCA (Dollar Cost Average) simple test to buy first trading day of month index for fixed
edited
SetBacktestMode( backtestRegularRaw );
SetOption("MaxOpenPositions", 100 );
SetTradeDelays(0,0,0,0);
SetOption("InitialEquity", 200000 ); //<<
//FixedDollarAmount = 10000;
PositionSize = 10000;// can also use Positionsize = -10 ie. 1/10th of available capital
MonthBegin = Month() != Ref( Month(), -1 );
FirstPurchase = Cum( MonthBegin ) == 1;
Buy = IIf( MonthBegin, sigScaleIn, 0 ); // each month increase position
Sell = 0; // we do not sell
BuyPrice=SellPrice = O;
Thanks a lot. Now I've noticed in detailed log that transactions were made in correct days. I was misguided by that there was present in "Trade list" view only one record but in "Detailed log" there is information about every trade.I see.
Try Settings>report>detailed log to see where the money is going.
Thanks a lot. Now I've noticed in detailed log that transactions were made in correct days. I was misguided by that there was present in "Trade list" view only one record but in "Detailed log" there is information about every trade.
https://www.amibroker.com/guide/h_debugger.html
Using _trace/tracef:
https://www.amibroker.com/guide/w_log.html
https://technet.microsoft.com/en-us/sysinternals/debugview.aspx
http://www.amibroker.org/userkb/ (topic "8.1. Debugging AFL")
Using printf:
https://www.amibroker.com/guide/h_interpret.html
Using Explorer
http://www.amibroker.com/kb/2014/09/29/debugging-techniques-part-1-exploration/
Functions
https://www.amibroker.com/guide/afl/_trace.html
https://www.amibroker.com/guide/afl/_tracef.html
https://www.amibroker.com/guide/afl/_printf.html
etc.
Correcting last link
https://www.amibroker.com/guide/afl/printf.html
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?