first program help

Discussion in 'Strategy Development' started by dematto, Sep 6, 2012.

  1. dematto

    dematto

    I made a program in OmegaT
    I started on this platform to start using easylenguage (I I program in other languages)

    I am writing some code that gives me error
    in practice assign a variable when I send a trade.

    then check that variable and if the volatility increases close the position


    the problem is not in the efficiency of the program
    but in the print which should not be done

    ...
    VARS: giallaup (0), gialladw (0), bluup (0), bludw (0), lr (0), bbw (0), pt (0), bbwv(0);
    ...

    bbw= delta_BollingerWidth(price, lenbb, 1);
    lr = linearregvaluefc (price, lenlr, 0);

    if lr> bluup then
    begin;
    sell;
    pt = -1;
    bbwv= bbw;
    end;


    if pt = -1 then begin;
    if MarketPosition = -1 and bbw> bbwv then begin;
    exitshort;
    print (bbw, " ", bbwv);
    end;

    if MarketPosition = 1 and bbw> bbwv then begin;
    exitlong;
    print (bbw, " ", bbwv);
    end;

    end;



    enters the positions, but give me the print
    10.00 10.00
    10.00 10.00
    10.00 10.00

    I do not understand why, if the two values ​​must be different ---> bbw> bbwv
    why gives me the print!????
     
  2. Two things assuming this is Tradesation 2000i code:

    1 - There is no function "sell" I believe". I remember there was a "Sell Next Bar" or somehting along these lines.
    2- You have no code to go long but you are exiting longs;
     
  3. dematto

    dematto

    thanks for the reply

    1) I do not think this is because for
    the program does the operations

    2) could be but I do not understand why the print from me two identical values ​​for the two variables that had to be different

    to give me the same two variables I should write
    bbw= bbwv;
    (after the exit)


    if MarketPosition = 1 and bbw> bbwv then begin;
    exitlong;
    print (bbw, " ", bbwv);
    end;

    :confused:
     
  4. hmm.... one value could be 10.0001 and the other 10.00001

    Try comparing the absolute value of the difference to a small value like:

    abs(a - b) < 0.00000001

    Comparing diectly real values when they can have small diffrences in a bad practice.
     
  5. dematto

    dematto

    thanks for the advice I'll try and I'll tell you how it goes :D