- Joined
- 30 June 2007
- Posts
- 7,200
- Reactions
- 1,226
Panic averted, thank you Prof!
LookBack = Optimize("LookBack", 13, 1, 240, 1);
SlopeThresh = Optimize("SlopeDiff", 0.07, 0.01, 0.5, 0.05);
VolatilityThresh = Optimize("VolatilityThresh", 0.0025, 0.05, 1, 0.05);
Shift = Param("Shift", 0, 0, 500, 1);
x = Cum(1);
lastx = LastValue( x ) - Shift;
Intercept = LinRegIntercept( C, LookBack );
Slope = LinRegSlope( C, LookBack );
aa = LastValue( Ref(Intercept, 0 - Shift), False );
bb = LastValue( Ref(Slope, 0 - Shift), False );
LinRegLine = aa + bb * ( x - (lastx - LookBack + 1 ) );
width = VolatilityThresh * MA(C, LookBack);
Upper = IIf( x > (lastx - LookBack) AND BarIndex() < lastx, LinRegLine + width , Null ) ;
Lower = IIf( x > (lastx - LookBack) AND BarIndex() < lastx, LinRegLine - width , Null ) ;
printf( "Upper = %5.2f\n", Upper );
printf( "Lower = %5.2f\n", Lower );
ChannelColor = ParamColor("ChannelColor", colorGreen );
Plot( Upper, "Upper", ChannelColor );
Plot( Lower, "Lower", ChannelColor );
// check for channel slope
SlopeOk = abs( LastValue( Ref(Slope, -1), False ) ) <= SlopeThresh;
Didbreak = 0;
// check for channel break
i = 1;
while(LastValue(i, False) < LookBack)
{
DidBreak = IIf(Ref(High, 0 - i) > Ref(Upper, 0 - i) OR Ref(Low, 0 - i) < Ref(Lower, 0 - i), 1, 0);
printf("High[%5.2f] = %5.2f\n", 0 - i, Ref(High, 0 - i));
printf("Upper[%5.2f] = %5.2f\n", 0 - i, Ref(Upper, 0 - i));
printf("Low[%5.2f] = %5.2f\n", 0 - i, Ref(Low, 0 - i));
printf("Lower[%5.2f] = %5.2f\n", 0 - i, Ref(Lower, 0 - i));
printf("DidBreak = %5.2f\n", LastValue(DidBreak, False));
Temp = IIf( LastValue(DidBreak, False), LookBack, i);
i = Temp + 1;
}
Score = 0 ;
AddColumn(C, "Close");
AddColumn(width, "Width");
Filter = SlopeOk AND LastValue(DidBreak, False) <= 0;
PlotShapes( IIf( Filter, shapeHollowCircle, shapeNone ), colorOrange, 0, High);
I think you use the plottext function but I have no idea how to write the code and I need help.
Can anyone help me PLEASE. Graham Kavanagh is not accepting any work at the moment so I really need help. If its easier to convert the "mytext1" and "mytext2" part of this formula so that it displays the range (Difference in price between current swing and the last swing), Swing price level on the chart that would be better. Any guidance at all would be appreciated
textUPStartX = myGraph1 > Ref( MyGraph1, -1);
textDNStartX = myGraph1 < Ref( MyGraph1, -1);
dist = 0.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( textUPStartX ) PlotText( "MyText1" , i, myGraph1 [ i ]+dist,
colorGreen );
if( textDNStartX ) PlotText( "MyText2" , i, myGraph1 [ i ]-dist,
colorRed );
}
SYNTAX = SetForeign( ticker, fixup = True, tradeprices = False )
tradeprices parameter controls if trade price arrays should be replaced too. If it is set to TRUE, then not only OHLC, V, OI, Avg arrays are set to foreign symbol values, but also BuyPrice, SellPrice, ShortPrice, CoverPrice, PointValue, TickSize, RoundLotSize, MarginDeposit variables are set to correspond to foreign security.
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.