Austin, TX
Experience: Intermediate
Platform: NinjaTrader, TOS
Broker: TOS, NinjaTrader, IBKR
Trading: Futures
Posts: 1 since Apr 2011
Thanks Given: 0
Thanks Received: 0
|
I have a small ThinkScript indicator that I would like to convert to NinjaScript. I got started but I would like some assistance from someone who is better versed in doing such conversions. Thanks in advance.
declare once_per_bar;
def NetChgAvg = MovingAverage(AverageType.WILDERS, close - close[1], 14);
def theta = GetYYYYMMDD();
def LRV = Inertia(close - ((Highest(high, 20) + Lowest(low, 20)) / 2 + ExpAverage(close, 20)) / 2, 20);
def Value = MovingAverage(AverageType.EXPONENTIAL, close, 10) - MovingAverage(AverageType.EXPONENTIAL, close, 50);
def Avg = MovingAverage(AverageType.EXPONENTIAL, Value, 9);
def periodIndx = theta;
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def VWAP = volumeVwapSum / volumeSum;
def RTH = if SecondsTillTime(1600) >= 0 and SecondsFromTime(925) >= 0 then 1 else 0;
def bulltrend = if ((Value > 0 and Avg > 0)) and (LRV > 0 and NetChgAvg > 0) and close[1] > VWAP[1] and close > VWAP then 1 else 0;
def beartrend = if ((Value < 0 and Avg < 0)) and (LRV < 0 and NetChgAvg < 0) and close[1] < VWAP[1] and close < VWAP then 1 else 0;
AssignPriceColor(if bulltrend then Color.GREEN else if beartrend then Color.RED else Color.BLUE);
|