How to add sound alert to Thinkor Swim Parabolic SAR ?

Discussion in 'Automated Trading' started by pavlov0032, Jul 26, 2010.

  1. Hello!

    There is a code for parabolic SAR

    input accelerationFactor = 0.02;
    input accelerationLimit = 0.2;
    rec state = {default init, long, short};
    rec extreme;
    rec SAR;
    rec acc;

    switch (state[1]) {
    case init:
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = low;
    case short:
    if (SAR[1] < high)
    then {
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = extreme[1];
    } else {
    state = state.short;
    if (low < extreme[1])
    then {
    acc = min(acc[1] + accelerationFactor, accelerationLimit);
    extreme = low;
    } else {
    acc = acc[1];
    extreme = extreme[1];
    }
    SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
    case long:
    if (SAR[1] > low)
    then {
    state = state.short;
    acc = accelerationFactor;
    extreme = low;
    SAR = extreme[1];
    } else {
    state = state.long;
    if (high > extreme[1])
    then {
    acc = min(acc[1] + accelerationFactor, accelerationLimit);
    extreme = high;
    } else {
    acc = acc[1];
    extreme = extreme[1];
    }
    SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
    }

    plot parSAR = SAR;
    parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
    parSAR.SetDefaultColor(GetColor(5));



    I'd like to have a sound alert the moment it Parabolic starts to plot on the opposite side of the chart (trend change)

    the sound alert script is here:

    http://tda.thinkorswim.com/thinkscript/dark/reference/Functions/Others/alert.html

    Where in the code should I insert the alert function?

    Thanks!