Easylanguage help

Discussion in 'Trading Software' started by wizardx, May 1, 2006.

  1. wizardx


    I am trying to add 1 contract whenever the previous position is profitable. Subtract 1 contract if the previous position is not profitable.

    I have tried the following code:

    if positionprofit(1)>0 then cts=cts+1;
    if positionprofit(1)<0 then cts=cts-1;
    The problem with this is that this code recalculates at every bar, so by the time the next entry arrives I have way too many contracts.

    For example, say the previous trade size was 1 contract and it was profitable. On the next trade I want the size to be 2 contracts. However, there are 10 bars in between, so the code calculates 10 times and cts = 11.

    I have tried to get the above code to calculate only when the entry condition has been met, but there are quirks with Tradestation that doesn't allow it to work perfectly.

    Is there another way to do it? I have tried

    if positionprofit(1)<>positionprofit(1)[1] ...
    but easylanguage does not allow you to put the [1] there.