Hello,
I tried Alertif for the first time today, so much to learn...see my attempt below. Complete code should run okay... The alertif I have used sends emails reliably. However, the emails received are always 1 stock less than the list generated in the scan. That is, one buy and one sell signal are always missing. I have set the scan to date range and the start and ends dates to the same date.
have tired many dates...always one sell and one buy missing. TIA Help appreciated.
maxpos = 5; // maximum number of open positions
SetOption("InitialEquity", 100000 ); // set initial equity = 100K
SetOption( "MaxOpenPositions", maxpos );
SetPositionSize( 100 / maxpos, spsPercentOfEquity );
SetOption("AllowSameBarExit", false);
SetOption("AllowPositionShrinking", true);
SetOption("InterestRate", 0);
SetTradeDelays(1,1,0,0);
SetOption("MinPosValue",1000);
//a=Optimize("maup",1.5, 1.5,1.51,.01);
//SetBacktestMode( backtestRegular );
minprice = C > 3;
turnover = C * V > 150000;
enter = BBandBot(c,55,1.25);
exit = BBandBot(c,5,0);
bollidown = RSI(2)<25;
bolliup = RSI(2)>70;
buyif = bollidown
AND minprice
AND turnover
;
sellif = bolliup;
PositionScore = 1/C;
Buy = BUYIF;
Sell = sellif;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Cover=0;
amount = 40; // 10% loss
ApplyStop( stopTypeLoss, stopModePercent, amount, True );
Plot(enter,"Below 55",color=colorred,styleLine);
Plot(exit,"Above 1",color=colorgreen,styleLine);
AlertIf(LastValue(ValueWhen(Status("LastBarInRange"), Buy)), "EMAIL", "Buy " + Name(),1, lookback = 0);
AlertIf(LastValue(ValueWhen(Status("LastBarInRange"), sell)), "EMAIL", "sell " + Name(),2, lookback = 0);