Welcome to the Traders Laboratory.

Coding Forum Collaborate, receive help, or discuss indicators and other coding-related topics

Reply
Old 10-07-2011, 03:27 PM   #41

Join Date: Dec 2010
Posts: 110
Ignore this user

Thanks: 3
Thanked 7 Times in 7 Posts

Re: Array (EasyLanguage)

Tradewinds thanks for your replay,
when do we intrabar dont' we get the same results?
COuld you explain more please?
bomberone1 is offline  
Reply With Quote
Old 10-07-2011, 03:56 PM   #42

Tradewinds's Avatar

Join Date: Nov 2008
Posts: 910
Ignore this user

Thanks: 379
Thanked 257 Times in 178 Posts

Re: Array (EasyLanguage)

Quote:
Originally Posted by bomberone1 »
Tradewinds thanks for your replay,
when do we intrabar dont' we get the same results?
COuld you explain more please?
I'll try to address your question on this thread:

Traders Lab - Intrabar Price Behavior
Tradewinds is offline  
Reply With Quote
Old 11-26-2011, 09:57 PM   #43

Tradewinds's Avatar

Join Date: Nov 2008
Posts: 910
Ignore this user

Thanks: 379
Thanked 257 Times in 178 Posts

Re: Array (EasyLanguage)

EasyLanguage now has Object Oriented Arrays. EL (EasyLanguage) calls the arrays VECTOR Arrays. Actually, EL OO has something called "Collections", which are a collection of data. There are 5 different types of Collections.

The answer to the traditional Array in EL OO is a VECTOR. But a VECTOR array can access a particular element in the array. Here are the methods that can be used in a VECTOR array.

Quote:
Create Initializes a new instance of the Vector class.
At(indx) Accesses an element at the specified position in the collection.
Back Accesses the last element of the collection.
Clear Removes all elements from the collection.
Empty True if there are no elements in the collection, otherwise false.
Erase(indx) Removes an element at the specified position.
Erase(indx1,indx2) Removes the elements in the specified range of index positions.
Front Accesses the first element of the collection.
Insert(indx,obj) Adds an element (obj) before the specified index.
Insert(indx,count,obj) Adds an element (obj) repeatedly before the specified position with the given count.
Pop_back Removes the last element from the collection.
Push_back(obj) Adds a new element (obj) to the end of the collection.
This code creates two vector ARRAYs. The code inside the METHOD subroutine only runs when an order is updated. It is an Event Driven subroutine. The event is the order status changing, for example, the order goes from Sending to Sent, or Sent to Received, or from Received to Filled, or From Filled to Closed out. This Method subroutine keeps track of unfilled Buys and Sells.

Code:
var: Vector UnFilledSells( NULL ), UnFilledBuys( NULL );

method void OP1_Updated( elsystem.Object sender, tsdata.trading.OrderUpdatedEventArgs args ) 

	var: int iCount, int TheState, int QtyUnfilled, int BuyOrSell,
 		string OrdrNum, bool ItsInThere, int SellsCount, int BuysCount;

begin

Once Begin  // If the vector is created more than once, it deletes all the elements
	UnFilledSells = new Vector;  // Create the new array.
	UnFilledBuys = new Vector; 
	End;

	TheState = args.State; // Get the state of the current order
	if OP1.Orders.Count > 0 then QtyUnfilled = OP1[0].LeftQuantity else QtyUnfilled = 0;
	OrdrNum = args.OrderID;  // Get the order number of the order that was just updated
	
	if StrLen(OrdrNum) > 0 then BuyOrSell = OP1[OrdrNum].Action else BuyOrSell = 0;  // Buy = 1 Sell = 2
	
	//print(file("c:\VctrArry.txt"), "Prn1 ", "array lngth=", UnFilledSells.Count:0:0, "   |   Order Num=", OrdrNum, "   State=", TheState:0:0, "   |  Qty Entered=", QtyUnfilled:0:0, "   |   Time=", Formattime("hh:mm:ss", TradeTimeEx));

	If UnFilledSells.empty() = False then  // If the array is NOT empty, get the count of how many records
		SellsCount = UnFilledSells.Count else SellsCount = 0;  // Get  how many records are in the array
	
	If UnFilledBuys.empty() = False then  // If the array is NOT empty, get the count of how many records
		BuysCount = UnFilledBuys.Count else BuysCount = 0;  // Get  how many records are in the array
	
	ItsInThere = False;
	
	If SellsCount > 0 and BuyOrSell = 2 then begin
		For iCount = 0 to UnFilledSells.Count - 1 begin // Loop through all the orders in the array
			If UnFilledSells.at(iCount) astype string = OrdrNum then // Check if current order number is in the array
			ItsInThere = True;
		End;
	End;
	
	If BuysCount > 0 and BuyOrSell = 1 then begin
		For iCount = 0 to UnFilledBuys.Count - 1 begin // Loop through all the orders in the array
			If UnFilledBuys.at(iCount) astype string = OrdrNum then // Check if current order number is in the array
			ItsInThere = True;
		end;
	End;
	
	// If the array is empty, just add the order
	If (TheState = 4 or TheState = 2) and SellsCount = 0 and BuyOrSell = 2 then begin
		// If it's a SELL order, and the array is empty, then add a new element to the SELL array
		UnFilledSells.insert(0, OrdrNum);  // If state is received, sent or sending and it's not in the array, add it
		UnfilledSellOrdrs = UnFilledSells.Count;
		//print(file("c:\VctrArry.txt"), "Prn2 ", "array lngth=", UnFilledSells.Count:0:0, "   |   Order Num=", OrdrNum, "   State=", TheState:0:0, "   |  Qty Entered=", QtyUnfilled:0:0, "   |   Time=", Formattime("hh:mm:ss", TradeTimeEx), Newline);
		Return; // If the order number needed to be added to the arry, then your done.  Quit here.
	End;

	If (TheState = 4 or TheState = 2) and BuysCount = 0 and BuyOrSell = 1 then begin
		UnFilledBuys.insert(0, OrdrNum);  // If state is received, sent or sending and it's not in the array, add it
		UnfilledBuyOrdrs = UnFilledBuys.Count;
		//print(file("c:\VctrArry.txt"), "Prn2 ", "array lngth=", UnFilledSells.Count:0:0, "   |   Order Num=", OrdrNum, "   State=", TheState:0:0, "   |  Qty Entered=", QtyUnfilled:0:0, "   |   Time=", Formattime("hh:mm:ss", TradeTimeEx), Newline);
		Return; // If the order number needed to be added to the arry, then your done.  Quit here.
	End;	

	If TheState <> 4 and TheState <> 2 and BuyOrSell = 2 and ItsInThere = True then begin // If order status is anything buy sent or received
		For iCount = 0 to UnFilledSells.Count - 1 begin // Loop through all the orders in the array
			If UnFilledSells.at(iCount) astype string = OrdrNum then begin // Check if current order number is in the array
				ItsInThere = True; // The order number was found in the array
			 	// If the order in the vector has any status but 4, then delete the record
				UnFilledSells.erase(iCount);  // If it's not a status of Received, then it's been filled, or canceled, etc
				UnfilledSellOrdrs = UnFilledSells.Count;
				Return;
			End;
		End;
	End;
		
	If TheState <> 4 and TheState <> 2 and BuyOrSell = 1 and ItsInThere = True then begin
		For iCount = 0 to UnFilledBuys.Count - 1 begin // Loop through all the orders in the array
			If UnFilledBuys.at(iCount) astype string = OrdrNum then begin // Check if current order number is in the array
				ItsInThere = True; // The order number was found in the array
			 	// If the order in the vector has any status but 4, then delete the record
				UnFilledBuys.erase(iCount);  // If it's not a status of Received, then it's been filled, or canceled, etc
				UnfilledBuyOrdrs = UnFilledBuys.Count;
				Return;
			End;
		End;
	End;

	If (TheState = 4 or TheState = 2) and BuyOrSell = 2 and ItsInThere = False then begin // if the order number is not in the array
		UnFilledSells.insert(0, OrdrNum);  // If state is received or sending and it's not in the array, add it
		UnfilledSellOrdrs = UnFilledSells.Count;
		//print(file("c:\VctrArry.txt"), "Prn4 ", "array lngth=", UnFilledSells.Count:0:0, "   |   Order Num=", OrdrNum, "   State=", TheState:0:0, "   |  Qty Entered=", QtyUnfilled:0:0, "   |   Time=", Formattime("hh:mm:ss", TradeTimeEx), Newline);
		Return;  // Return is not needed in a VOID method, but useful to control when the execution is stopped.
	End;
			
	if (TheState = 4 or TheState = 2) and BuyOrSell = 1 and ItsInThere = False then begin
		UnFilledBuys.insert(0, OrdrNum);  // If state is received or sending and it's not in the array, add it
		UnfilledBuyOrdrs = UnFilledBuys.Count;
		//print(file("c:\VctrArry.txt"), "Prn4 ", "array lngth=", UnFilledSells.Count:0:0, "   |   Order Num=", OrdrNum, "   State=", TheState:0:0, "   |  Qty Entered=", QtyUnfilled:0:0, "   |   Time=", Formattime("hh:mm:ss", TradeTimeEx), Newline);
		Return;  // Return is not needed in a VOID method, but useful to control when the execution is stopped.
	End;

End;
Tradewinds is offline  
Reply With Quote
The Following User Says Thank You to Tradewinds For This Useful Post:
tradingbigboy (04-19-2016)
Old 01-26-2012, 10:25 AM   #44

Join Date: Dec 2010
Posts: 110
Ignore this user

Thanks: 3
Thanked 7 Times in 7 Posts

Re: Array (EasyLanguage)

Quote:
Originally Posted by Tradewinds »
If you want to compare the high of the current bar at one point in time, to the high of the current bar at another point in time, you can only do that with an array. For example, if you wanted to compare the high of the price bar when your indicator crossed a threshold, and then compare the high of the price bar when the indicator started in a new direction, and that all happened on the same price bar, you would need to store the value of the high of the bar when the indicator crossed the threshold, then capture the value of the high of the price bar when the indicator started moving the other direction, then retrieve those two values from the array in order to compare them.
COuld code this example by normal easylanguage and not OOO.
bomberone1 is offline  
Reply With Quote
Old 01-26-2012, 11:45 AM   #45

Tradewinds's Avatar

Join Date: Nov 2008
Posts: 910
Ignore this user

Thanks: 379
Thanked 257 Times in 178 Posts

Re: Array (EasyLanguage)

Quote:
Originally Posted by bomberone1 »
COuld code this example by normal easylanguage and not OOO.
Regular EL also has an array. I have not used the regular array. There is probably multiple ways to compare intrabar values to each other. The time could be recorded and compared.
EL has something called 'intrabarpersist'. I find it confusing and a pain. Intrabarpersist variables will hold intrabar values differently than regular variables.

Do you have an example of how to do this with regular easylanguage?

Unfortunately I can't edit my post that you are referring to. I'd change the wording, but I can't now. I stated that there was only one way to do something, but I'm sure that isn't true.
Tradewinds is offline  
Reply With Quote
Old 02-27-2013, 12:34 AM   #46

Join Date: Aug 2011
Posts: 116
Ignore this user

Thanks: 128
Thanked 32 Times in 27 Posts

Array (EasyLanguage)

Tradewinds your code did not verify. Can you post the eld or the verified code?
johnnydaymon is offline  
Reply With Quote
Old 04-19-2016, 02:28 PM   #47

Join Date: Nov 2011
Posts: 5
Ignore this user

Thanks: 4
Thanked 0 Times in 0 Posts

Re: Array (EasyLanguage)

Tradewinds,

So is a vector available to different windows such that an indicator's vector values are also available to a strategy? Or is this dependent on making the values of the method global dictionary values?
Thanks,
TBB
tradingbigboy is offline  
Reply With Quote

Reply

Tags
array, easylanguage

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
Buy at Open with Easylanguage cleon Coding Forum 5 03-02-2011 11:16 AM
Antonio: Please help me on MP for easylanguage nasdaq5048 Market Profile 13 09-23-2010 09:50 AM
Can function in TS8 return array? ImXotep Technical Analysis 5 05-25-2009 02:13 AM
MT4 Indicator Array Problem. ForexSurfr Coding Forum 0 02-16-2009 12:19 PM
Some EasyLanguage Help Please jjthetrader Coding Forum 8 06-02-2008 04:20 PM

All times are GMT -4. The time now is 12:28 AM.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.