Easylanguage help

Discussion in 'Trading Software' started by m4a1, Jun 30, 2006.

  1. m4a1

    m4a1

    Has anyone successfully programmed martingale position sizing in Tradestation? I am have trouble getting my code to work.

    if positionprofit(1)>=0 then size=1;
    if positionprofit(1)<= then size=size+1;

    The problem with this is that it calculates every bar, so "size=size+1" keeps counting after every bar.

    I have tried various tweaks but could not get it to work. It is especially problematic when a trade reverses a previous trade without any time in between.
     
  2. I have programmed it, but I don't see what you're trying to do in your code.
     
  3. m4a1

    m4a1

    i'm saying

    if profit from previous trade is profitable, then add 1 contract to the previous contract size
    if profit from previous trade is not profitable, then contract size =1
     
  4. so you want to increase your position size after a losing trade?
     
  5. m4a1

    m4a1

    yes, just testing the idea.
     
  6. try this.

    tt=totaltrades;

    if tt>tt[1] then begin
    if positionprofit(1)>=0 then size=1;
    if positionprofit(1)<= then size=size+1;
    end;
     
  7. m4a1

    m4a1

    thanks protrader. this is adding on size correctly when there are no bars in between trades. but when there are bars in between trades, it does not add on size.
     
  8. m4a1

    m4a1

    actually, something strange is happening. i can't pinpoint the exact problem but sometimes it will add size, sometimes it won't.
     
  9. This code works perfect. I don't know how else I can help without seeing the code and knowing exactly what is going on.

    _______________________________________________

    vars: tt(0),size(1),lasttrade(1);

    tt=totaltrades;

    if tt>tt[1] then begin
    if positionprofit(1)>=0 then size=1;
    if positionprofit(1)<0 then size=size+1;
    end;

    if t=1330 then begin
    if lasttrade=1 then begin
    sell short size contracts this bar;
    lasttrade=-1;
    end else begin
    buy size contracts this bar;
    lasttrade=1;
    end;
    end;

    setexitonclose;
     
  10. m4a1

    m4a1

    it does not seem to be working properly with this code.

    Code:
    vars: tt(0),size(1),lasttrade(1);
    
    tt=totaltrades;
    
    if tt>tt[1] then begin
    if positionprofit(1)>=0 then size=1;
    if positionprofit(1)<0 then size=size+1;
    end;
    
    buy size contract at highd(0) on stop;
    sell size contract at lowd(0) on stop;
    setexitonclose;
     
    #10     Jun 30, 2006