The code below is for Tradestation paintbar. When all the conditions are met, the chart colors the bar blue. This is to be used on a 2 data stream chart. 1 Minute bars for data1 and 5 minute bars for data2. The metrics are calculated on data2
inputs:
PriceH( High of data2 ),
PriceL( Low of data2 ),
PriceC( Close of data2 ),
StochLength( 14 ),
SmoothingLength1( 1 ), { used to slow FastK to FastD = SlowK }
SmoothingLength2( 3 ), { used to slow FastD to SlowD }
SmoothingType( 1 ), { pass in 1 for Original, 2 for Legacy }
OverSold( 20 ),
OverBought( 80 ),
PRV(10000);
variables:
oFastK( 0 ),
oFastD( 0 ),
oSlowK( 0 ),
oSlowD( 0 ) ,
myMACD(0);
Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, oFastK, oFastD, oSlowK, oSlowD ) ;
myMACD= MACD(c of data2,5,13);
Condition1 = (ticks of data2 > PRV and myMACD >= .40 and oslowd >= overbought and oslowk >= overbought) or (ticks of data2 > PRV and myMACD <= -.40 and oslowd <= oversold and oslowk <= oversold) ;
Value1 = HIGH ;
Value2 = LOW ;
if Condition1 then
begin
PlotPaintBar( Value1, Value2 ) ;
Alert ;
end ;