Hi guys, how are things?
I was running some optimize backtests with the follow code in a watchlist to see all the possible scenarios:
step = Optimize( "step", 1, 1, 50000, 1 );
PositionScore = mtRandom();
Then I changed the code to:
step = Optimize( "step", 1, 1, 50000, 1 );
PositionScore = Random();
The results using "Random" is far larger and have more results and possible scenarios compared to "mtRandom".
What am I missing? Why mtRandom brings fewer results?
Thanks!!
nsm51
#2
You full code is not known but
Random() returns an Array
while mtRandom() is Scalar.
Therefore, the PositionScore variable which should ideally be an Array is getting affected with no score.
You can try with mtRandomA()
1 Like
Hey there.
Here is my code
PosQty = 1;
SetOption("MaxOpenPositions", PosQty );
PositionSize = -100/PosQty;
SetOption("ActivateStopsImmediately", 0);
SetOption("AllowSameBarExit", 0);
SetOption("SettlementDelay", 1);
BuyLimitPrice = Ref(L, -1);
BuySignal = L<=BuyLimitPrice;
Buy = BuySignal;
BuyPrice = Min(Open, BuyLimitPrice);
// define profit level
PriceHighest = Ref(HHV(H, 2), -1);// use previous 2 bars high
Sell = H >= PriceHighest;
TickSize = 0.01;
// n-bar stop
ApplyStop(stopTypeNBar, stopModeBars, bars=3, priority=0, 0, reentry_delay=0);
// profit stop at next bar after Buy
ApplyStop(stopTypeProfit, stopModePoint, TickSize, exitatstop=0, 0, reentry_delay=0, valid_from = 1, valid_to = 2);
regular_exit = Sell == 1;
SellPrice = IIf(regular_exit, Max(Open,PriceHighest), Close);
My code is very simple. I am still studing about coding and amibroker. Is a new wolrd.
Using your sugestion, it worked! I got the same result when using mtRandomA() and Random(). Thanks!!!
system
Closed
#4
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.