NexusFi: Find Your Edge


Home Menu

 





9.1- 9.5


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Quick Summary with 1 posts (0 thanks)
    2. looks_two ABCTG with 1 posts (0 thanks)
    3. looks_3 Pitrader with 1 posts (0 thanks)
    4. looks_4 eronyx with 1 posts (0 thanks)
    1. trending_up 1,210 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 Pitrader 
Canada
 
Posts: 12 since Feb 2011

I have an indicator that works just fine on ver 9.1 but I get an error when applied to 9.5 or higher. Placed on a 15 second chart to expedite, once the active bar closes I get a 'Vector is empty or invalid index' error. I have the code below. Any help would be appreciated.

 
Code
 using elsystem ; 								
using elsystem.drawingobjects ; 								
using elsystem.drawing ; 								
								
inputs: 								
	BackBars(10), 							
    PtOffsetPoint(0.5), UniqueID("GGG"); 								
	 							
Vars: 								
	ii(0), ptoffset(0), TextLabel BarCounterTxt( NULL ), TextLabel DeleteText(NULL), BNPoint PosBN( NULL ); 							
	 							
Arrays: TXID[100](0);	 							
method void CreateBNLabel(int barcnt) 								
	begin 							
	{ create position for the text label by bar number using the BNPoint class } 							
	PosBN = BNPoint.Create( CurrentBar - barcnt, Low[barcnt]-PtOffsetPoint) ; 							
		 						
	{ create the text label } 							
	BarCounterTxt = TextLabel.Create( PosBN, Numtostr(barcnt+1,0) ) ; 							
	BarCounterTxt.Font = Font.Create( "Arial", 8 ) ; 							
	BarCounterTxt.HStyle = HorizontalStyle.center ; 							
	BarCounterTxt.VStyle = VerticalStyle.top;							
	BarCounterTxt.Color = Color.Red ; 							
	BarCounterTxt.Tag = UniqueID astype string ;							
		 	 					
	BarCounterTxt.Persist = true ; 							
	end ;	 						
								
method void ShowText() 								
	begin 							
		DrawingObjects.Add( BarCounterTxt ) ; 						
	end;							
//Deleting the Old Texts								
method void deleteAllText()  								
Var: int textList, int textCnt,int jj  ;  								
begin  								
    textList = ObjectCategory.TextLabel;   								
    textCnt = DrawingObjects.Items[textList].Count;  								
    if (LastBarOnChart) then   								
    begin  								
        for jj = 0 to TextCnt - 1   								
        begin  								
            DeleteText = DrawingObjects.Items[textList][jj] astype TextLabel;  								
            if (DeleteText <> NULL) and DeleteText.Tag astype string = UniqueID then DrawingObjects.Delete(DeleteText);  								
        end;  								
    end;  								
end;     								
								
	if (LastBarOnChart) and (BarStatus(1)=2) then 							
	begin 		 					
		deleteAllText();						
		for ii = 0 to BackBars -1						
		begin 						
			CreateBNLabel(ii);					
			ShowText();					
		end; 						
	end;


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Using multiple Versions of the same DLL in MC.Net
MultiCharts
The Safety Trade System
Platforms and Indicators
Building models w/Neuroshell and Adaptatrade
Platforms and Indicators
How to look up market depth?
MultiCharts
Ticksandtrades.com
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Algo automated / semi-automated trading anyone?
22 thanks
Statistical Arbitrage trading/market neutral strategies
13 thanks
Any good traders on YouTube?
12 thanks
Tariffs and what comes next...
5 thanks
Daytrading ES & NQ
4 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


Pitrader,

this might be caused by your method that deletes the text, as you loop through elements of the drawing collection and delete elements from it during the loop. This can lead to a situation where you try to access an index that is not longer present in the collection, which would trigger the error.

Regards,

ABCTG


Follow me on X Reply With Quote
  #4 (permalink)
eronyx
Moldova
 
Posts: 9 since Nov 2017
Thanks Given: 6
Thanks Received: 0

Hi

just wondering if you were able to fix the issue? and how it was done


Reply With Quote




Last Updated on April 27, 2020


© 2025 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts