Simple Coding Help - No Promise.

Dawood

Active Member
You can incorporate something like this into the code:

Buy = Cross( MA( C, 5 ), MA( C, 21 ) );//Use your own buy/sell conditions
Sell = Cross( MA( C, 21 ), MA( C, 5 ) );

hiBuy = ValueWhen( Buy, H );
loSell = ValueWhen( Sell, L );

Plot( IIf( BarsSince( Buy ) < 6, hiBuy, Null ), "", colorWhite, styleLine );
Plot( IIF( BarsSince( Sell ) < 6, loSell, Null ), "", colorWhite, styleline );
Thanks my friend....works perfectly
 

casoni

Well-Known Member
Please post your code .... coz as per colion's code the line stays even after the signal changes


bar=Param("No of bas",5,3,20,1);
pdbars = BarsSince(Buy);
pmbars = BarsSince(Sell);
PDbuyvalue = ValueWhen(Buy,H,1);
Pmbuyvalue = ValueWhen(Sell,L,1);
up2= IIf(pdbars<pmbars AND pdbars<bar,PDbuyvalue,Null);
dn2= IIf(pdbars>pmbars AND pmbars<bar,Pmbuyvalue,Null);
Plot(up2,"Buy Lev",colorRed,8);
Plot(dn2,"Short lev",colorGreen,8);
 

Nehal_s143

Well-Known Member
Hi

I came across a web site http: // www . profsoftware . com /trend/

they are offering trend reversal indicator on price chart for any time frame any market

seems interesting they had also provided formula for the same but I think its for trade station. We need afl to test the same in Live market, they had shown examples on U.S. Market.

formula is as under


Manul on how to use in pdf given at
http : // www . profsoftware . com /trend/UNITRDES.pdf

Code:
//Universal Trend Detection System - Indicator

{ UT_Trend
PSS Universal Trend Detection System - Indicator
(C)Copyright, 2009, B.Eichberger from Professional Software Solutions, [email protected]
This program remains the exclusive property of B. EICHBERGER and may not be sold,
used, copied, displayed or modified without the written consent of B. EICHBERGER.
YOU ASSUME FULL LIABILITY FOR ALL TRADING RISKS AND OUTCOMES!
PSS OR ITS EMPLOYEES AND ASSOCIATES ARE NOT RESPONSIBLE FOR ANY LOSS OR PROFIT!
}
Inputs:
	UTScope(40),
	UTSmooth(1),
	UTRecent(2),
	UTStep(80),
	UTCloseFac(100),
	UTColorMax(3),
	UTStyle(1),
	ColorUp(Green),
	ColorNeutral(Yellow),
	ColorDown(Red);

Var:
	cmt(""),
	txtDiag("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),
	txtID(Symbol + "_TREND"),
	nColor(0),
	ret(0);
Array:
	double arrVal[100](0);

{====== UT MODULE INTERFACE =========================================}
DefineDLLFunc: "PSS_UTC.DLL", float , "PSS_UTC", LPSTR, LPDOUBLE, LPSTR;
arrVal[0] = Date data1;
arrVal[1] = Time data1;
arrVal[2] = Open data1;
arrVal[3] = High data1;
arrVal[4] = Low  data1;
arrVal[5] = Close data1;
arrVal[6] = Ticks data1;
arrVal[7] = BarNumber data1;
arrVal[8] = BarInterval data1;
arrVal[9] = BarType data1;
arrVal[10] = CustomerID;
arrVal[11] = UTScope;
arrVal[12] = UTSmooth;
arrVal[14] = UTRecent;
arrVal[15] = UTStep;
arrVal[16] = GetBackgroundColor;
arrVal[17] = ColorUp;
arrVal[18] = ColorNeutral;
arrVal[19] = ColorDown;
arrVal[20] = UTCloseFac;
arrVal[21] = UTColorMax;
ret = PSS_UTC(txtID,&arrVal[0],txtDiag);

IF ret > 0 THEN BEGIN
	nColor = ColorNeutral;
	IF arrVal[61] < 0 THEN
		nColor = ColorDown;
	IF arrVal[61] > 0 THEN
		nColor = ColorUp;
	IF UTStyle = 1 THEN BEGIN	// Show clipped Trend Grades -5 to +5
		IF arrVal[57] = 0 AND arrVal[59] >= 0 THEN
			arrVal[57] = 0.5;
		IF arrVal[57] = 0 AND arrVal[59] < 0 THEN
			arrVal[57] = -0.5;
		Plot1(arrVal[57],"Trend",nColor);
		Plot2(0,"Zero");
	END;
	IF UTStyle = 2 THEN BEGIN	// Show unclipped Trend Strength
		Plot1(arrVal[59],"Trend",nColor);
		Plot2(0,"Zero");
		Plot3(5,"TrendMax",ColorUp);
		Plot4(-5,"TrendMax",ColorDown);
	END;
	IF UTStyle = 3 THEN BEGIN	// Show Trend Age
		Plot1(arrVal[60],"Trend",nColor);
		Plot2(0,"Zero");
	END;
	IF UTStyle = 4 THEN BEGIN	// Show Direction
		Plot1(arrVal[61],"Trend",nColor);
		Plot2(0,"Zero");
	END;

	{====== SHOW BAR COMMENT =============================================}
	IF AtCommentaryBar and CommentaryEnabled THEN BEGIN
		cmt = "Grade=" + Numtostr(arrVal[57],0) + "(" + Numtostr(arrVal[59],2) + ") Dir=" + Numtostr(arrVal[61],0) + " TrendAge=" + Numtostr(arrVal[60],0) + newline;
		cmt = cmt + "Scope=" + Numtostr(UTScope,0) + " Smooth=" + numtostr(UTSmooth,0) + " Recent=" + numtostr(UTRecent,1) + " Step=" + numtostr(UTStep,0) + " CloseFac=" + numtostr(UTCloseFac,0) + " 1.3a" + newline;
		commentary(cmt);
	END;
END;

IF ret < -100 THEN
	RaiseRunTimeError(txtDiag);
Code:
//Universal Trend Detection System - Paint Bar

{ UT_Bars
PSS Universal Trend Detection System - Paint Bar
(C)Copyright, 2009, B.Eichberger from Professional Software Solutions, [email protected]
This program remains the exclusive property of B. EICHBERGER and may not be sold,
used, copied, displayed or modified without the written consent of B. EICHBERGER.
YOU ASSUME FULL LIABILITY FOR ALL TRADING RISKS AND OUTCOMES!
PSS OR ITS EMPLOYEES AND ASSOCIATES ARE NOT RESPONSIBLE FOR ANY LOSS OR PROFIT!
}
Inputs:
	UTScope(40),
	UTSmooth(1),
	UTRecent(2),
	UTStep(80),
	UTCloseFac(100),
	UTColorMax(3),
	BarWidth(2),
	ColorUp(Green),
	ColorNeutral(Yellow),
	ColorDown(Red);

Var:
	txtDiag("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),
	txtID(Symbol + "_BARS"),
	ret(0);
Array:
	double arrVal[100](0);

{====== UT MODULE INTERFACE =========================================}
DefineDLLFunc: "PSS_UTC.DLL", float , "PSS_UTC", LPSTR, LPDOUBLE, LPSTR;
arrVal[0] = Date data1;
arrVal[1] = Time data1;
arrVal[2] = Open data1;
arrVal[3] = High data1;
arrVal[4] = Low  data1;
arrVal[5] = Close data1;
arrVal[6] = Ticks data1;
arrVal[7] = BarNumber data1;
arrVal[8] = BarInterval data1;
arrVal[9] = BarType data1;
arrVal[10] = CustomerID;
arrVal[11] = UTScope;
arrVal[12] = UTSmooth;
arrVal[14] = UTRecent;
arrVal[15] = UTStep;
arrVal[16] = GetBackgroundColor;
arrVal[17] = ColorUp;
arrVal[18] = ColorNeutral;
arrVal[19] = ColorDown;
arrVal[20] = UTCloseFac;
arrVal[21] = UTColorMax;
ret = PSS_UTC(txtID,&arrVal[0],txtDiag);

{====== PAINT BAR WITH CURRENT TREND COLOR ===========================}
IF ret > 0 THEN
	PlotPaintBar(High,Low,Open,Close,"Trend",arrVal[58],Default,BarWidth);

{====== PROCESS ERRORS ===============================================}
IF ret < -100 THEN
	RaiseRunTimeError(txtDiag);
Code:
//Universal Trend Detection System - Automated Trading Strategy

{ UT_TRD
PSS Universal Trend Detection System - Automated Trading Strategy
(C)Copyright, 2009, B.Eichberger from Professional Software Solutions, [email protected]
This program remains the exclusive property of B. EICHBERGER and may not be sold,
used, copied, displayed or modified without the written consent of B. EICHBERGER.
YOU ASSUME FULL LIABILITY FOR ALL TRADING RISKS AND OUTCOMES!
PSS OR ITS EMPLOYEES AND ASSOCIATES ARE NOT RESPONSIBLE FOR ANY LOSS OR PROFIT!
}
Inputs:
	UTScope(40),
	UTSmooth(1),
	UTRecent(2),
	UTStep(80),
	UTCloseFac(100),
	EntryGrade(2),
	ExitAge(3),
	TargetAmount(0),
	StopAmount(0),
	TrailAmount(0),
	ExitDayEnd(0),
	txtID("TRD");;

Var:
	txtDiag("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),
	txtID_(Symbol + "_TRADE_" + txtID),
	nGrade(0),
	nTrendAge(0),
	ret(0);
Array:
	double arrVal[100](0);

{====== UT MODULE INTERFACE =========================================}
DefineDLLFunc: "PSS_UTC.DLL", float , "PSS_UTC", LPSTR, LPDOUBLE, LPSTR;
arrVal[0] = Date data1;
arrVal[1] = Time data1;
arrVal[2] = Open data1;
arrVal[3] = High data1;
arrVal[4] = Low  data1;
arrVal[5] = Close data1;
arrVal[6] = Ticks data1;
arrVal[7] = BarNumber data1;
arrVal[8] = BarInterval data1;
arrVal[9] = BarType data1;
arrVal[10] = CustomerID;
arrVal[11] = UTScope;
arrVal[12] = UTSmooth;
arrVal[13] = GetAppInfo(aiOptimizing);
arrVal[14] = UTRecent;
arrVal[15] = UTStep;
arrVal[20] = UTCloseFac;
ret = PSS_UTC(txtID_,&arrVal[0],txtDiag);
nGrade = arrVal[57];
nTrendAge = arrVal[60];

{====== ENTER WHEN ENTRY GRADE HAS BEEN REACHED ======================}
IF ret > 0 THEN BEGIN 
	IF nGrade >= Pos(EntryGrade) AND nGrade[1] < Pos(EntryGrade) then BEGIN
		Buy("LE") next bar Market;
	END;
	IF nGrade <= Neg(EntryGrade) AND nGrade[1] >= Neg(EntryGrade) then BEGIN
		SellShort("SE") next bar Market;
	END;
end;

{====== EXIT WHEN DIRECTION CHANGED ==================================}
IF MarketPosition > 0 AND nGrade <= -1 AND nTrendAge > ExitAge THEN
	Sell("LX") Next bar Market;
IF MarketPosition < 0 AND nGrade >=  1 AND nTrendAge > ExitAge THEN
	BuyToCover("SX") Next bar Market;

{====== OPTIONAL AMOUNT BASED EXITS ==================================}
IF ExitDayEnd > 0 THEN
	SetExitOnClose;					// exit at end of day/session
SetStopPosition;
IF TargetAmount > 0 THEN
	SetProfitTarget(TargetAmount);	// target/gain reached
IF StopAmount > 0 then
	SetStopLoss(StopAmount);		// fixed stop out protection
IF TrailAmount > 0 THEN
	SetDollarTrailing(TrailAmount);	// trailing stop

{====== SHOW BAR COMMENT =============================================}
IF AtCommentaryBar and CommentaryEnabled THEN BEGIN
	Vars: cmt("");
	cmt = cmt + "Bar#" + numtostr(barnumber,0) + " Close=" + numtostr(C,5) + " High=" + numtostr(H,5) + " Low=" + numtostr(L,5) + newline;
	cmt = cmt + "Pos="+numtostr(marketposition,0) + " PosAge=" + numtostr(BarsSinceEntry,0) + " Left=" + numtostr(CurrentContracts,0) + " Entry=" + numtostr(EntryPrice,5) + " ExitAge=" + numtostr(BarsSinceExit(1),0) + newline;
	cmt = cmt + "Grade=" + Numtostr(arrVal[57],0) + "(" + Numtostr(arrVal[59],2) + ") Dir=" + Numtostr(arrVal[61],0) + " TrendAge=" + Numtostr(arrVal[60],0) + newline;
	cmt = cmt + "Scope=" + Numtostr(UTScope,0) + " Smooth=" + numtostr(UTSmooth,0) + " Recent=" + numtostr(UTRecent,1) + " Step=" + numtostr(UTStep,0) + " CloseFac=" + numtostr(UTCloseFac,0) + " 1.3a" + newline;
	commentary(cmt);
END;

{====== PROCESS ERRORS ===============================================}
IF ret < -100 THEN
	RaiseRunTimeError(txtDiag);
"Universal Trend Detection System (UNITRDES)" to assist you in detecting the current trend in real-time
in any market (Stocks, ETF's, futures, FOREX etc) using an intuitive continuous color scheme
 

amitrandive

Well-Known Member
Hi

I came across a web site http: // www . profsoftware . com /trend/

they are offering trend reversal indicator on price chart for any time frame any market

seems interesting they had also provided formula for the same but I think its for trade station. We need afl to test the same in Live market, they had shown examples on U.S. Market.

formula is as under


Manul on how to use in pdf given at
http : // www . profsoftware . com /trend/UNITRDES.pdf

Code:
//Universal Trend Detection System - Indicator

{

.
.
 "Universal Trend Detection System (UNITRDES)" to assist you in detecting the current trend in real-time
in any market (Stocks, ETF's, futures, FOREX etc) using an intuitive continuous color scheme[/QUOTE]

Nehal 
Please do not be mislead by such marketing gimmicks.
Obviously the code has a dll lock which locks the software after the trial period.

Secondly, if the indicator is surely making profits,why are they charging fees for it and distributing it to the world.They might as well use the software/indicator and become multimillionaires themselves.
 
I have buy/sell conditions based on MACD on 5 mins graph, but I want to trade only on 1st signal of the day whether buy or sell. seniors plz help with coding in afl. thank you
 

Similar threads