I'm really sorry to bother you because what's happening to me is really weird and I don't know if someone is going to know how to help me, but I had to try.
I'm using an exploration what it looks is that the explorer changes de quotation of the stocks.
I enclose a screen video where you can see that the current close (Cierre actual) for CC is 40,04. It gets updates to 40,8 and when I explore it two times it changes back to 40,04.
It's a daily system. I enclose as well the system code.
If anyone has a hint where I should look or what is wrong, I'd be very glad!
Thanks and have a good sunday!
/* PART 1 - VARIABLES */ Margin = 0; // 1 = 50% margin, 0 = cash PositionsHeld = OPTIMIZE("Positions", 10,5,20,1);; // Maximum number of simultaneously open positions OwnCapital = 100000; // Initial capital AllocationPercent = IIf(Margin==1,(1/PositionsHeld)*200,(1/PositionsHeld)*100); /* PART 2 - BACKTESTER SETTINGS */ SetBacktestMode(backtestRegularRaw); // Backtest mode - raw used so that Amibroker doesn't automatically filter out excessive signals SetPositionSize(AllocationPercent, spsPercentOfEquity); // Allocation per position, using the allocationpercent variable calculated in part 1 SetOption("InitialEquity",OwnCapital); // Initial capital, using OwnCapital variable from part 1 SetOption("AllowSameBarExit",False); // Disable same bar exit as the strategy exits at open of the following day SetOption("AccountMargin",IIf(Margin==1,50,100)); // Margin - using the Margin switch from part 1 SetOption("maxopenpositions",PositionsHeld); // Maximum number of simultaneously open positions using the variable from part 1 SetOption("UsePrevBarEquityForPosSizing",True); // Equity value as of close of previous bar is used to calculate position size SetOption("usecustombacktestproc", True); // CBT needs to be enabled to handle the limit order entries - part 8 of the code SetTradeDelays(0,1,0,0); // Sell delay set to 1 to allow for exiting the positions at the open of the following day RoundLotSize = 1; // Round the share quantity to whole numbers /* PART 3 - PRICE CHANNEL FILTER */ ChannelHigh = HHV(H,50); // Channel high variable - taking the highest high value of N days ChannelLow = LLV(L,10); // Channel low variable - taking the lowest low value of N days ChannelBOwindow = 5; // Channel breakout window - how many bars since channel breakout are we still looking to enter ChannelBreakout = C > Ref(ChannelHigh,-1); // Definition of channel breakout - price CLOSES above the channel high Diff = (ChannelHigh - ChannelLow) / 4; // Difference between channel high and low, divided by X BuyZone = ChannelLow + (Diff * 2); // Buyzone - used to filter out non-trending stocks that do not show sufficient momentum, using Diff multiplied by X /* PART 4 - BUY SETUP AND RANKING */ FechaInicio=10000 * (2021 - 1900) + 100 * 12 + 31; BuySetup= ROC(C,1) < - 2 // Closing price decreased by at least 2 percent AND C > BuyZone // Closing price is in the BuyZone AND BarsSince(ChannelBreakout) < ChannelBOwindow // Channel breakout took place within the specified time window prior to the signal AND Close > 1 ; // Check if closing price is greater than 5; this is to filter out stocks that are too cheap to control the trading commissions //AND IIf(DateNum()<Fechainicio,valida_y_dentro,IIF( InWatchListName("S&P 500"), 1 , 0 )); // Pertenece al índice PositionScore = -Ref(ROC(C,5),-1) ; // Signal ranking - greater the decrease in the closing price, the better; using previous bar's value as entering following day with limit order /* PART 5 - LIMIT PRICE AND EXIT SETUP */ ATRvariable = ATR(5); // ATR used in calculation of the limit price and a stop-loss ATRMultiple = 1; // Multiple of ATR used in calculation of the limit price LimitPrice = IIf(Ref(BuySetup,-1),Ref(L,-1)-(Ref(ATRvariable,-1) * ATRMultiple),Null); // If BuySetup at previous bar, set the limit price calculated from low of the previous bar, using ATR and its multiple, if no BuySetup set to null ExitSignal = C > O; // Sell signal definition - signal generated on first up bar following the entry /* PART 6 - BUY LIMIT FILL */ Buy = Ref(BuySetup,-1); // Buy signal gets activated if a valid BuySetup got generated at the previous bar BuyPrice = Close; // Buyprice provisionally set to either bar's open on our limit price (which ever is lower) - however we do not yet know if the limit price actually gets filled (handled via CBT) LimitBuy = Buy AND Low < LimitPrice; // Final limit buy simulation - valid buy signal at previous bar and low of the current bar lower than our limit price; however not taking the maximum open position count into the account (handled via CBT) LimitBuy = ExRem(LimitBuy,ExitSignal); // LimitBuy var restated using ExRem - this filters out excessive LimitBuy signals after the first one has been taken /* PART 7 - STOP-LOSS AND EXIT */ ATRatEntry = ValueWhen(LimitBuy,Ref(ATRvariable,-1)); // Take the ATR's value at the point of LimitBuy (as of previous bar's close) to be used to calculate the stop-loss StopLoss = ValueWhen(LimitBuy,BuyPrice) - ATRatEntry; // Set the stop-loss price at the point of LimitBuy - deduct the ATRatEntry from the buyprice Sell = ExitSignal ; SellPrice = Close; // Sellprice set to open, as trades are closed at the open of the following day bars = 3; // exit after 10 bars /* PART 9 - EXPLORER CODE */ Nombre=FullName();// añadido por EJ Filter = BuySetup; AddTextColumn(Nombre,"Nombre",1.2);// añadido por EJ AddTextColumn( GetFnData( "Alias" ), "ISIN"); AddColumn(Ref(C,-1),"Cierre Anterior",1.2); AddColumn(C,"Cierre Actual",1.2); AddColumn(ROC(C,1),"Cambio",1.2); AddColumn(L-(ATRvariable * ATRMultiple),"Precio Límite",1.2); AddColumn(L-(ATRvariable * ATRMultiple) - ATRvariable,"Stop Loss",1.2); AddColumn(ATR(5)/(L-(ATRvariable * ATRMultiple) - ATRvariable)*100,"% Stop Loss",1.2);// añadido por EJ AddColumn(((C-(L-(ATRvariable * ATRMultiple)))/C)*100,"Distancia Entrada",1.2);// añadido por EJ if ( Status( "action" ) == actionExplore ) SetSortColumns(-2,7); // sort for Exploration only if ( Status( "action" ) == actionBacktest ) SetSortColumns(-5 ); // sort for Backtest only