ApplyStop on same daily bar as entry

/// This sets up the bars on the chart
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

// This sets up the styles for the indicators
HHighPrice = ParamField("HHighPrice",1);
HHfastcolor = ParamColor("HHfastcolor", colorAqua );
FastStyle = ParamStyle("FastStyle", styleDashed | styleNoLabel);

//Default Settings
HH_lookback = 252;
HH_FilterNumDays = 3;
HH_TicksAbove = 1; 
ATR_lookback = 5;
ATR_StopMulti = 1;

//To Optimize use these
//HH_lookback = optimize( "HH_lookback", 252, 252, 252, 2 );
//HH_FilterNumDays = optimize( "HH_FilterNumDays", 3, 3, 3, 1 );
//HH_TicksAbove = optimize( "HH_TicksAbove", 1, 1, 1, 1 );
//ATR_lookback = optimize( "ATR_lookback", 5, 5, 5, 1 );
//ATR_StopMulti = optimize( "ATR_StopMulti", 2, 2, 2, 1 );

//Plot the HighestHigh of HH_lookback bars back
HH = hhv( High, HH_lookback);
Plot(HH,"HH",HHfastcolor,FastStyle);
printf( "ref(HH,-1): " + NumToStr( ref(HH,-1) ) + "\n" ); 

HHbarsAgo = BarsSince(Ref(HH,0) > Ref(HH,-1));
printf( "HHbarsAgo: " + NumToStr( HHbarsAgo ) + "\n" ); 

myATR = ATR(ATR_lookback);  
printf( "myATR: " + NumToStr( myATR ) + "\n" ); 

//// Strategy buy/sell signals  //////////////////////////
SetBacktestMode(backtestRegular);
//SetOption("InitialEquity",100000 );
SetOption("AllowSameBarExit",true);
SetTradeDelays(0,0,0,0);
//SetOption("MaxOpenPositions",100000);


EntryQty = 1000 / Close;
SetPositionSize( EntryQty, spsShares ); 

BuyPrice = Max(Ref(HH,-1) + .01 * HH_TicksAbove, Open);
SellPrice = Open ;

Buy = High >= Ref(HH,-1) + .01 * HH_TicksAbove AND Ref(HHbarsAgo,-1) >= HH_FilterNumDays;
Sell = open;

buy = ExRem( buy, sell );
sell = ExRem( sell, buy ); 

ApplyStop(stopTypeLoss,stopModePoint,ATR_StopMulti * myATR,0,0,0); 
//ApplyStop(stopTypeNBar,stopModeBars,nBars,0,True);
//ApplyStop(stopTypeProfit,stopModePoint,Ref(PSL,-1),1,False,0); 
//ApplyStop(stopTypeTrailing,stopModePoint,Ref(TSL,-1),1,False,0); 

Equity(1); // THIS EVALUATES STOPS
Plot(Sell==4,"ApplyStop Sell",colorRed,1|styleOwnScale);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue,  0, BuyPrice, Offset=-15); 
PlotShapes(IIf(sell, shapeDownArrow, shapeNone),colorWhite, 0, SellPrice, Offset=-15);

Capture

No matter what I do, I cannot get the stop to exit on the same day as the entry. See this snapshot:

See how the stop is always one day later. I've read about:
SetOption("AllowSameBarExit",true);
SetTradeDelays(0,0,0,0);
ApplyStop(stopTypeLoss,stopModePoint,ATR_StopMulti * myATR,0,0,0);

but no matter what combinations of these I try it always exits on the next day.

You really have to read the manual: http://www.amibroker.com/guide/afl/applystop.html

Read "SCENARIOS" in ApplyStop docs.

ApplyStop have separate option called "ActivateStopsImmediately" that causes them to trigger same bar.

I did read this page in the manual, and this part is very confusing to me. In the scenarios you talk about ActivateStopsImmediately, but no where above scenarios, nor in it do you show how to do that, nor give an example. I am still unclear as to how to enable ActivateStopsImmediately. Please show me an example.

One way is go to analysis / settings / stops and check Activate Stops immediately.

Also, I went to the help file and did a search on activatestopsimmediately and information and examples
were provided.

thank you. I will try again

well, I don't know why it was so difficult to get someone to simply say this is what needed to be added to the code:

SetOption("ActivateStopsImmediately", True );

Because as old saying goes: "give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime"

Code is a fish. Ability to search and read the documentation with understanding is a rod.

It is good to have former tradestation users here. He is not a beginner but just doing his best to learn Amibroker in a very short time. Some people have 20 questions in one years and some have the same in one week. Maybe you could have a premium support, sometimes that could pay very well. There are probably users without a valid license asking more stupid questions. I had similar questions with a tradestation background.