Trying to recreate indicator - futures io
futures io futures trading



Trying to recreate indicator


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Trying to recreate indicator

(login for full post details)
  #1 (permalink)
Kingsport, Tennessee
 
 
Posts: 28 since Apr 2020
Thanks: 10 given, 10 received

Can anyone tell me what I'm doing wrong here? I'm trying to recreate the closed-source Better X Trend indicator for my own purposes, but I can't get it to work correctly. It essentially uses price action and volume to signify different market conditions. I get a line on the chart, but not like the original. The two lines are on the chart pictured. The original line is the one the runs flatter (from high to high, and low to low). Here's the code. TradeStation said "staff can't help recreate protected code" so I'm asking here. I guess they are contractually obligated or something. Most of the code is from the Better Volume Indicator which is open-source. The rest (the Better X portion) was copied from a PineScript indicator, also open-source. Don't understand what the deal would be with TradeStation over that, but whatever.

 
Code
{***** Copyright www.Emini-Watch.com  All rights reserved *****}

Inputs:		Color(Cyan), BetterXBullishColor(green), BetterXBearishColor(red), UseUpTicks(True), Use2Bars(True);
Variables:	LowVol(false), HVBullish(false), HVBearish(false), Churn(false), HVChurn(false), Lookback(20), trend(1), resistance(high), support(low);



{If chart is anything other than minute or tick}
If BarType > 1 then begin
	If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*V;
	If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*V;
	If C = O then Value1 = 0.5*V;
	Value2 = V-Value1;
End;
{If chart is minute or tick, and UseUpTicks is set to false}
If BarType <= 1 and UseUpTicks = False then begin
	If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*Ticks;
	If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*Ticks;
	If C = O then Value1 = 0.5*Ticks;
	Value2 = Ticks-Value1;
End;

If BarType <= 1 and UseUpTicks then begin
	Value1 = UpTicks;
	Value2 = DownTicks;
End;

Value3 = AbsValue(Value1+Value2);
Value4 = Value1*Range;
Value5 = (Value1-Value2)*Range;
Value6 = Value2*Range;
Value7 = (Value2-Value1)*Range;
If Range <> 0 then begin
	Value8 = Value1/Range;
	Value9 = (Value1-Value2)/Range;
	Value10 = Value2/Range;
	Value11 = (Value2-Value1)/Range;
	Value12 = Value3/Range;
End;
If Use2Bars then begin
	Value13 = Value3+Value3[1];
	Value14 = (Value1+Value1[1])*(Highest(H,2)-Lowest(L,2));
	Value15 = (Value1+Value1[1]-Value2-Value2[1])*(Highest(H,2)-Lowest(L,2));
	Value16 = (Value2+Value2[1])*(Highest(H,2)-Lowest(L,2));
	Value17 = (Value2+Value2[1]-Value1-Value1[1])*(Highest(H,2)-Lowest(L,2));
	If Highest(H,2) <> Lowest(L,2) then begin
		Value18 = (Value1+Value1[1])/(Highest(H,2)-Lowest(L,2));
		Value19 = (Value1+Value1[1]-Value2-Value2[1])/(Highest(H,2)-Lowest(L,2));
		Value20 = (Value2+Value2[1])/(Highest(H,2)-Lowest(L,2));
		Value21 = (Value2+Value2[1]-Value1-Value1[1])/(Highest(H,2)-Lowest(L,2));
		Value22 = Value13/(Highest(H,2)-Lowest(L,2));
	End;
End;

Condition1 = Value3 = Lowest(Value3,Lookback);
Condition2 = Value4 = Highest(Value4,Lookback) and C > O;
Condition3 = Value5 = Highest(Value5,Lookback) and C > O;
Condition4 = Value6 = Highest(Value6,Lookback) and C < O;
Condition5 = Value7 = Highest(Value7,Lookback) and C < O;
Condition6 = Value8 = Lowest(Value8,Lookback) and C < O;
Condition7 = Value9 = Lowest(Value9,Lookback) and C < O;
Condition8 = Value10 = Lowest(Value10,Lookback) and C > O;
Condition9 = Value11 = Lowest(Value11,Lookback) and C > O;
Condition10 = Value12 = Highest(Value12,Lookback);
If Use2Bars then begin
	Condition11 = Value13 = Lowest(Value13,Lookback);
	Condition12 = Value14 = Highest(Value14,Lookback) and C > O and C[1] > O[1];
	Condition13 = Value15 = Highest(Value15,Lookback) and C > O and C[1] > O[1];
	Condition14 = Value16 = Highest(Value16,Lookback) and C < O and C[1] < O[1];
	Condition15 = Value17 = Highest(Value17,Lookback) and C < O and C[1] < O[1];
	Condition16 = Value18 = Lowest(Value18,Lookback) and C < O and C[1] < O[1];
	Condition17 = Value19 = Lowest(Value19,Lookback) and C < O and C[1] < O[1];
	Condition18 = Value20 = Lowest(Value20,Lookback) and C > O and C[1] > O[1];
	Condition19 = Value21 = Lowest(Value21,Lookback) and C > O and C[1] > O[1];
	Condition20 = Value22 = Highest(Value22,Lookback);
End;

If BarType > 1 then begin
	If (Condition1 or Condition11) 
		then LowVol = True;
	If (Condition2 or Condition3 or Condition8 or Condition9 or Condition12 or Condition13 or Condition18 or Condition19) 
		then HVBullish = True;
	If (Condition4 or Condition5 or Condition6 or Condition7 or Condition14 or Condition15 or Condition16 or Condition17) 
		then HVBearish = True;
	If (Condition10 or Condition20) 
		then Churn = True;
	If 	(Condition10 or Condition20) 
		and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or 
		     Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) 
		     then HVChurn = True;
End;

If BarType <= 1 then begin
	If (Condition1 or (Condition11 and D=D[1])) 
		then LowVol = True;
	If (Condition2 or Condition3 or Condition8 or Condition9 or ((Condition12 or Condition13 or Condition18 or Condition19) and D=D[1])) 
	   	then HVBullish = True;
	If (Condition4 or Condition5 or Condition6 or Condition7 or ((Condition14 or Condition15 or Condition16 or Condition17) and D=D[1])) 
	   	then HVBearish = True;
	If (Condition10 or (Condition20 and D=D[1])) 
	   	then Churn = True;
	If (Condition10 or (Condition20 and D=D[1])) 
	   and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or 
		   ((Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) 
	   and D=D[1])) 
	   	then HVChurn = True;
End;

//Plot1(Value3,"Better Volume",BarColor);
//If ShowAvg then Plot2(Average(Value3,200),"Avg",AvgColor);

if (close > plot1[1]) then
	trend = 1;
if (close < plot1[1]) then
	trend = -1;

If (trend = 1) then
	resistance = resistance[1];
	
If (trend = 1) and (High > resistance[1]) then
	resistance = high;

If (trend = 1) and (HVBearish) then
	resistance = highest(high,2);
	

	
If (trend = -1) then
	resistance = resistance[1];
	
If (trend = -1) and (HVBearish) then
	resistance = highest(high,2);


{if (trend = 1) then 
	if (HVBearish) then 
		resistance = highest(high,2)
	else 
		if (high > resistance[1]) then 
			resistance = high;
		else 
			resistance = resistance[1]}
			
{if (trend = -1) then
	if (HVBearish) then 
		resistance = highest(high,2);
	else  
		resistance = resistance[1];}

			
If (trend = -1) then
	support = support[1];
	
If (trend = -1) and (Low < support[1]) then
	support = low;
	
If (trend = -1) and (HVBullish) then
	support = lowest(low,2);
	
	
If (trend = 1) then
	support = support[1];

If (trend = 1) and (HVBullish) then
	support = lowest(low,2);

{if (trend = -1) then
	if (HVBullish) then 
		support = lowest(low,2)
	else 
		if (low < support[1]) then 
			support = low;
		else  
			support = support[1]}

{if (trend = 1) then
	if (HVBullish) then 
		support = lowest(low,2);
	else 
		support = support[1];}
		
			
If trend = 1 then begin
	plot1(support, "Better X StratPlot", BetterXBullishColor);
	//alert("BearishX");
	end;
If trend = -1 then begin
	plot1(resistance, "Better X StratPlot", BetterXBearishColor);
	//alert("BullishX");
	end;

Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	33
Size:	63.9 KB
ID:	308064  
Reply With Quote

Can you help answer these questions
from other members on futures io?
Data for the YM and RTY for NT8 to practice on?
NinjaTrader
Market Position Indicator
The Elite Circle
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
MACD line not plotting after change of plot order
NinjaTrader
Indicators for pair trading MES and M2K
Platforms and Indicators
 
 
(login for full post details)
  #2 (permalink)
Kingsport, Tennessee
 
 
Posts: 28 since Apr 2020
Thanks: 10 given, 10 received

Forgot to add: My suspicion is that EasyLanguage doesn't store historical values for user variables like "resistance" or "support."

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Trying to recreate indicator


Last Updated on January 11, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts