Announcement

Collapse
No announcement yet.

Generic Broker Function

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

  • Generic Broker Function

    Hi, Sorry to post this in a way, I have tried to look it up in the support website, but the links appear to be broken.

    I am attempting some position management, and I have the logic and everything working fine for the backtest (thanks to one of your great documents). I am now attempting to put some generic broker functions in for forward testing, but I am having trouble trading out of half the position, leaving a runner. The idea is to scalp for 10 tics, leave a runner on for the rest. I have it running in backtest as I say, but I guess I am struggling to structure that in Generic broker.

    Any advive would be great, here is the buy/sell code below for long:

    Buy:

    Strategy.doLong("Going Long", Strategy.MARKET, Strategy.NEXTBAR, 2 );
    vTarget=(close(0)+nScalp);
    buyMarket( getSymbol(), 2 );
    if ( nStop = (2.5 * xATR.getValue(-1)) < 0.0050 ){
    nStop = close(0) - (2.5 * xATR.getValue(-1));
    } else {
    nStop=(close(0) -0.0050);
    }
    }

    Sell:

    if (close()< nStop){
    Strategy.doSell("Close Long Stop", Strategy.STOP, Strategy.THISBAR, Strategy.ALL, nStop);
    nStop=null;
    vScalp=false;
    closeAllPositions()
    } else if (vScalp == false){
    var nLot = Math.abs(Math.round(Strategy.getPositionSize()/2));
    if (high(0) >= vTarget) {
    vScalp=true;
    Strategy.doSell("Close Long Scalp", Strategy.LIMIT, Strategy.THISBAR, nLot, vTarget);
    sellLimit(getSymbol(), 1, vTarget);
    }



    Thanks a lot.

  • #2
    Rogerha,

    What kind of error are you receiving?

    I use both the backtester and generic broker functions all the time.

    You seem to be exeuting both the strategy backtester and generic broker functions in the same block of code?

    I'd be happy to try and help you resolve the problem but without posting the complete EFS so the strategy can be executed and the error can be reproduced, it's very difficult for anyone to identify and resolve the problem you are having.
    Last edited by demarcog; 12-16-2006, 05:00 PM.
    Glen Demarco
    [email protected]

    Comment


    • #3
      Hi Demarcog,

      Thanks very much for your prompt response, after a bit more searching I got it working.

      Thanks for your time however I appreciate it.

      Roger

      Comment

      Working...
      X