Hi ,
I have three charts. 512T, 3500T and 5M. And I've been struggling with getting consistent price bars on these charts for open price, first 15 mins price-range, pre-market price range, prev-day price range across these charts. When I load the same study on the three charts, they come up with different numbers and as a result I endup with in-consistent indicators on all the three charts. I tried to have a fourth chart (1 Sec) that would set global values for the above and then the studies on the 512T, 3500T, and 5M charts just read the global values, but that causes a lot of performance issues as I need to load a lot of bars for 1 sec chart to span back to previous day. Any help would be deeply appreciated. Here's my code for calculating open and first 15min high/low -
//OPEN
var openPrice = null;
//OPEN RANGE
var openRangeHigh = null;
var openRangeLow = null;
var tempOpenRangeHigh = null;
var tempOpenRangeLow = null;
function preMain() {
setPriceStudy(true);
}
function main() {
var barIndex = getCurrentBarIndex();
var curHour = null;
var curMin = null;
var todayDate = null;
var lastTrade = null;
//Logic to figure out if we're in present or in the past
if(barIndex == 0) {
today = new Date();
todayDate = today.getDate();
curHour = today.getHours()+3;
curMin = today.getMinutes();
lastTrade = getMostRecentTrade();
} else {
today = getDay();
curHour = getHour();
curMin = getMinute();
lastTrade = close();
}
//Prepare counters for the next trading day
if(openPrice != null && curHour == 16 && curMin >= 0) {
openPrice = null;
openRangeHigh = null;
openRangeLow = null;
}
//OPEN PRICE
if(openPrice == null && curHour == 9 && curMin == 30){
openPrice = lastTrade;
}
//OPEN RANGE
if(openRangeHigh == null && curHour == 9 && curMin >= 30){
if(tempOpenRangeHigh == null || tempOpenRangeHigh < lastTrade){
tempOpenRangeHigh = lastTrade;
}
if(tempOpenRangeLow == null || tempOpenRangeLow > lastTrade){
tempOpenRangeLow = lastTrade;
}
//Trigger for setting and plotting the range
if(curMin >= (45)){
openRangeHigh = tempOpenRangeHigh;
openRangeLow = tempOpenRangeLow;
}
}
}
Thanks!
EsigTrader
I have three charts. 512T, 3500T and 5M. And I've been struggling with getting consistent price bars on these charts for open price, first 15 mins price-range, pre-market price range, prev-day price range across these charts. When I load the same study on the three charts, they come up with different numbers and as a result I endup with in-consistent indicators on all the three charts. I tried to have a fourth chart (1 Sec) that would set global values for the above and then the studies on the 512T, 3500T, and 5M charts just read the global values, but that causes a lot of performance issues as I need to load a lot of bars for 1 sec chart to span back to previous day. Any help would be deeply appreciated. Here's my code for calculating open and first 15min high/low -
//OPEN
var openPrice = null;
//OPEN RANGE
var openRangeHigh = null;
var openRangeLow = null;
var tempOpenRangeHigh = null;
var tempOpenRangeLow = null;
function preMain() {
setPriceStudy(true);
}
function main() {
var barIndex = getCurrentBarIndex();
var curHour = null;
var curMin = null;
var todayDate = null;
var lastTrade = null;
//Logic to figure out if we're in present or in the past
if(barIndex == 0) {
today = new Date();
todayDate = today.getDate();
curHour = today.getHours()+3;
curMin = today.getMinutes();
lastTrade = getMostRecentTrade();
} else {
today = getDay();
curHour = getHour();
curMin = getMinute();
lastTrade = close();
}
//Prepare counters for the next trading day
if(openPrice != null && curHour == 16 && curMin >= 0) {
openPrice = null;
openRangeHigh = null;
openRangeLow = null;
}
//OPEN PRICE
if(openPrice == null && curHour == 9 && curMin == 30){
openPrice = lastTrade;
}
//OPEN RANGE
if(openRangeHigh == null && curHour == 9 && curMin >= 30){
if(tempOpenRangeHigh == null || tempOpenRangeHigh < lastTrade){
tempOpenRangeHigh = lastTrade;
}
if(tempOpenRangeLow == null || tempOpenRangeLow > lastTrade){
tempOpenRangeLow = lastTrade;
}
//Trigger for setting and plotting the range
if(curMin >= (45)){
openRangeHigh = tempOpenRangeHigh;
openRangeLow = tempOpenRangeLow;
}
}
}
Thanks!
EsigTrader
Comment