how to program this indicator script to work with stocks and not just futures - indicator

i found this.. posted it in the Amibroker editor.. saved.. found out after looking into it further.. that it will only work on futures that are listed in the if statements within the code.. i'd like to see this for stocks.. any ideas..
// ACD Plot
// LSMA is Linreg
// ACD.afl
// v 1.2 9/13/2004
SetChartBkColor(16);
Per = Param("Periods",13);
Per2 = Param("Periods 2",34);
LSMAPer = Param("LMSA Period",25);
Offset = Param("A Level",1);
ACDFlag = 0;
IntervalFlag = IIf(Interval(format=0)==300,1,0);
strInterval = Interval(format=2);
strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
if( StrFind( Name(), "YM" ) )
{
ACDOffset = 10;
ACDFlag = 1;
ACDTime = 94500;
}
if( StrFind( Name(), "ER" ) )
{
ACDOffset = 0.5;
ACDFlag = 1;
ACDTime = 93500;
}
if( StrFind( Name(), "ES" ) )
{
ACDOffset = 2;
ACDFlag = 1;
ACDTime = 94500;
}
if( StrFind( Name(), "NQ" ) )
{
ACDOffset = 3;
ACDFlag = 1;
ACDTime = 94500;
}
if( StrFind( Name(), "ZB" ) )
{
ACDOffset = 0.15;
ACDFlag = 1;
ACDTime = 83000;
}
if( StrFind( Name(), "ZN" ) )
{
ACDOffset = 0.15;
ACDFlag = 1;
ACDTime = 83000;
}
GraphXSpace = 1;
Shift = 2;
// calculate the pivot range
PDH = TimeFrameGetPrice( "H", inDaily, -1 ); // gives previous Day High when working on intraday data
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
PP = (PDH+PDL+PDC)/3;
DIFF = abs((PDH+PDL)/2 - PP);
PRHi = PP + DIFF;
PRLo = PP - DIFF;
EMA1 = EMA(Avg,Per);
EMA2 = EMA(Avg,Per2);
LSMA = LinearReg(Avg, LSMAPer);
Plot(C, "Close",colorWhite,styleCandle);
if (ACDFlag AND IntervalFlag) {
ORHigh= ValueWhen(TimeNum()<ACDTime,HighestSince(DateNum()>Ref(DateNum(),-1),High));
ORLow = ValueWhen(TimeNum()<ACDTime,LowestSince(DateNum()>Ref(DateNum(),-1), Low));
Plot(PRHi,"PRHigh",colorWhite,styleDots+styleNoLine+styleNoLabel);
Plot(PRLo,"PRLow",colorWhite,styleDots+styleNoLine+styleNoLabel);
Plot(ORHigh,"ORHigh",colorBlue,style=styleStaircase+styleDots+styleNoLine+styleNoLabel);
Plot(ORLow,"ORLow",colorBlue,style=styleStaircase+styleDots+styleNoLine+styleNoLabel);
Plot(ORHigh+ACDOffset,"AUp",colorYellow,style=styleStaircase+styleDots+styleNoLine);
Plot(ORLow-ACDOffset,"ADn",colorYellow,style=styleStaircase+styleDots+styleNoLine);
// Plot(LSMA, "LSMA", colorYellow,style=styleThick);
}
Title=Name()+" ["+strInterval+"] "+ strWeekday + " " +Date()+ " Close: "
+WriteVal(C,format=1.2) +" "+WriteVal(per,format=1.0)+"-Per MA: "
+WriteVal(EMA1,format=1.2)+" " + WriteVal(per2,format=1.0)+"-Per MA: "
+WriteVal(EMA2,format=1.2) + " PR High: "+WriteVal(PRHi,format=1.2) + " PR Low: "
+WriteVal(PRLo,format=1.2);

this is the response i got in Amibroker forum.. thought i would share the answer..
This is both indicator and an exploration (however – this code is using very old approach, now it’s much more convenient to use PLOT or ADDCOLUMN functions instead of this obsolete coding style)
There are just some errors in the formula, as it uses assignment instead of equality check, so you need to replace:
HiLo=IIf(HLv=-1,
with
HiLo=IIf(HLv == -1,
the same with - HiLoInvert=IIf(HLv=-1,
This is because == (double =) is an operator used for equality check.

Related

create my nribin code for logistf ,does it really work?

i need to creat my own nribin code , it can be used for logistf package outcome, i maybe work,please give me some advise!!!
i change z.std = mdl.std$x[,-1] to z.std = mdl.std$x
and cancle: link = mdl.std$family[[2]] and family=binomial(link),
the whole code is:
nribin_LTY <-
function (event=NULL, mdl.std=NULL, mdl.new=NULL, z.std=NULL, z.new=NULL, p.std=NULL, p.new=NULL,
updown='category', cut=NULL, link='logit', niter=1000, alpha=0.05, msg=TRUE) {
##
## type of calculation
flag.mdl = !is.null(mdl.std) && !is.null(mdl.new)
flag.prd = !is.null(z.std) && !is.null(z.new)
flag.rsk = !is.null(p.std) && !is.null(p.new)
##
## check standard & new model
if (flag.mdl) {
if (is.null(event)) event = as.numeric(mdl.std$y)
if (is.null(mdl.std$x) || is.null(mdl.new$x))
stop("\n\nmodel object does not contain predictors. pls set x=TRUE for model calculation.\n\n")
z.std = mdl.std$x
z.new = mdl.new$x
mdl.std = glm(event ~ ., data=as.data.frame(cbind(event, z.std)))
mdl.new = glm(event ~ ., data=as.data.frame(cbind(event, z.new)))
} else if (flag.prd) {
mdl.std = glm(event ~ ., data=as.data.frame(cbind(event, z.std)))
mdl.new = glm(event ~ ., data=as.data.frame(cbind(event, z.new)))***
message("\nSTANDARD prediction model:")
print(summary(mdl.std)$coef)
message("\nNEW prediction model:")
print(summary(mdl.new)$coef)
} else if (!flag.mdl && !flag.prd && !flag.rsk) {
stop("\n\neither one of 'event, z.std, z.new', 'event, p.std, p.new', and 'mdl.std, mdl.new' should be specified.\n\n")
}
if (is.null(cut))
stop("\n\n'cut' is empty")
objs = list(mdl.std, mdl.new, z.std, z.new, p.std, p.new)
##
## DH & DL
wk = get.uppdwn.bin(event, objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg=msg)
upp = wk[[1]]
dwn = wk[[2]]
ret = list(mdl.std=mdl.std, mdl.new=mdl.new, p.std=wk[[3]], p.new=wk[[4]], up=upp, down=dwn, rtab=wk[[5]], rtab.case=wk[[6]], rtab.ctrl=wk[[7]])
##
## point estimation
message("\nNRI estimation:")
est = nribin.count.main(event, upp, dwn)
message("Point estimates:")
result = data.frame(est)
names(result) = 'Estimate'
row.names(result) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
print(result)
##
## interval estimation
if (niter > 0) {
message("\nNow in bootstrap..")
ci = rep(NA, 14)
N = length(event)
samp = matrix(NA, niter, 7)
colnames(samp) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
for (b in 1:niter) {
f = as.integer(runif(N, 0, N)) + 1
objs = list(mdl.std, mdl.new, z.std[f,], z.new[f,], p.std[f], p.new[f])
wk = get.uppdwn.bin(event[f], objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg=FALSE)
upp = wk[[1]]
dwn = wk[[2]]
samp[b,] = nribin.count.main(event[f], upp, dwn)
}
ret = c(ret, list(bootstrapsample=samp))
ci = as.numeric(apply(samp, 2, quantile, c(alpha/2, 1-alpha/2), na.rm=TRUE, type=2))
se = as.numeric(apply(samp, 2, sd))
message("\nPoint & Interval estimates:")
result = as.data.frame(cbind(est, se, matrix(ci, ncol=2, byrow=TRUE)))
names(result) = c('Estimate', 'Std.Error', 'Lower', 'Upper')
row.names(result) = c('NRI','NRI+','NRI-','Pr(Up|Case)','Pr(Down|Case)','Pr(Down|Ctrl)','Pr(Up|Ctrl)')
print(result)
}
invisible(c(list(nri=result), ret))
}
It is need to add variable matrix to logistf outcome,such as:
x.std=as.matrix(thromb2[,c(8,9,10,14,21,22,24,25,26)])
mstd = logistf(formula=fml.std, firth = FALSE,
data = thromb2, x=TRUE)
mstd =backward(mstd)
mstd$x <- x.std

lights out game using CORONA SDK

am trying to devalope a lights out game with CORONA SDK
but am not able to figure out a way for looping it !!!
how many functions to create and the way to keep this going
here is my code (its dummy but a friend gave it to me as am trying to go on from there )
obj = nil
px = 35
py = 50
r = 22
xi = 60
yi = 60
x1y1 = display.newCircle(px+xi*0,py+yi*0,r) x1y1.id = "x1y1"
x2y1 = display.newCircle(px+xi*1,py+yi*0,r) x2y1.id = "x2y1"
x3y1 = display.newCircle(px+xi*2,py+yi*0,r) x3y1.id = "x3y1"
x4y1 = display.newCircle(px+xi*3,py+yi*0,r) x4y1.id = "x4y1"
x5y1 = display.newCircle(px+xi*4,py+yi*0,r) x5y1.id = "x5y1"
x1y2 = display.newCircle(px+xi*0,py+yi*1,r) x1y2.id = "x1y2"
x2y2 = display.newCircle(px+xi*1,py+yi*1,r) x2y2.id = "x2y2"
x3y2 = display.newCircle(px+xi*2,py+yi*1,r) x3y2.id = "x3y2"
x4y2 = display.newCircle(px+xi*3,py+yi*1,r) x4y2.id = "x4y2"
x5y2 = display.newCircle(px+xi*4,py+yi*1,r) x5y2.id = "x5y2"
x1y3 = display.newCircle(px+xi*0,py+yi*2,r) x1y3.id = "x1y3"
x2y3 = display.newCircle(px+xi*1,py+yi*2,r) x2y3.id = "x2y3"
x3y3 = display.newCircle(px+xi*2,py+yi*2,r) x3y3.id = "x3y3"
x4y3 = display.newCircle(px+xi*3,py+yi*2,r) x4y3.id = "x4y3"
x5y3 = display.newCircle(px+xi*4,py+yi*2,r) x5y3.id = "x5y3"
x1y4 = display.newCircle(px+xi*0,py+yi*3,r) x1y4.id = "x1y4"
x2y4 = display.newCircle(px+xi*1,py+yi*3,r) x2y4.id = "x2y4"
x3y4 = display.newCircle(px+xi*2,py+yi*3,r) x3y4.id = "x3y4"
x4y4 = display.newCircle(px+xi*3,py+yi*3,r) x4y4.id = "x4y4"
x5y4 = display.newCircle(px+xi*4,py+yi*3,r) x5y4.id = "x5y4"
x1y5 = display.newCircle(px+xi*0,py+yi*4,r) x1y5.id = "x1y5"
x2y5 = display.newCircle(px+xi*1,py+yi*4,r) x2y5.id = "x2y5"
x3y5 = display.newCircle(px+xi*2,py+yi*4,r) x3y5.id = "x3y5"
x4y5 = display.newCircle(px+xi*3,py+yi*4,r) x4y5.id = "x4y5"
x5y5 = display.newCircle(px+xi*4,py+yi*4,r) x5y5.id = "x5y5"
bb = {x1y1,x2y1,x3y1,x4y1,x5y1,x1y2,x2y2,x3y2,x4y2,x5y2,x1y3,x2y3,x3y3,x4y3,x5y3,x1y4,x2y4,x3y4,x4y4,x5y4,x1y5,x2y5,x3y5,x4y5,x5y5}
iClicked = 0
function click(e)
if(e.phase == "ended") then
--circleID = e.target.id
--whichCircle()
print(e.target.id)
obj = e.target
for u=1,25 do
if(obj==bb[u]) then
iClicked = u
end
end
if((iClicked-5) > 0 and (iClicked-5) < 26) then
bb[iClicked-5]:setFillColor(1,0,0)
end
if((iClicked-1) > 0 and (iClicked-1) < 26) then
bb[iClicked-1]:setFillColor(1,0,0)
end
obj:setFillColor(1,0,0)
if((iClicked+1) > 0 and (iClicked+1) < 26) then
bb[iClicked+1]:setFillColor(1,0,0)
end
if((iClicked+5) > 0 and (iClicked+5) < 26) then
bb[iClicked+5]:setFillColor(1,0,0)
end
end
end
for k=1,25 do
bb[k]:addEventListener("touch",click)
end
its all about having 25 circles and lighting them on and off but it doesnt seem to work for me
any good help will be great
Thanks
local myCircles = {}
for y = 1, 5 do
myCircles[y] = {}
for x = 1, 5 do
myCircles[y][x] = display.newCircle(px+xi*0,py+yi*4,r)
myCircles[y][x].id = .id = "x" .. x .. "y" .. y
end
end
or something like that.
Rob

Remove animation at the end of the loop count

I'm using the following code to play explosion animation, How can I removeSelf the animation when it finished the loop-count?
function showExplotion(event)
local sheetData = { width=32, height=32, numFrames=13, sheetContentWidth=128, sheetContentHeight=128 }
local mySheet = graphics.newImageSheet( "media/fire.png", sheetData )
local sequenceData = {
--{ name = "normalRun", start=1, count=13, loopCount = 1, time=800 }
{ name = "fastRun", frames={ 1,2,4,5,6,7,8,9,10,11,12,13 }, time=800, loopCount = 1 }
}
local animation = display.newSprite( mySheet, sequenceData )
animation.x = event.x
animation.y = event.y
animation:play()
end
you can add listener to your sprite animation to detect it's phase
function showExplotion(event)
local sheetData = { width=32, height=32, numFrames=13, sheetContentWidth=128, sheetContentHeight=128 }
local mySheet = graphics.newImageSheet( "media/fire.png", sheetData )
local sequenceData = {
--{ name = "normalRun", start=1, count=13, loopCount = 1, time=800 }
{ name = "fastRun", frames={ 1,2,4,5,6,7,8,9,10,11,12,13 }, time=800, loopCount = 1 }
}
local animation = display.newSprite( mySheet, sequenceData )
animation.x = event.x
animation.y = event.y
animation:play()
local function mySpriteListener( event )
if ( event.phase == "ended" ) then
animation:removeSelf()
animation = nil
end
end
animation:addEventListener( "sprite", mySpriteListener )
end

Access NSDictionary values

I have a JSon object like this
{
Attendance = {
Attendance = (
{
EmployeeCode = 7593;
InDate = "27/02/2013";
InTime = "08:11";
InTime2 = "00:00";
OutDate = "27/02/2013";
OutDate2 = "01/01/1901";
OutTime = "17:42";
OutTime2 = "00:00";
Present = 1;
}
);
AttendanceCount = 1;
};
AuthPersons = {
WFAuthCount = 1;
WfAuthPersons = (
{
LsAuthls = (
{
AuthEmployeeName = "SAMPLE NAME";
EmployeeCode = 4813;
}
);
RequestTypeCode = 5;
WFID = 99;
"WF_LevelID" = 2;
WorkFlowName = "EHL - Group HR (Kanchana/Asitha)";
}
);
};
}
What I wanted is to get these employeecode,IntDate... seperately So I get a seperate NSDictionary NSDictionary *summary = [resultJSON objectForKey:#"Attendance"];
and return it into my Viewcontroller method inside my Viewcontroller I have done like this.
` nsDicttendanceReqDate = [[ws GetWorkflowInfoAttendanceRequest:[NSString stringWithFormat:#"%d",usr.empCode] : #"5" :usr.stringRequestDate] copy];
dicDates= [nsDicttendanceReqDate objectForKey:#"Attendance"] ;
//dicDates=[nsDicttendanceReqDatey JSONValue];
NSLog(#"%d",[dicDates count]);
NSLog(#"DIC DATES%#",dicDates);
NSLog(#"%#",nsDicttendanceReqDate);
if ([nsDicttendanceReqDate count] > 0 ) {
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"EmployeeCode"]);
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"OutDate"] );
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"InDate"] );`
But these are getting inside paranthesis. How can I solve this.Any one can tell me how to extract this values.
Try This.It might be a help.
NSDictionary *summary = [resultJSON valueForKey:#"Attendance"]objectAtIndex:0];

Script to export layer coordinates to excel

I have found a script that export my layers coordinates form photoshop CS5 to XML
I hope somebody here can help me to edit that script to record coordinates to xls file?
Also if is possible to have each coordinates on separate row will be great.
Below is script I want to modify to do what I need.
//
// This script exports extended layer.bounds information to [psd_file_name].xml
// by pattesdours
//
function docCheck() {
// ensure that there is at least one document open
if (!documents.length) {
alert('There are no documents open.');
return; // quit
}
}
docCheck();
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var docRef = activeDocument;
var docWidth = docRef.width.value;
var docHeight = docRef.height.value;
var mySourceFilePath = activeDocument.fullName.path + "/";
// Code to get layer index / descriptor
//
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function getLayerDescriptor (doc, layer) {
var ref = new ActionReference();
ref.putEnumerated(cTID("Lyr "), cTID("Ordn"), cTID("Trgt"));
return executeActionGet(ref)
};
function getLayerID(doc, layer) {
var d = getLayerDescriptor(doc, layer);
return d.getInteger(cTID('LyrI'));
};
var stackorder = 0;
// function from Xbytor to traverse all layers
traverseLayers = function(doc, ftn, reverse) {
function _traverse(doc, layers, ftn, reverse) {
var ok = true;
for (var i = 1; i <= layers.length && ok != false; i++) {
var index = (reverse == true) ? layers.length-i : i - 1;
var layer = layers[index];
if (layer.typename == "LayerSet") {
ok = _traverse(doc, layer.layers, ftn, reverse);
} else {
stackorder = stackorder + 1;
ok = ftn(doc, layer, stackorder);
}
}
return ok;
};
return _traverse(doc, doc.layers, ftn, reverse);
};
// create a string to hold the data
var str ="";
// class using a contructor
function cLayer(doc, layer) {
//this.layerID = Stdlib.getLayerID(doc, layer);
this.layerID = getLayerID(doc, layer);
//alert("layer ID: " + this.layerID);
this.layerWidth = layer.bounds[2].value - layer.bounds[0].value;
this.layerHeight = layer.bounds[3].value - layer.bounds[1].value;
// these return object coordinates relative to canvas
this.upperLeftX = layer.bounds[0].value;
this.upperLeftY = layer.bounds[1].value;
this.upperCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.upperCenterY = layer.bounds[1].value;
this.upperRightX = layer.bounds[2].value;
this.upperRightY = layer.bounds[1].value;
this.middleLeftX = layer.bounds[0].value;
this.middleLeftY = this.layerHeight / 2 + layer.bounds[1].value;
this.middleCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.middleCenterY = this.layerHeight / 2 + layer.bounds[1].value;
this.middleRightX = layer.bounds[2].value;
this.middleRightY = this.layerHeight / 2 + layer.bounds[1].value;
this.lowerLeftX = layer.bounds[0].value;
this.lowerLeftY = layer.bounds[3].value;
this.lowerCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.lowerCenterY = layer.bounds[3].value;
this.lowerRightX = layer.bounds[2].value;
this.lowerRightY = layer.bounds[3].value;
// I'm adding these for easier editing of flash symbol transformation point (outputs a 'x, y' format)
// because I like to assign shortcut keys that use the numeric pad keyboard, like such:
// 7 8 9
// 4 5 6
// 1 2 3
//
this.leftBottom = this.lowerLeftX + ", " + this.lowerLeftY;
this.bottomCenter = this.lowerCenterX + ", " + this.lowerCenterY;
this.rightBottom = this.lowerRightX + ", " + this.lowerRightY;
this.leftCenter = this.middleLeftX + ", " + this.middleLeftY;
this.center = this.middleCenterX + ", " + this.middleCenterY;
this.rightCenter = this.middleRightX + ", " + this.middleRightY;
this.leftTop = this.upperLeftX + ", " + this.upperLeftY;
this.topCenter = this.upperCenterX + ", " + this.upperCenterY;
this.rightTop = this.upperRightX + ", " + this.upperRightY;
// these return object coordinates relative to layer bounds
this.relUpperLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relUpperLeftY = layer.bounds[0].value - layer.bounds[0].value;
this.relUpperCenterX = this.layerWidth / 2;
this.relUpperCenterY = layer.bounds[0].value - layer.bounds[0].value;
this.relUpperRightX = this.layerWidth;
this.relUpperRightY = layer.bounds[0].value - layer.bounds[0].value;
this.relMiddleLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relMiddleLeftY = this.layerHeight / 2;
this.relMiddleCenterX = this.layerWidth / 2;
this.relMiddleCenterY = this.layerHeight / 2;
this.relMiddleRightX = this.layerWidth;
this.relMiddleRightY = this.layerHeight / 2;
this.relLowerLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relLowerLeftY = this.layerHeight;
this.relLowerCenterX = this.layerWidth / 2;
this.relLowerCenterY = this.layerHeight / 2;
this.relLowerRightY = this.layerHeight;
this.relLowerRightX = this.layerWidth;
this.relLowerRightY = this.layerHeight;
return this;
}
// add header line
//str = "<psd filename=\"" + docRef.name + "\" path=\"" + mySourceFilePath + "\" width=\"" + docWidth + "\" height=\"" + docHeight + "\">\n";
// now a function to collect the data
function exportBounds(doc, layer, i) {
var isVisible = layer.visible;
var layerData = cLayer(doc, layer);
// if(isVisible){
// Layer object main coordinates relative to its active pixels
var str2 = leftTop // this is the
// + "\" layerwidth=\"" + layerData.layerWidth
// + "\" layerheight=\"" + layerData.layerHeight
// + "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point
+"\" \"" + layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored
str += str2.toString();
};
//};
// call X's function using the one above
traverseLayers(app.activeDocument, exportBounds, true);
// Use this to export XML file to same directory where PSD file is located
var mySourceFilePath = activeDocument.fullName.path + "/";
// create a reference to a file for output
var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xls");
// open the file, write the data, then close the file
csvFile.open('w');
csvFile.writeln(str + "</psd>");
csvFile.close();
preferences.rulerUnits = originalRulerUnits;
// Confirm that operation has completed
alert("Operation Complete!" + "\n" + "Layer coordinates were successfully exported to:" + "\n" + "\n" + mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml");
Change
var str2 = leftTop // this is the
// + "\" layerwidth=\"" + layerData.layerWidth
// + "\" layerheight=\"" + layerData.layerHeight
// + "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point
+"\" \"" + layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored
str += str2.toString();
to
var str2 = leftTop + ","+ layer.name + "\n"
str += str2.toString();
and
var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xls");
to
var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".csv");
This works great for me!

Resources