Hi, how do I use CBT to specify the entry and exit price of a trade, and ignore the built in buyprice/sellprice variables?
Buy = Sell = Short = Cover = 0;
BuyPrice = SellPrice = ShortPrice = CoverPrice = O;
// Only 1 trade for this symbol
Buy[BarCount-2] = 1;
Sell[BarCount-1] = 1;
if (Status("action") == actionPortfolio)
//trade entryprice = 100;
//trade exit price = 200;
//so trade profit would be 100%;
It was explained dozens of times already, that by default AmiBroker protects users from trading using abstract prices. All trade prices must be inside High-Low range of given bar.
This feature is called Price bound checking and it is turned ON by default.
To switch that off you have to use SetOption
It is HIGHLY DISCOURAGED to do so because you would get non-sense results (not reproducible in real life)
Thank you, I understand all that - and know it will give non-real life results.
My question was is it possible to programmatically artificially set the entry and exit price via the CBT?
You just assign new prices to BuyPrice, SellPrice, ShortPrice, CoverPrice.
It works exactly the same regardless if you are using CBT or not.
If you want to set prices outside H-L range you have to call SetOption("PriceBoundChecking", False);
Thank you for that Tomasz