Hello
Could someone please explain to me on the attached code:
1.) The box drawn on line 42 does not appear on the chart immediately when the EFS is loaded but sometimes after the third or fourth bar sometimes not.
I thought that this line should be executed immediately on loading the efs?
For an action like this that I only want to be executed once, is there a more efficient way to "call" it or does the current way not place additional strain on resources as it would seem to me to be "called" every tic?
2.) If I change a function parameter on this EFS, eSignal freezes for 5.5seconds (despite this being a Dual Core with 3 g of ram). Presumably there is some code causing this issue; could you give me an idea what it could be?
3.) Can I call a drawing function outside of main() as per lines 65 and 77? The butons are not being drawn and I cannot see why.
Thanks in anticipation
[code]
function preMain() {
setStudyTitle("IB Trade");
setPriceStudy(true);
setShowCursorLabel(false);
// default parameters
var fp0 = new FunctionParameter("PSL", FunctionParameter.NUMBER);
fp0.setName("PSL");
//fp0.setLowerLimit(1);
fp0.setDefault(20);
var fp1 = new FunctionParameter("Risk", FunctionParameter.NUMBER);
fp1.setName("Risk");
fp1.setDefault(1500);
var nSize
}
function main(PSL,Risk){
var bLong = false
var nLast = close()
var nAsk = getMostRecentAsk()
var nBid = getMostRecentAsk()
var nRiskC = (nLast - PSL)
//Draw the PSL line
drawLineAbsolute(-40, PSL, 20, PSL, PS_SOLID, 2,Color.red,105 );
//Draw the box for the buttons
drawTextAbsolute(5, 15, " ",
Color.black, Color.lightgrey,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.BOLD | Text.CENTER,
"Arial", 60, "border");
// Draw Edit parameter button
drawTextAbsolute(5, 17, "Parameters @URL=EFS:editParameters", Color.black, Color.grey,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.ONTOP | Text.CENTER,
"Arial", 10, "msg");
//Specify long trade: true or false
if(nLast > PSL) {
bLong = true
}
debugPrintln("This is a long trade? " +bLong)
if(bLong) {
DrawBuy();
} else {
DrawSell();
}
}
// Button to change parameters
function editParameters(nButtonPressed){
if(nButtonPressed == BUTTON_RIGHT) nClick++;
askForInput("Trading Parameters")
}
function DrawBuy(){
drawTextAbsolute(5, 49, " Buy @URL=EFS:BuyCallBack",
Color.white, Color.green,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.ONTOP | Text.BOLD | Text.CENTER,
"Arial", 12, "OB");
}
function DrawSell(){
drawTextAbsolute(5, 29, " Sell @URL=EFS:SellCallBack",
Color.white, Color.red,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.ONTOP | Text.BOLD | Text.CENTER,
"Arial", 12, "OS");
}
[/code ]
Could someone please explain to me on the attached code:
1.) The box drawn on line 42 does not appear on the chart immediately when the EFS is loaded but sometimes after the third or fourth bar sometimes not.
I thought that this line should be executed immediately on loading the efs?
For an action like this that I only want to be executed once, is there a more efficient way to "call" it or does the current way not place additional strain on resources as it would seem to me to be "called" every tic?
2.) If I change a function parameter on this EFS, eSignal freezes for 5.5seconds (despite this being a Dual Core with 3 g of ram). Presumably there is some code causing this issue; could you give me an idea what it could be?
3.) Can I call a drawing function outside of main() as per lines 65 and 77? The butons are not being drawn and I cannot see why.
Thanks in anticipation
[code]
function preMain() {
setStudyTitle("IB Trade");
setPriceStudy(true);
setShowCursorLabel(false);
// default parameters
var fp0 = new FunctionParameter("PSL", FunctionParameter.NUMBER);
fp0.setName("PSL");
//fp0.setLowerLimit(1);
fp0.setDefault(20);
var fp1 = new FunctionParameter("Risk", FunctionParameter.NUMBER);
fp1.setName("Risk");
fp1.setDefault(1500);
var nSize
}
function main(PSL,Risk){
var bLong = false
var nLast = close()
var nAsk = getMostRecentAsk()
var nBid = getMostRecentAsk()
var nRiskC = (nLast - PSL)
//Draw the PSL line
drawLineAbsolute(-40, PSL, 20, PSL, PS_SOLID, 2,Color.red,105 );
//Draw the box for the buttons
drawTextAbsolute(5, 15, " ",
Color.black, Color.lightgrey,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.BOLD | Text.CENTER,
"Arial", 60, "border");
// Draw Edit parameter button
drawTextAbsolute(5, 17, "Parameters @URL=EFS:editParameters", Color.black, Color.grey,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.ONTOP | Text.CENTER,
"Arial", 10, "msg");
//Specify long trade: true or false
if(nLast > PSL) {
bLong = true
}
debugPrintln("This is a long trade? " +bLong)
if(bLong) {
DrawBuy();
} else {
DrawSell();
}
}
// Button to change parameters
function editParameters(nButtonPressed){
if(nButtonPressed == BUTTON_RIGHT) nClick++;
askForInput("Trading Parameters")
}
function DrawBuy(){
drawTextAbsolute(5, 49, " Buy @URL=EFS:BuyCallBack",
Color.white, Color.green,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.ONTOP | Text.BOLD | Text.CENTER,
"Arial", 12, "OB");
}
function DrawSell(){
drawTextAbsolute(5, 29, " Sell @URL=EFS:SellCallBack",
Color.white, Color.red,
Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.FRAME | Text.ONTOP | Text.BOLD | Text.CENTER,
"Arial", 12, "OS");
}
[/code ]
Comment