Esignal Realtime Strategy

eSignal indicators

Moderator: moderators

zeller4
rank: 150+ posts
rank: 150+ posts
Posts: 152
Joined: Sat Jul 29, 2006 9:16 pm
Reputation: 0
Location: Geneva, FL
Gender: None specified

Esignal Realtime Strategy

Postby zeller4 » Tue Sep 25, 2007 2:14 am

I've attached a simple long-only study I'm testing.

I've researched all the backtesting tutorials on the Esignal forums and am having trouble resetting the entry orders for when my limit price doesn't fill. I also cannot seem to figure out why a couple graphic lines don't produce the expected results.

Anybody who is good with Esignal code? Your help will be greatly appreciated.

Sincerely,
Kirk


Code: Select all

var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vMid_1 = null;
var vLastAlert = -1;
var bLongSetup = false;
var bLongFilled = false;
var bLongNotFilled = false;
var bLongTargetHit = false;
var bLongStopHit = false;
var vTargetPrice = null;
var vLastAlert = -1;


function preMain() {


    setPriceStudy(true);
    setStudyTitle("test reset");
    setCursorLabelName("ma", 0);
    setCursorLabelName("entry", 1);
    setCursorLabelName("target", 2);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.green, 2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(3, 1);
    setDefaultBarThickness(3, 2);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_FLATLINES, 1);
    setPlotType(PLOTTYPE_FLATLINES, 2);
   
   
}

function main() {

vMid_1 = Math.round((((high(-1)-low(-1))*.5)+low(-1))*10)/10;
vTargetPrice = vMid_1 + 1.0;           
if (vMid_1 == null) return;

//LONG SETUP
       if (
            close(-1) > vEMA8.getValue(MAStudy.MA, -1) &&
            close() > vEMA8.getValue(MAStudy.MA)
        ) {
            if(
                bLongSetup != true &&
                bLongFilled != true
            ) {
                ///*if (vLastAlert != 1)*/ setBarBgColor(Color.RGB(0,128,18));
                bLongSetup = true;
                //vMid_1 = Math.round((((high(-1)-low(-1))*.5)+low(-1))*10)/10;
               
                drawTextRelative(0,low()-1.5,"LONGSETUP",Color.black,Color.lime,Text.ONTOP | Text.VCENTER |
                    Text.CENTER|Text.BOLD | Text.ITALIC,"Arial",8,getValue("rawtime") + "LS1a" );
                vLastAlert = 1;
            }
        } else {
            vMid_1 = null;
            vTargetPrice = null;
        }

//TEST FOR LONG FILL
        if (
            bLongSetup == true &&
            bLongFilled != true
        ) {
            vMid_1 = Math.round((((high(-1)-low(-1))*.5)+low(-1))*10)/10;
            vTargetPrice = vMid_1 + 1.0;
            if(
                low(0) < vMid_1 &&
                high(0) > vMid_1
           
            ) {
                ///*if (vLastAlert != 2)*/ setBarBgColor(Color.RGB(160,255,160));
                bLongFilled = true;
                drawTextRelative(0,low()-1.5,"LONG",Color.white,Color.green,Text.ONTOP | Text.VCENTER |
                    Text.CENTER|Text.BOLD | Text.ITALIC,"Arial",8,getValue("rawtime") + "L1a" );
                vLastAlert = 2;
            } else if (
                (low() > vMid_1 ||
                high() < vMid_1)
            ) {
                ///*if (vLastAlert != 3)*/ setBarBgColor(Color.RGB(160,160,164));
                vLastAlert = 3;
                bLongNotFilled = true;
            }
        }
//SETUP STILL TRUE, NOT YET FILLED
        if (
            bLongSetup == true &&
            bLongFilled != true &&
            bLongNotFilled == true
        ) {
            vMid_1 = Math.round((((high(-1)-low(-1))*.5)+low(-1))*10)/10;
            vTargetPrice = vMid_1 + 1.0;
            if(
                low(0) < vMid_1 &&
                high(0) > vMid_1
           
            ) {
                ///*if (vLastAlert != 2)*/ setBarBgColor(Color.RGB(160,255,160));
                bLongFilled = true;
            } else {
            bLongNotFilled = true;
            }
        }
 
debugClear();

debugPrintln("vLastAlert  "+vLastAlert ); 
debugPrintln("vMid_1  "+vMid_1 ); 
debugPrintln("bLongTargetHit  "+bLongTargetHit ); 
debugPrintln("bLongNotFilled  "+bLongNotFilled ); 
debugPrintln("bLongFilled  "+bLongFilled ); 
debugPrintln("bLongSetup  "+bLongSetup ); 
       
       

if ( bLongSetup == true && bLongFilled != true && bLongNotFilled != true) {setBarBgColor(Color.RGB(0,128,18));}
if ( bLongSetup != true && bLongFilled == true && bLongNotFilled != true) {setBarBgColor(Color.RGB(160,255,160));drawTextRelative(0,low()-1.5,"LONG",Color.white,Color.green,Text.ONTOP | Text.VCENTER |
                    Text.CENTER|Text.BOLD | Text.ITALIC,"Arial",8,getValue("rawtime") + "L1f" );}
               
if ( bLongSetup != true && bLongFilled != true && bLongNotFilled == true) {setBarBgColor(Color.RGB(160,160,164));}

    return new Array(
        vEMA8.getValue(MAStudy.MA),
        vMid_1,
        vTargetPrice
    );

}
Attachments
test reset.efs
(4.44 KiB) Downloaded 28 times

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

zeller4
rank: 150+ posts
rank: 150+ posts
Posts: 152
Joined: Sat Jul 29, 2006 9:16 pm
Reputation: 0
Location: Geneva, FL
Gender: None specified

rev.1

Postby zeller4 » Tue Sep 25, 2007 3:53 pm

been working wih the btProfit-target.efs to get some more ideas for this long-only study.

I figured a couple things out, needed to place exits, eliminate the "notfilled" condition, etc.

I need to know how to extend the vEntryPrice and vTargetPrice to the right until they are filled.

please see the attached revised efs

thanks for any help you can give
Attachments
test reset - rev.1.efs
(8.3 KiB) Downloaded 38 times


Return to “eSignal indicators”