TRO Buy Zone -- Please help

Questions about MultiCharts and user contributed studies.
tradinghumble
Posts: 38
Joined: 11 Jun 2006

TRO Buy Zone -- Please help

Postby tradinghumble » 19 Apr 2010

Hello, I'm trying to plot the indicator below (credits to TRO) and it works ok in TS but not in Multicharts... can anyone please give me a clue of where it could be wrong ... I'm guessing it's related to scaling.

Code: Select all

[LegacyColorValue = true];

{ _TRO_BuyZone }


{Attn: TS
if this indicator is posted on the TS Forum, I, TheRumpledOne, did NOT post it there,
so I can't be blamed for this indicator having my contact info.}


{Programmer: Avery T. Horton, Jr. aka TheRumpledOne,
gifts and donations accepted, PO Box 43575, Tucson, AZ 85733 }

{ © Copyright 2007 Avery T. Horton, Jr.}


// Value1 = GetAppInfo(aiApplicationType); // returns a value that identifies the calling window type

// cUnknown = 0 cChart = 1 cRadarScreen = 2 cOptionStation = 3


inputs:
iDecimals(4),
iOpen(dailyopen),
iOpenBuyZone(.1),

iBuyZoneHI(.2), {inside ask must be <= (OPEN + iBuyZoneHI) to place buy order}
iBuyZoneLO(.2), {inside bid must be >= (OPEN - iBuyZoneLO) to place buy order}

iPlotOpen(true),


ShortBotColor( red),
ShortTopColor( red),
OpenColor(white),
LongTopColor( blue),
LongBotColor( blue) ,

TLSize( 0 ), // 0 - 6 for thin to thick
TLStyle( 2 ), // 1 = solid, 2 = dashed, 3 = dotted, 4 = dashed 2, 5 = dashed 3

TL_Text_HVal ( 0 ) , // HVal: 0=left, 1=right, 2=centered,
TL_Text_VVal ( 1 ) ; // VVal: 1=Top, 0=Bottom, 2=Centered


variables:

FG1(white),
BG1(black),

FG2(white),
BG2(black),

FG3(white),
BG3(black),

FG4(white),
BG4(black),


PrevSessionDate( 0 ),
PrevSessionTime(0),
PrevSessionHigh( 0 ),
PrevSessionLow( 0 ),
PrevSessionClose( 0 ),
PrevSessionMid( 0 ),
PrevSessionOpen( 0 ),
SessionDate( 0 ),
SessionTime(0),
SessionOpen( 0 ),
SessionClose( 0 ),
SessionHigh( 0 ),
SessionLow( 0 ),
PrevSession(999999),


Candle(0),
CandleDaily(0),
ShortDiff( 0 ),
LongDiff( 0 ),
tShortDiff( "" ),
tLongDiff( "" ),
BuyZone( 0 ),
xBuyZone(0),
tBuyZone(""),


sSession(false),


sFirstPass(true),
xAppType(0),

TL_TextTime( 0 ),


xDailyOpen(0),

xBuyZoneHI(0), {inside ask must be <= (OPEN + iBuyZoneHI) to place buy order}
xBuyZoneLO(0), {inside bid must be >= (OPEN - iBuyZoneLO) to place buy order}

textShortBot(0),
textShortTop(0),

textLongTop(0),
textLongBot(0),

textOpen(0),

TLOpen( 0 ),

HavePrevLines( false ),
TLShortTop( 0 ),
TLLongTop( 0 ),
TLLongBot( 0 ),
TLShortBot( 0 ),
ShortBot( 0 ),
ShortTop( 0 ),
LongTop( 0 ),
LongBot( 0 ) ;

{commentary variables}

variables:

xcomm(0),
oComm1( "" ),
oComm2( "" ),
oComm3( "" ),
oComm4( "" ),
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),
oComm10( "" );




{first time through}

if sFirstPass
then begin

sFirstPass = false;

xAppType = GetAppInfo(aiApplicationType); // cUnknown = 0 cChart = 1 cRadarScreen = 2 cOptionStation = 3

end; {if sFirstPass}


{ INITIALIZE }

FG1 = WHITE;
BG1 = BLACK;

fg2 = WHITE;
bg2 = BLACK;

fg3 = WHITE;
bg3 = BLACK;

fg4 = WHITE;
bg4 = BLACK;

{*************************************************}
{ C A L C U L A T I O N S }
{*************************************************}

Commentary(" ");

Commentary("CurrentSession(0) = ", numtostr( CurrentSession(0), 0 ) , NewLine);
Commentary("PrevSession = ", numtostr( PrevSession, 0 ) , NewLine);

sSession = false ;

if CurrentSession(0) <> PrevSession
then begin

sSession = true ;
PrevSessionOpen = SessionOpen;
PrevSessionDate = SessionDate;
PrevSessionTime = SessionTime;
PrevSessionClose = close[1];
PrevSessionHigh = SessionHigh;
PrevSessionLow = SessionLow;

SessionDate = date;
SessionTime = time;
SessionOpen = iOpen;
SessionHigh = iOpen;
SessionLow = iOpen;
PrevSession = CurrentSession(0);
PrevSessionMid = ( PrevSessionHigh + PrevSessionLow ) * .50 ;

end; // if CurrentSession(0) <> PrevSession

if High > SessionHigh then
SessionHigh = High ;

if Low < SessionLow then
SessionLow = Low ;


if d <> currentdate
then xDailyOpen = Opend(0)
else xDailyOpen = SessionOpen ;


// xDailyOpen = SessionOpen ;

LongTop = xDailyOpen + iBuyZoneHI;
LongBot = xDailyOpen + iOpenBuyZone;

ShortTop = xDailyOpen - iOpenBuyZone;
ShortBot = xDailyOpen - iBuyZoneLO;

ShortDiff = ShortTop - close ;
LongDiff = close - LongBot ;

tShortDiff = numtostr( ShortDiff , iDecimals ) ;
tLongDiff = numtostr( LongDiff , iDecimals ) ;


if xAppType = 1
then begin

TL_TextTime = AddTime( Time , 2 * BarInterval ) ;

{*************************************************}


if date this bar = currentdate
then begin

if HavePrevLines
then begin

If TLShortTop > 0
then value9 = TL_Delete( TLShortTop ) ;

If TLLongTop > 0
then value9 = TL_Delete( TLLongTop ) ;

If TLLongBot > 0
then value9 = TL_Delete( TLLongBot ) ;

If TLShortBot > 0
then value9 = TL_Delete( TLShortBot ) ;

If TLOpen > 0
then value9 = TL_Delete( TLOpen ) ;

end ; // if HavePrevLines

{ insert the new lines and set their colors/extents }

TLShortTop = TL_New( SessionDate, SessionTime, ShortTop, Date, Time, ShortTop ) ;
TLLongTop = TL_New( SessionDate, SessionTime, LongTop, Date, Time, LongTop ) ;
TLLongBot = TL_New( SessionDate, SessionTime, LongBot, Date, Time, LongBot ) ;
TLShortBot = TL_New( SessionDate, SessionTime, ShortBot, Date, Time, ShortBot ) ;

TL_SetColor( TLShortTop, ShortTopColor ) ;
TL_SetColor( TLLongTop, LongTopColor ) ;
TL_SetColor( TLLongBot, LongBotColor ) ;
TL_SetColor( TLShortBot, ShortBotColor ) ;

TL_SetStyle(TLLongTop,TLStyle);
TL_SetStyle(TLLongBot,TLStyle);
TL_SetStyle(TLShortTop,TLStyle);
TL_SetStyle(TLShortBot,TLStyle);

TL_SetExtLeft( TLShortTop, false ) ;
TL_SetExtLeft( TLLongTop, false ) ;
TL_SetExtLeft( TLLongBot,false ) ;
TL_SetExtLeft( TLShortBot,false ) ;

TL_SetExtRight( TLShortTop, true ) ;
TL_SetExtRight( TLLongTop, true ) ;
TL_SetExtRight( TLLongBot, true ) ;
TL_SetExtRight( TLShortBot, true ) ;

if iPlotOpen
then begin
TLOpen = TL_New( SessionDate, SessionTime, xDailyOpen, Date, Time, xDailyOpen ) ;
TL_SetColor( TLOpen, OpenColor ) ;
TL_SetStyle(TLOpen,TLStyle);
TL_SetExtLeft( TLOpen,false ) ;
TL_SetExtRight( TLOpen, true ) ;
end; // if iPlotOpen


{ set flag }
if HavePrevLines = false
then HavePrevLines = true ;

end ; // if date this bar <> currentdate


If textShortBot > 0
then value9 = Text_Delete( textShortBot ) ;

textShortBot = Text_New(Date, TL_TextTime ,ShortBot,"ShortBot ("+ NumToStr(ShortBot, iDecimals )+")");
Text_SetStyle(textShortBot, TL_Text_HVal , TL_Text_VVal );
Text_SetColor(textShortBot, ShortBotColor );
Text_SetLocation( textShortBot , date , TL_TextTime , ShortBot );

If textShortTop > 0
then value9 = Text_Delete( textShortTop) ;

textShortTop = Text_New(Date, TL_TextTime ,ShortTop,"ShortTop ("+ NumToStr(ShortTop, iDecimals )+")");
Text_SetStyle(textShortTop, TL_Text_HVal , TL_Text_VVal ); // HVal: 0=left, 1=right, 2=centered, / VVal: 0=Top, 1=Bottom, 2=Centered
Text_SetColor(textShortTop, ShortTopColor );
Text_SetLocation( textShortTop , date , TL_TextTime , ShortTop );

If textLongTop > 0
then value9 = Text_Delete( textLongTop) ;

textLongTop = Text_New(Date, TL_TextTime ,LongTop,"LongTop ("+ NumToStr(LongTop, iDecimals )+")");
Text_SetStyle(textLongTop, TL_Text_HVal , TL_Text_VVal ); // HVal: 0=left, 1=right, 2=centered, / VVal: 0=Top, 1=Bottom, 2=Centered
Text_SetColor(textLongTop, LongTopColor );
Text_SetLocation( textLongTop , date , TL_TextTime , LongTop );

If textLongBot > 0
then value9 = Text_Delete( textLongBot ) ;

textLongBot = Text_New(Date, TL_TextTime ,LongBot,"LongBot ("+ NumToStr(LongBot, iDecimals )+")");
Text_SetStyle(textLongBot,TL_Text_HVal , TL_Text_VVal ); // HVal: 0=left, 1=right, 2=centered, / VVal: 0=Top, 1=Bottom, 2=Centered
Text_SetColor(textLongBot, LongBotColor );
Text_SetLocation( textLongBot , date , TL_TextTime , LongBot );


If textOpen > 0
then value9 = Text_Delete( textOpen ) ;

textOpen = Text_New(Date, TL_TextTime , xDailyOpen ,"Open ("+ NumToStr(xDailyOpen, iDecimals )+")");
Text_SetStyle(textOpen,TL_Text_HVal , TL_Text_VVal ); // HVal: 0=left, 1=right, 2=centered, / VVal: 0=Top, 1=Bottom, 2=Centered
Text_SetColor(textOpen, OpenColor );
Text_SetLocation( textOpen , date , TL_TextTime , xDailyOpen );


end ; // if xAppType = 1


if xAppType = 2
then begin


candle = close - open ;

//CandleDaily = close - closeD(1) ;
CandleDaily = close - PrevSessionClose ;

{ Alert criteria }


If candle > 0
then begin
Fg3 = BLACK;
Bg3 = green;
end
else
If candle < 0
then begin
Fg3 = BLACK;
Bg3 = red;
end
else
begin
Fg3 = yellow;
Bg3 = BLACK;
end;

If CandleDaily > 0
then begin
Fg4 = BLACK;
Bg4 = green;
end
else
If CandleDaily < 0
then begin
Fg4 = BLACK;
Bg4 = red;
end
else
begin
Fg4 = yellow;
Bg4 = BLACK;
end;

If close < xdailyopen
and close > ShortTop
then begin
tBuyZone = "Wait " + tShortDiff ;
FG1 = RED;
BG1 = YELLOW;
end
else
If close > xdailyopen
and close < LongBot
then begin
tBuyZone = "Wait " + tLongDiff ;
FG1 = BLACK;
BG1 = YELLOW;
end;

If close crosses below xdailyopen
then begin
tBuyZone = "X Open " + tShortDiff ;
FG1 = RED;
BG1 = YELLOW;
end
else

If close crosses above xdailyopen
then begin
tBuyZone = "X Open " + tLongDiff ;
FG1 = BLACK;
BG1 = YELLOW;
end
else

If close crosses below LongTop
then begin
tBuyZone = "X LgTOP " + tLongDiff ;
FG1 = RED;
BG1 = YELLOW;
end
else

If close crosses above LongBot
then begin
tBuyZone = "X LgBOT " + tLongDiff ;
FG1 = BLACK;
BG1 = YELLOW;
end
else

If close > LongTop
then begin
tBuyZone = "ABOVE " + tLongDiff ;
FG1 = GREEN;
BG1 = BLACK;
end
else

If close crosses below ShortTop
then begin
tBuyZone = "X ShTOP " + tShortDiff ;
FG1 = red;
BG1 = YELLOW;
end
else

If close crosses above ShortBot
then begin
tBuyZone = "X ShBOT " + tShortDiff ;
FG1 = black;
BG1 = YELLOW;
end
else

If close < ShortBot
then begin
tBuyZone = "BELOW " + tShortDiff ;
FG1 = RED;
BG1 = BLACK;
end
else

If close > LongBot
and close <= LongTop
then begin
tBuyZone = "BUY " + tLongDiff ;
FG1 = BLACK;
BG1 = green;
end
else

If close >= ShortBot
and close < ShortTop
then begin
tBuyZone = "SHORT " + tShortDiff ;
FG1 = BLACK;
BG1 = red;
end;


if close > prevclose
then begin
FG2 = BLACK;
BG2 = green;
end
else
if close < prevclose
then begin
FG2 = yellow;
BG2 = BLACK;
end;


{ PLOTS }

Plot1( tBuyZone, "BuyZone", fg1 ) ;
SetPlotBGColor( 1, bg1);

Plot2( xdailyopen, "dailyopen", FG2 ) ;
SetPlotBGColor( 2, BG2);

Plot3( candle, "Candle", fg3 ) ;
SetPlotBGColor( 3, bg3);

Plot4( CandleDaily, "Dly C-C[1]", fg4 ) ;
SetPlotBGColor( 4, bg4);

Plot5( SessionTime, "Start", WHITE ) ;
SetPlotBGColor( 5, BLACK);

end ; // if xAppType = 2


xComm = _fCommentary(oComm1, oComm2, oComm3, oComm4, oComm5, oComm6, oComm7, oComm8, oComm9, oComm10);

CommentaryCl(oComm1 );

CommentaryCl(oComm2 );
CommentaryCl(oComm3 );
CommentaryCl(oComm4 );
CommentaryCl(oComm5 );
CommentaryCl(oComm6 );
CommentaryCl(oComm7 );
CommentaryCl(oComm8 );
CommentaryCl(oComm9 );
CommentaryCl(oComm10 );

Commentary(" ");
CommentaryCl( "CurrentDate: ", ELDateToString(CurrentDate) );
CommentaryCl( "Date: ", ELDateToString(Date) );
Commentary("CurrentSession(0) = ", numtostr( CurrentSession(0), 0 ) , NewLine);

Commentary(" ");

Commentary("Prev.Open = ", numtostr( PrevSessionOpen,iDecimals) , NewLine);
Commentary("Prev.High = ", numtostr( PrevSessionHigh,iDecimals) , NewLine);
Commentary("Prev.Low = ", numtostr( PrevSessionLow,iDecimals) , NewLine);
Commentary("Prev.Close = ", numtostr( PrevSessionClose,iDecimals) , NewLine);
Commentary("Prev.Mid = ", numtostr( PrevSessionMid,iDecimals) , NewLine);

Commentary(" ");

Commentary("Open = ", numtostr( Open,iDecimals) , NewLine);
Commentary("Opend(0) = ", numtostr( Opend(0),iDecimals) , NewLine);
Commentary("xdailyopen = ", numtostr( xdailyopen ,iDecimals) , NewLine);
Commentary("SessionOpen = ", numtostr( SessionOpen ,iDecimals) , NewLine);

Commentary(" ");

Commentary("LongTop = ", numtostr( LongTop,iDecimals) , NewLine);
Commentary("LongBot = ", numtostr( LongBot,iDecimals) , NewLine);
Commentary("ShortTop = ", numtostr( ShortTop,iDecimals) , NewLine);
Commentary("ShortBot = ", numtostr( ShortBot,iDecimals) , NewLine);


Commentary("iOpenBuyZone = ", numtostr( iOpenBuyZone,iDecimals) , NewLine);
Commentary("iBuyZoneHI = ", numtostr( iBuyZoneHI,iDecimals) , NewLine);
Commentary("iBuyZoneLO = ", numtostr( iBuyZoneLO,iDecimals) , NewLine);

Thanks in advance.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: TRO Buy Zone -- Please help

Postby TJ » 19 Apr 2010

Hello, I'm trying to plot the indicator below (credits to TRO) and it works ok in TS but not in Multicharts... can anyone please give me a clue of where it could be wrong ... I'm guessing it's related to scaling.
....
can you describe what do you mean by "does not work"?

can't compile?
error messages?
no plot?
what version of MC?

you have to give a bit more information for people to help you.

tradinghumble
Posts: 38
Joined: 11 Jun 2006

Re: TRO Buy Zone -- Please help

Postby tradinghumble » 19 Apr 2010

Hello, I'm trying to plot the indicator below (credits to TRO) and it works ok in TS but not in Multicharts... can anyone please give me a clue of where it could be wrong ... I'm guessing it's related to scaling.
....
can you describe what do you mean by "does not work"?

can't compile?
error messages?
no plot?
what version of MC?

you have to give a bit more information for people to help you.
TJ -- it compiles no problem and I can add it to the chart but it shrinks the price data... picture attached.

I have set Scaling to 'Same as instrument'.

Thanks for your help.
Attachments
shrink.png
(12.6 KiB) Downloaded 728 times

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 19 Apr 2010

Try making sure you have more days of data loaded than just the two, since it refers to previous daily information. Also, you could try putting it into a different subgraph so you can see better what it's outputting.

tradinghumble
Posts: 38
Joined: 11 Jun 2006

Postby tradinghumble » 19 Apr 2010

Think I've figure it out, for some reason it only works in MC if you use 'Screen Scalling' where as in TS it works in other scaling modes...

Thanks for your help guys.

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 19 Apr 2010

Be wary - if you set Screen as the scaling method, you may not be matching up the same prices in the indicator's output to the underlying data series prices, and as you scroll left and right, the values can shift relative to the underlying.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Postby ABC » 19 Apr 2010

tradinghumble,

what should help you is leaving the scaling to "Same as Symbol" for the indicator, but uncheck "Expand Scale to Indicators" under "Format Instrument" and in the "Scaling" tab:

Image

I forgot when this was introduced into MC, but it surely is to be found in the current beta version.

Regards,

ABC
Attachments
Screenshot - 19.04.2010 , 17_29_24.png
scaleoff
(46.48 KiB) Downloaded 712 times

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 19 Apr 2010

Excellent suggestion, that is exactly what is needed in this case to get it going right away. In the long run, I would suggest when time permits to also take a look at the indicator code and figure out why it's outputting plots that are out of range for the pane scale (probably 0), but in the interim, following the instructions provided by ABC above should get this up and running immediately, and thanks for reminding about this setting - I had forgotten that was even in there and I'll bet a lot of people probably have.

tradinghumble
Posts: 38
Joined: 11 Jun 2006

Postby tradinghumble » 19 Apr 2010

HA HA... Very nice, thanks ABC ... that did the trick for this indicator as well as other indicators.


Return to “MultiCharts”