NexusFi: Find Your Edge


Home Menu

 





How to determine the time of the current variable and the previous one.


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,340 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

How to determine the time of the current variable and the previous one.

  #1 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0

Hello! Tell me how to determine the time of the current variable and the previous one. The indicator shows a bar that satisfies the conditions, you need to find the time value of the last bar that satisfies the indicator conditions and the time value of the previous bar that satisfies the indicator conditions.

 
Code
Inputs:
vTL(3), 
BuyTLColor (blue),
SellTLColor (red),
NetTLColor (white),
TLSize (1),
TLStyle (1);


Variables:
var0(0),
vTLValue(0),
BuyTL (1),
NetTL (1),
SellTL (1);


begin

var0 = Volume ;
var0 = Ticks ;

vTLValue = TL_GetEndVal(vTL);
If (close[0] > close[1] and var0 > vTLValue) then
BuyTL = TL_New_s(Date,Time_s, Low, Date, Time_s, High); 
TL_SetColor(BuyTL, BuyTLColor); 
TL_SetSize(BuyTL,TLSize); 
TL_SetStyle(BuyTL, TLStyle);

If (close[0] < close[1]and var0 > vTLValue) then
SellTL = TL_New_s(Date,Time_s, Low, Date, Time_s, High); 
TL_SetColor(SellTL, SellTLColor); 
TL_SetSize(SellTL,TLSize); 
TL_SetStyle(SellTL, SellTLColor);

If (close[0] = close[1]and var0 > vTLValue) then
NetTL = TL_New_s(Date,Time_s, Low, Date, Time_s, High); 
TL_SetColor(NetTL, NetTLColor); 
TL_SetSize(NetTL,TLSize); 
TL_SetStyle(NetTL, NetTLColor);


End;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Fobos,

you can store the time or DateTime in a variable when your conditions are met. At the same location within the code and before (!) you update this variable you store the value of that variable in another variable. In case you need to look back further than a few occurrences you might want to consider using a vector to store the previous values.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0



ABCTG View Post
Fobos,

you can store the time or DateTime in a variable when your conditions are met. At the same location within the code and before (!) you update this variable you store the value of that variable in another variable. In case you need to look back further than a few occurrences you might want to consider using a vector to store the previous values.

Regards,

ABCTG

Tell me how to save DateTime into a variable?

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Fobos,

these two links should get you going:
DateTime Class
BarDateTime (Reserved Word)

Regards,

ABCTG


Fobos View Post
Tell me how to save DateTime into a variable?


Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0


ABCTG View Post
Fobos,

these two links should get you going:
DateTime Class
BarDateTime (Reserved Word)

Regards,

ABCTG

Thank you so much! With your help, I managed to find the DateTime variable. Now I am looking for a high-low between the two variables DateTime and DateTime [1], but this code displays the high-low bars of these variables. What's my mistake?

 
Code
if (dateTime > Times[1]) and (dateTime <= Times) then begin 

// Reset variables
if (dateTime[1] = Times[1]) then begin
        openRangeHigh = 0;
        openRangeLow  = 99999;
    end;
     
openRangeHigh = MaxList(High, openRangeHigh);
openRangeLow  = MinList(Low,  openRangeLow);
   
        
    end;



tlHigh = openRangeHigh;
tlMid	= (openRangeHigh + openRangeLow) * 0.50;
tlLow 	= openRangeLow;


// Draw the trendlines
	value10 = TL_New_Dt(Times[1] , tlHigh, Times, tlHigh);
	value11 = TL_New_Dt( Times[1], tlMid, Times, tlMid);
	value12 = TL_New_Dt( Times[1], tlLow, Times, tlLow);

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Fobos,

since the code is incomplete I could only guess, but I would suggest using the print reserved word or debugger to find out when you variables are reset and if this happens for example on every bar.

Regards,

ABCTG


Fobos View Post
Thank you so much! With your help, I managed to find the DateTime variable. Now I am looking for a high-low between the two variables DateTime and DateTime [1], but this code displays the high-low bars of these variables. What's my mistake?

 
Code
if (dateTime > Times[1]) and (dateTime <= Times) then begin 

// Reset variables
if (dateTime[1] = Times[1]) then begin
        openRangeHigh = 0;
        openRangeLow  = 99999;
    end;
     
openRangeHigh = MaxList(High, openRangeHigh);
openRangeLow  = MinList(Low,  openRangeLow);
   
        
    end;



tlHigh = openRangeHigh;
tlMid	= (openRangeHigh + openRangeLow) * 0.50;
tlLow 	= openRangeLow;


// Draw the trendlines
	value10 = TL_New_Dt(Times[1] , tlHigh, Times, tlHigh);
	value11 = TL_New_Dt( Times[1], tlMid, Times, tlMid);
	value12 = TL_New_Dt( Times[1], tlLow, Times, tlLow);


Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0


ABCTG View Post
Fobos,

since the code is incomplete I could only guess, but I would suggest using the print reserved word or debugger to find out when you variables are reset and if this happens for example on every bar.

Regards,

ABCTG


 
Code
Inputs:
       vTL(3),
       High_Color(Red),		
	Mid_Color(RGB(255, 128, 0)),		
	Low_Color(blue),			
	High_Line_Tickness(2),				
	Mid_Line_Tickness(1),				
	Low_Line_Tickness(2),				
	High_Line_Style(2),					
	Mid_Line_Style(3),					
	Low_Line_Style(2);	



Variables:


Times(0),
var0(0),
vTLValue(0),
openRangeHigh(0), 
openRangeLow(999999),
tlHigh(0), 
tlLow(0), 
tlMid(0);


begin

var0 = Volume ;
var0 = Ticks ;

vTLValue = TL_GetEndVal(vTL);
If ( var0 > vTLValue) then
Times = DateTime;
end;

if (dateTime > Times[1]) and (dateTime <= Times) then begin 

// Reset variables
if (dateTime[1] = Times[1]) then begin
        openRangeHigh = 0;
        openRangeLow  = 99999;
    end;
     
openRangeHigh = MaxList(High, openRangeHigh);
openRangeLow  = MinList(Low,  openRangeLow);
   
        
    



tlHigh = openRangeHigh;
tlMid	= (openRangeHigh + openRangeLow) * 0.50;
tlLow 	= openRangeLow;


// Draw the trendlines
	value10 = TL_New_Dt(Times[1] , tlHigh, Times, tlHigh);
	value11 = TL_New_Dt( Times[1], tlMid, Times, tlMid);
	value12 = TL_New_Dt( Times[1], tlLow, Times, tlLow);
	
	// Change colour of the lines
	TL_SetColor(value10, High_Color);
	Tl_SetColor(value11, Mid_Color);
	TL_SetColor(value12, Low_Color);
	
	// Change the style of the lines
	TL_SetStyle(value10, High_Line_Style);
	TL_SetStyle(value11, Mid_Line_Style);
	TL_SetStyle(value12, Low_Line_Style);
end;

Reply With Quote
  #8 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0

ABCTG, Thank you! Understood the code, fixed it.

Reply With Quote




Last Updated on October 4, 2019


© 2024 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 - Privacy Policy - Downloads - Top
no new posts