NexusFi: Find Your Edge


Home Menu

 





Plz Help:Indicator plot nothing


Discussion in TradeStation

Updated
    1. trending_up 4,687 views
    2. thumb_up 9 thanks given
    3. group 2 followers
    1. forum 22 posts
    2. attach_file 2 attachments




 
Search this Thread

Plz Help:Indicator plot nothing

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

jiaqiangmit,

I posted a potential cause for the text and trendline not being shown and the solution here:


When you do the update i.e. before or after you draw a line shouldn't be a problem, but trying to update a non existent text or trendline will result in the problem described in the help file excerpt.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #12 (permalink)
 jiaqiangmit 
Mianyang China
 
Experience: Beginner
Platform: Multicharts
Broker: broker: Oanda
Trading: HSI, DAX, ES
Posts: 84 since Aug 2017
Thanks Given: 18
Thanks Received: 10


ABCTG View Post
jiaqiangmit,

I posted a potential cause for the text and trendline not being shown and the solution here:


When you do the update i.e. before or after you draw a line shouldn't be a problem, but trying to update a non existent text or trendline will result in the problem described in the help file excerpt.

Regards,

ABCTG

Thanks, I'll see to it.

Started this thread Reply With Quote
  #13 (permalink)
 jiaqiangmit 
Mianyang China
 
Experience: Beginner
Platform: Multicharts
Broker: broker: Oanda
Trading: HSI, DAX, ES
Posts: 84 since Aug 2017
Thanks Given: 18
Thanks Received: 10



ABCTG View Post
jiaqiangmit,

I posted a potential cause for the text and trendline not being shown and the solution here:


When you do the update i.e. before or after you draw a line shouldn't be a problem, but trying to update a non existent text or trendline will result in the problem described in the help file excerpt.

Regards,

ABCTG

the ID in Text_setlocation in waveText, which is a var as var:waveText(0).

The first block using Text_setlocation is here, the logic is:
trend is up,
if price did not drop to the set points to form a new down leg( if not swingHiCondition)
then update current upswing line and text from lastLoBar,
else, if price reaction to the set points to form a new down leg(if swingHiCondition),
update the up leg to the swinghigh bar

Quoting 
//if dir > 0 then begin // trend is up, look for new swing high
if not swingHiCondition then
begin
if hi[0] >= lastHi then // found an equal high or higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
end;
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line and text from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
TL_SetEnd( tl, date[0],time[0], lastHi );Print;
end;
plotText = NumToSTr( volUp / ScaleVolumeBy, 0 );print;
Text_SetLocation( waveTxt, date[0],time[0], High[0]+dis);
Text_SetString( waveTxt, plotText );
end
else if swingHiCondition then // found a swing high
begin
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto ( CurrentBar - lastHiBar )
begin
volUp = volUp + vol[x];
{if PlotVolume thena
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy,0){NumToSTr( volUp / ScaleVolumeBy, 0 )} ;

Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar]+dis );
Text_SetString( waveTxt, plotText );


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

jiaqiangmit,

you can utilize the build in functions "Text_Exist" and "TL_Exist" to check if an ID exists before you update it.
However it will most likely be enough to simply check that the respective ID variables (tl or waveTxt) are greater than zero before you are trying to update the text or trendline with this ID. This is likely were your code runs into the problem described in the help file i.e. it's enough if it tries to update a not existing ID (for example when waveTxt = 0). This would trigger the mentioned issue and the result would be a blank chart.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #15 (permalink)
 jiaqiangmit 
Mianyang China
 
Experience: Beginner
Platform: Multicharts
Broker: broker: Oanda
Trading: HSI, DAX, ES
Posts: 84 since Aug 2017
Thanks Given: 18
Thanks Received: 10


ABCTG View Post
jiaqiangmit,

you can utilize the build in functions "Text_Exist" and "TL_Exist" to check if an ID exists before you update it.
However it will most likely be enough to simply check that the respective ID variables (tl or waveTxt) are greater than zero before you are trying to update the text or trendline with this ID. This is likely were your code runs into the problem described in the help file i.e. it's enough if it tries to update a not existing ID (for example when waveTxt = 0). This would trigger the mentioned issue and the result would be a blank chart.

Regards,

ABCTG

Thanks, I added " if tl_exist(tl) then /if text_exist(wavetxt) " before those IDs, and it's plotting now. However, there is still two problem, please see Pic below:


the latest codes are:

Quoting 
Inputs:
HiPrice( close ), // price field for high swings
LoPrice( close ), // price field for low swings
RetraceMethod( 1 ), // 1=Pnt, 2=%, 3=ATR, 4=UTC
Period( 2 ), // number of bars over which ATR or UTC is calculated
Retrace( 0 ), // retracement in Pnt, % or ATR multiple
PlotVolume( true ), // plots swing volume histogram
PlotSwings( true ), // plots ZigZag lines
PlotVolumeText( true ), // plots swing volume text of up/down swing at swing high/low
AvgVolume( false ), // shows average swing volume text in stead of cumulative swing volume text
ScaleVolumeBy( 1 ), // divides cumulative volume text by the number of this input
PlotPriceText( false ), // plots price change of up/down swing at swing high/low
PlotTimeText( false ), // plots duration of up/down swing at swing high/low
LineWidth( 0 ), // line width of ZigZag lines: 0,1,2,3,4,5,6
LineStyle( tool_solid), // line style of ZigZag lines: tool_solid, tool_dotted, tool_dashed, tool_dashed2, tool_dashed3
UpColor( red ), // line color of upswings: PowerLanguage colors
DnColor( red ), // line color of downswings: PowerLanguage colors
TextColor( white ), // text color: PowerLanguage colors
dis(3); //distance of text frome the high/low, added by Qin H Jia 20171213

Vars:
dailyTF( false ),
dir( 0 ),
hi( HiPrice ),
lo( LoPrice ),
lastLoBar( 1 ),
lastHiBar( 1 ),
lastHi( HiPrice ),
lastLo( LoPrice ),
swingHiCondition( false ),
swingLoCondition( false ),
vol( 0 ),
volUp( 0 ),
volDn( 0 ),
barsBack( 0 ),
x( 0 ),
tl( 0 ),
plotText( "" ),var1(-99),var2(-99),
waveTxt(0 );

// Initialize variables
dailyTF = BarType >= 2 and BarType < 5;
hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );
lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );
vol = iff( dailyTF, Volume, Ticks );

// set initial trend direction (dir will become non-zero after the first couple of bars)
if dir = 0 then
begin
if hi[0] > lastHi then // higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
if lo[0] > lo[1] then // higher low
dir = 1; // initial trend direction is up
end;
if lo[0] < lastLo then // lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
if hi[0] < hi[1] then // lower high
dir = -1; // initial trend direction is down
end;
end;

// look for swing points and draw lines

if dir > 0 then // trend is up, look for new swing high
begin
if RetraceMethod = 1 then swingHiCondition = lo[0] < lastHi - Retrace; // condition for swing high pnt
if RetraceMethod = 2 then swingHiCondition = lo[0] < lastHi * (1 - Retrace * 0.01 ); // condition for swing high %
if RetraceMethod = 3 then swingHiCondition = lo[0] < lastHi - ( Retrace * AvgTrueRange( Period ) ); // condition for swing high ATR
if RetraceMethod = 4 then swingHiCondition = hi[0] < lastHi and lo[0] < lo[1]; // condition for swing high UTC

if not swingHiCondition then
begin
if hi[0] >= lastHi then // found an equal high or higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
end;
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line and text from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
if tl_exist(tl) then TL_SetEnd( tl, date[0],time[0], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy, 0 );print;
if text_exist(wavetxt) then Text_SetLocation( waveTxt, date[0],time[0], High[0]+dis);
if text_exist(wavetxt) then Text_SetString( waveTxt, plotText );
end
else if swingHiCondition then // found a swing high
begin
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto ( CurrentBar - lastHiBar )
begin
volUp = volUp + vol[x];
{if PlotVolume thena
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
if tl_exist(tl) then TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy,0){NumToSTr( volUp / ScaleVolumeBy, 0 )} ;

if text_exist(wavetxt) then Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar]+dis );
if text_exist(wavetxt) then Text_SetString( waveTxt, plotText );

dir = -1; // trend direction is now down
lastLo = lo[0];
lastLoBar = CurrentBar; // now seeking new lows
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;

if PlotSwings then // start new trendline from new swing high to most recent low
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
tl = TL_New( date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, DnColor );
end;
plotText =
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ), "" ) ;
waveTxt = Text_New( date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar], plotText );
Text_SetStyle( waveTxt, 2, 0 );
{Text_SetSize( waveTxt, 8 );}
Text_SetColor( waveTxt, TextColor );
end;
end
else
begin // dir < 0, trend is down, look for new swing low
if RetraceMethod = 1 then swingLoCondition = hi[0] > lastLo + Retrace; // condition for swing low pnt
if RetraceMethod = 2 then swingLoCondition = hi[0] > lastLo * (1 + Retrace * 0.01 ); // condition for swing low %
if RetraceMethod = 3 then swingLoCondition = hi[0] > lastLo + ( Retrace * AvgTrueRange( Period ) ); // condition for swing low ATR
if RetraceMethod = 4 then swingLoCondition = lo[0] > lastLo and hi[0] > hi[1]; // condition for swing low UTC

if not swingLoCondition then
begin
if lo[0] <= lastLo then // found an equal low or lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
end;
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;
// update current downswing line and text from lastHiBar
if PlotSwings then
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
if tl_exist(tl) then TL_SetEnd( tl, date[0],time[0], lastLo );
end;
plotText =

iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) ;

if text_exist(wavetxt) then Text_SetLocation( waveTxt, date[0],time[0], Low[0]-dis );
if text_exist(wavetxt) then Text_SetString( waveTxt, plotText );
end
else if swingLoCondition then // found a swing low
begin
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto ( CurrentBar - lastLoBar )
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;
// update current downswing line from lastHiBar
if PlotSwings then
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
if tl_exist(tl) then TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo);
end;
plotText =

iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) ;

if text_exist(wavetxt) then Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar]-dis);
if text_exist(wavetxt) then Text_SetString( waveTxt, plotText );

dir = 1; // trend direction is now up
lastHi = hi[0];
lastHiBar = CurrentBar; // now seeking new highs
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
{if PlotVolume then
begin
Plot1[x]( VolUp, "Volume Up" );
NoPlot[x]( 2 );
end;}
end;

if PlotSwings then // start new trendline from new swing low to most recent high
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
tl = TL_New( date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, UpColor );
end;
plotText =

NumToSTr( volUp / ScaleVolumeBy, 0 );

waveTxt = Text_New( date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar], plotText );
Text_SetStyle( waveTxt, 2, 1 );
{Text_SetSize( waveTxt, 8 );}
Text_SetColor( waveTxt, TextColor );
end;
end;


Started this thread Reply With Quote
Thanked by:
  #16 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

jiaqiangmit,

good job, I am glad to hear that. It's hard to tell why it's missing text and trendline in these situation and you will most likely have to look at the internal values of your code within those times to track down if and why the lines and text are missing or if they get updated/drawn to a wrong location. This might take a bit of work and digging.

Regards,

ABCTG

P.S.: You can "Thank" posts on future.io if you think they have been helpful or want to show your appreciation.


jiaqiangmit View Post
Thanks, I added " if tl_exist(tl) then /if text_exist(wavetxt) " before those IDs, and it's plotting now. However, there is still two problem, please see Pic below:


the latest codes are:


Follow me on Twitter Reply With Quote
Thanked by:
  #17 (permalink)
 jiaqiangmit 
Mianyang China
 
Experience: Beginner
Platform: Multicharts
Broker: broker: Oanda
Trading: HSI, DAX, ES
Posts: 84 since Aug 2017
Thanks Given: 18
Thanks Received: 10


ABCTG View Post
jiaqiangmit,

good job, I am glad to hear that. It's hard to tell why it's missing text and trendline in these situation and you will most likely have to look at the internal values of your code within those times to track down if and why the lines and text are missing or if they get updated/drawn to a wrong location. This might take a bit of work and digging.

Regards,

ABCTG

P.S.: You can "Thank" posts on future.io if you think they have been helpful or want to show your appreciation.

ABCTG,
Thanks again, I finally made it! It turned out that when I transfer the tl_SetEnd_Dt (tl, datetime[XX],ePrice] for MC into tl_SetEnd[tl,date[xx],time[xx],ePrice] for TS, I pasted the wrong Hi Lo prices. Now it works as it in MC.

BTW, the block below(in Multicharts) plot the histogram for the accumulative volume for a zigzag wave, it need to un-plot several histogram when the zigzag bounce up and down. How can I make it in TS?

Quoting 
if PlotVolume then
begin
noPlot[x](2);
plot1[1](volup,"volume up")
end;


Started this thread Reply With Quote
Thanked by:
  #18 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

jiaqiangmit,

you are welcome. You can not back reference NoPlot in Tradestation. One way to tackle this could be to set the plotcolor for that plot to transparent X bars back. Another way could be to set the plot to a value that is not visible on your chart (like 0 or 999999) and unchecking the option to "Expand Range to include Analysis Techniques" on the "Scaling" tab on the format symbol window.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #19 (permalink)
 jiaqiangmit 
Mianyang China
 
Experience: Beginner
Platform: Multicharts
Broker: broker: Oanda
Trading: HSI, DAX, ES
Posts: 84 since Aug 2017
Thanks Given: 18
Thanks Received: 10


ABCTG View Post
jiaqiangmit,

you are welcome. You can not back reference NoPlot in Tradestation. One way to tackle this could be to set the plotcolor for that plot to transparent X bars back. Another way could be to set the plot to a value that is not visible on your chart (like 0 or 999999) and unchecking the option to "Expand Range to include Analysis Techniques" on the "Scaling" tab on the format symbol window.

Regards,

ABCTG

setplotcolor(1,getplotbgcolor(1));

is this right?
and how to set it transparent?
Thanks.

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


jiaqiangmit,

you can find an example in here:


Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on January 19, 2018


© 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