Fort Worth, TX
Experience: Intermediate
Platform: Sierra, NinjaTrader
Trading: Futures
Posts: 3 since Mar 2011
Thanks Given: 0
Thanks Received: 0
|
Hello,
Can anyone convert this Tradovate code to NT8? I have no idea how easy/difficult this is. It's an indicator that plots Volatility/Std Deviation/ Fib levels based on prior days close and VIX/VXN close (user input).
The code is below. Thanks in advance.
const predef = require("./tools/predef");
class VixPredict {
init() {
this.OpenPrice = this.props.OpenPrice;
this.SettlementPrice = this.props.SettlementPrice;
this.VixOpen = this.props.VixOpen;
this.VixClose = this.props.VixClose;
this.ZTable = 0.0625;
}
map(d, i) {
//Calculate Move
const MoveO = this.VixOpen / 16;
const MoveS = this.VixClose / 16;
const SD = this.SettlementPrice * (this.VixClose / 100) * this.ZTable;
const Settle = this.SettlementPrice;
//standard deviation calculation
const Usd2 = this.SettlementPrice + (SD * 2);
const Usd175 = this.SettlementPrice + (SD * 1.75);
const Usd15 = this.SettlementPrice + (SD * 1.5);
const Usd125 = this.SettlementPrice + (SD * 1.25);
const Usd1 = this.SettlementPrice + SD;
const Usd75 = this.SettlementPrice + (0.75 * SD);
const Usd5 = this.SettlementPrice + (0.5 * SD);
const Usd25 = this.SettlementPrice + (0.25 * SD);
const Dsd25 = this.SettlementPrice - (0.25 * SD);
const Dsd5 = this.SettlementPrice - (0.5 * SD);
const Dsd75 = this.SettlementPrice - (0.75 * SD);
const Dsd1 = this.SettlementPrice - SD;
const Dsd125 = this.SettlementPrice - (SD * 1.25);
const Dsd15 = this.SettlementPrice - (SD * 1.5);
const Dsd175 = this.SettlementPrice - (SD * 1.75);
const Dsd2 = this.SettlementPrice - (SD * 2);
//Settlement Calculation
const SUFib4 = this.SettlementPrice + (this.SettlementPrice * (MoveS / 100 * 0.685));
const SUFib2 = this.SettlementPrice + (this.SettlementPrice * (MoveS / 100 * 0.382));
const SUFib1 = this.SettlementPrice + (this.SettlementPrice * (MoveS / 100 * 0.236));
const SDFib1 = this.SettlementPrice - (this.SettlementPrice * (MoveS / 100 * 0.236));
const SDFib2 = this.SettlementPrice - (this.SettlementPrice * (MoveS / 100 * 0.382));
const SDFib4 = this.SettlementPrice - (this.SettlementPrice * (MoveS / 100 * 0.685));
return {
//Standard Deviation Return
Usd2,
Usd175,
Usd15,
Usd125,
Usd1,
Usd75,
Usd5,
Usd25,
Dsd25,
Dsd5,
Dsd75,
Dsd1,
Dsd125,
Dsd15,
Dsd175,
Dsd2,
//Settlement Return
SUFib4,
SUFib2,
SUFib1,
SDFib1,
SDFib2,
SDFib4,
//Settle
Settle
};
}
}
module.exports = {
name: "Std. Dev Volatility",
description: "Std. Dev Volatility",
calculator: VixPredict,
params: {
SettlementPrice: predef.paramSpecs.number(3194.50, .01, 0),
VixClose: predef.paramSpecs.number(28.13, .01, 0),
},
tags: ["Patocalypse"],
plots: {
Settle: {title: "Settle"},
Usd2: { title: "+2.0 SD"},
Usd175: { title: "+1.75 SD"},
Usd15: { title: "+1.5 SD"},
Usd125: { title: "+1.25 SD"},
Usd1: { title: "+1.0 SD" },
Usd75: { title: "+0.75 SD" },
Usd5: { title: "+0.5 SD" },
Usd25: { title: "+0.25 SD" },
Dsd25: { title: "-0.25 SD" },
Dsd5: { title: "-0.5 SD" },
Dsd75: { title: "-0.75 SD" },
Dsd1: { title: "-1.0 SD" },
Dsd125: { title: "-1.25 SD"},
Dsd15: { title: "-1.5 SD" },
Dsd175: { title: "-1.75 SD"},
Dsd2: { title: "-2.0 SD"},
SUFib1: { title: "Settle +0.236" },
SUFib2: { title: "Settle +0.382" },
SUFib4: { title: "Settle +0.682" },
SDFib1: { title: "Settle -0.236" },
SDFib2: { title: "Settle -0.382" },
SDFib4: { title: "Settle -0.682" }
},
schemeStyles: {
dark: {
Settle: {color: "pink"},
Usd2: {color: "yellow"},
Usd175: {color: "yellow"},
Usd15: {color: "yellow"},
Usd125: {color: "yellow"},
Usd1: {color: "yellow"},
Usd75: {color: "yellow"},
Usd5: {color: "yellow"},
Usd25: {color: "yellow"},
Dsd25: {color: "yellow"},
Dsd5: {color: "yellow"},
Dsd75: {color: "yellow"},
Dsd1: {color: "yellow"},
Dsd125: {color: "yellow"},
Dsd15: {color: "yellow"},
Dsd175: {color: "yellow"},
Dsd2: {color: "yellow"},
SUFib1: {color: "blue"},
SUFib2: {color: "blue"},
SUFib4: {color: "blue"},
SDFib1: {color: "blue"},
SDFib2: {color: "blue"},
SDFib4: {color: "blue"}
}
}
};
|