Hi,
I have an efs to plot trades on the charts.
I apply this study on a ES 2min charts with RTH time template ( 9:30am - 16:15pm )
If I view the plot outside RTH it work fine. But during RTH it shift the line everytime a new 2 min bar close.
What do I need to add/change to the code to stop shifting the line.
Thank you
Tony
I have an efs to plot trades on the charts.
I apply this study on a ES 2min charts with RTH time template ( 9:30am - 16:15pm )
If I view the plot outside RTH it work fine. But during RTH it shift the line everytime a new 2 min bar close.
What do I need to add/change to the code to stop shifting the line.
Thank you
Tony
PHP Code:
/*
Tony Hariman August 2nd 2009
The goal for this program is to load csv file from my trading platform and plot the entry exit on the charts.
This is what the csv file look like:
"Entry Time","Exit Time","Symbol","Side","Quantity","Entry Price","Exit Price","P/L","Gross Profit","Net Profit","Time in Trade","MAE","MFE","Strategy","Live/Simulation","Trade #"
"7/28/2009 9:49:58 AM","7/28/2009 9:53:10 AM","ES","Long",1,978.25,977,-1.25,-62.5,-67.3,"03:11",-1,.25,"Default Strategy","Live",1
"7/28/2009 10:03:29 AM","7/28/2009 10:16:06 AM","ES","Short",1,974.5,970.5,4,200,195.2,"12:37",-1,3.75,"Default Strategy","Live",2
"7/28/2009 10:37:55 AM","7/28/2009 10:39:30 AM","ES","Short",1,971.5,972.5,-1,-50,-54.8,"01:35",-1,0,"Default Strategy","Live",3
So far I'm concentrating on plotting the trade in the charts
I use perl to convert the csv file to GoLong and GoShort and copy paste to this efs
This perl will also round down to the nearest 2 min bar chart for the entry and exit time.
I get the logic for this efs from one of the users in the forum.
*/
function preMain() {
setPriceStudy(true);
setStudyTitle("Trades Plot");
}
var Index = null;
var BeginIndex = null;
var cntr = 0;
var cntr2 = 0;
var vDay = null;
var vMonth = null;
function main() {
var vTime = new Date();
vTime = getValue("Time", 0);
vDay = vTime.getDate();
vMonth = vTime.getMonth() + 1;
Index = getCurrentBarIndex();
BarHr = getHour();
BarMin = getMinute();
BarSec = getSecond();
CurrentTime = BarHr * 10000 + BarMin * 100 + BarSec * 1;
GoLong(7, 23, 95400, 95600, 956.00, 957.00); // 95537 95609 1
GoLong(7, 23, 110000, 110200, 968.50, 969.50); // 110121 110342 1
GoLong(7, 23, 111000, 111400, 970.50, 972.00); // 111113 111419 1.5
GoShort(7, 27, 101200, 101400, 974.50, 972.25); // 101204 101429 2.25
GoShort(7, 27, 103000, 104800, 971.25, 970.25); // 103002 104832 1
GoLong(7, 27, 110000, 111000, 971.25, 971.75); // 110111 111102 .5
GoShort(7, 28, 100200, 101600, 974.50, 970.50); // 100329 101606 4
GoShort(7, 29, 95000, 95600, 969.75, 969.00); // 95147 95609 .75
GoLong(7, 30, 95200, 95400, 984.25, 987.25); // 95204 95512 3
GoLong(7, 30, 103800, 103800, 993.00, 993.50); // 103800 103815 .5
return null;
}
function GoLong(LongMonth, LongDay, LongEntryTime, LongExitTime, LongEntryPrice, LongExitPrice) {
if (vMonth == LongMonth && vDay == LongDay) {
if (CurrentTime == LongEntryTime) {
BeginIndex = Index;
cntr2 += 1;
drawShapeAbsolute(Index - 1, LongEntryPrice, Shape.RIGHTARROW, null, Color.blue, Shape.LEFT | Shape.ONTOP, cntr2);
}
if (CurrentTime == LongExitTime) {
cntr += 1;
if (LongEntryTime == LongExitTime) { // draw line if trade happen in the same bar
//drawShapeAbsolute( Index-1 , LongEntryPrice, Shape.RIGHTARROW, null, Color.yellow, Shape.LEFT | Shape.ONTOP, null );
drawLineAbsolute(BeginIndex - 1, LongEntryPrice, Index + 1, LongEntryPrice, PS_SOLID, 2, Color.black, "Line" + cntr);
cntr += 1;
drawLineAbsolute(BeginIndex - 1, LongExitPrice, Index + 1, LongExitPrice, PS_SOLID, 2, Color.black, "Line" + cntr);
} else {
drawLineAbsolute(BeginIndex, LongEntryPrice, Index, LongExitPrice, PS_SOLID, 2, Color.blue, "Line" + cntr);
}
cntr2 += 1;
drawShapeAbsolute(Index + 1, LongExitPrice, Shape.LEFTARROW, null, Color.blue, Shape.LEFT | Shape.ONTOP, cntr2);
}
}
return null;
}
function GoShort(ShortMonth, ShortDay, ShortEntryTime, ShortExitTime, ShortEntryPrice, ShortExitPrice) {
if (vMonth == ShortMonth && vDay == ShortDay) {
//debugPrintln( " CurrentTime:" + CurrentTime + " Entry:" + ShortEntryTime + " Exit:" + ShortExitTime);
if (CurrentTime == ShortEntryTime) {
BeginIndex = Index;
cntr2 += 1;
drawShapeAbsolute(Index - 1, ShortEntryPrice, Shape.RIGHTARROW, null, Color.yellow, Shape.LEFT | Shape.ONTOP, cntr2);
}
if (CurrentTime == ShortExitTime) {
cntr += 1;
if (ShortEntryTime == ShortExitTime) { // draw line if trade happen in the same bar
//drawShapeAbsolute( Index-1 , ShortEntryPrice, Shape.RIGHTARROW, null, Color.yellow, Shape.LEFT | Shape.ONTOP, null );
drawLineAbsolute(BeginIndex - 1, ShortEntryPrice, Index + 1, ShortEntryPrice, PS_SOLID, 2, Color.black, "Line" + cntr);
cntr += 1;
drawLineAbsolute(BeginIndex - 1, ShortExitPrice, Index + 1, ShortExitPrice, PS_SOLID, 2, Color.black, "Line" + cntr);
} else {
drawLineAbsolute(BeginIndex, ShortEntryPrice, Index, ShortExitPrice, PS_SOLID, 2, Color.yellow, "Line" + cntr);
}
cntr2 += 1;
drawShapeAbsolute(Index + 1, ShortExitPrice, Shape.LEFTARROW, null, Color.yellow, Shape.LEFT | Shape.ONTOP, cntr2);
}
}
return null;
}
Comment