Announcement

Collapse
No announcement yet.

long short parameters needs help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • long short parameters needs help

    i've started a new thread from this re:

    Originally posted by michaelm
    alex,
    i'm trying to get this stuff, but i am really more a trader than a programmer. i really appreciate those of you who are gurus at this.

    the indicator formula i'm refering to is below.

    from this i would like to go long 0.25point above blue bar high (or short -0.25 below low of red bar). All actions should be sent to Alert Window.

    if long entered, set initial stop loss at 4 points. if new signal to short happens before initial stop loss hit, then it will reverse and cxl the initial stop loss. if trade goes +2 points in favor, then move initial stop loss to a break even stop. if trade goes +5points, then cover 1/2 of trade, have the BE stop adjust for 1/2 left, and the 1/2 left of trade will stay on until there is a short signal, whereupon it will cover that 1/2 and go short.
    visa versa for the short side.

    i would like trade signals to occur only between 6:30 - 13:00 pst, M-F. thus, new trades initiate only after 6:30, and cover if in trade at 12:59.

    I am also including link to
    this thread, which seems like you had some great ideas.
    here's what i've been able to come up with so far, but doens't result in any trades via backtest.
    where is it going wrong?

    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description 7532


    //{{EFSWizard_Declarations

    var vADXDM = new ADXDMStudy(6);
    var vLastAlert = -1;

    //}}EFSWizard_Declarations 6291


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(false);
    setStudyTitle("APnt6 alrt bs test");
    setCursorLabelName("APnt6 aBS", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(2, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 0);
    setColorPriceBars(true);
    addBand(0, PS_SOLID, 1, Color.yellow);
    //}}EFSWizard_PreMain 29888

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if ((
    vADXDM.getValue(ADXDMStudy.PDI)-vADXDM.getValue(ADXDMStudy.NDI) > 0) &&
    Strategy.isLong() == false
    ) onAction1()
    //}}EFSWizard_Expression_1 12182

    //{{EFSWizard_Expression_2
    else if ((
    vADXDM.getValue(ADXDMStudy.PDI)-vADXDM.getValue(ADXDMStudy.NDI) < 0) &&
    Strategy.isShort() == false
    ) onAction2()
    //}}EFSWizard_Expression_2 15465

    //{{EFSWizard_Expression_3
    else if (
    1 < 1
    ) onAction3()
    //}}EFSWizard_Expression_3 6495

    //{{EFSWizard_Expression_4
    else if (
    Strategy.isInTrade() == true &&
    Strategy.isLong() == true &&
    getHour() > 6 &&
    getHour() < 13 &&
    getDay() >= monday &&
    getDay() <= friday
    ) onAction4()
    //}}EFSWizard_Expression_4 28794

    //{{EFSWizard_Expression_5
    else if (
    Strategy.isInTrade() == true &&
    Strategy.isShort() == true &&
    getHour() > 6 &&
    getHour() < 13 &&
    getDay() >= monday &&
    getDay() <= friday
    ) onAction5()
    //}}EFSWizard_Expression_5 28757

    //{{EFSWizard_Expression_6
    else if (
    Strategy.isLong() == true &&
    open() >= Strategy.isLong()+2
    ) onAction6()
    //}}EFSWizard_Expression_6 15354

    //{{EFSWizard_Expression_7
    else if (
    Strategy.isShort() == true &&
    open() < Strategy.isShort()-2
    ) onAction7();
    //}}EFSWizard_Expression_7 14676

    //}}EFSWizard_Expressions 192117


    //{{EFSWizard_Return
    return vADXDM.getValue(ADXDMStudy.PDI)-vADXDM.getValue(ADXDMStudy.NDI);
    //}}EFSWizard_Return 5500

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    setPriceBarColor(Color.lime);
    if (vLastAlert != 1) setPriceBarColor(Color.RGB(0,0,255));
    if (vLastAlert != 1) Strategy.doLong("", Strategy.STOP, Strategy.NEXTBAR, Strategy.ALL, 0.25);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1 28731

    //{{EFSWizard_Action_2
    function onAction2() {
    setPriceBarColor(Color.RGB(255,192,160));
    if (vLastAlert != 2) setPriceBarColor(Color.red);
    if (vLastAlert != 2) Strategy.doShort("", Strategy.STOP, Strategy.NEXTBAR, Strategy.ALL, -0.25);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2 31237

    //{{EFSWizard_Action_3
    function onAction3() {
    setPriceBarColor(Color.RGB(0,0,0));
    vLastAlert = 3;
    }
    //}}EFSWizard_Action_3 10592

    //{{EFSWizard_Action_4
    function onAction4() {
    Strategy.doSell("LongPT5 exit", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, 5);
    Strategy.setStop(-4);
    if (vLastAlert != 4) Alert.addToList(getSymbol(), "Long @ "+(high()+.25), Color.RGB(0,0,0), Color.RGB(0,128,0));
    vLastAlert = 4;
    }
    //}}EFSWizard_Action_4 34958

    //{{EFSWizard_Action_5
    function onAction5() {
    Strategy.doCover("ShortPT5 Exit", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, -5);
    Strategy.setStop(4);
    if (vLastAlert != 5) Alert.addToList(getSymbol(), "Short @ "+(low()-.25), Color.RGB(0,0,0), Color.RGB(195,0,0));
    vLastAlert = 5;
    }
    //}}EFSWizard_Action_5 33997

    //{{EFSWizard_Action_6
    function onAction6() {
    if (vLastAlert != 6) Strategy.clearStop();
    if (vLastAlert != 6) Strategy.setStop(0);
    vLastAlert = 6;
    }
    //}}EFSWizard_Action_6 17490

    //{{EFSWizard_Action_7
    function onAction7() {
    if (vLastAlert != 7) Strategy.clearStop();
    if (vLastAlert != 7) Strategy.setStop(0);
    vLastAlert = 7;
    }
    //}}EFSWizard_Action_7 18210

    //}}EFSWizard_Actions 257074
    Michael
Working...
X