thiagofnsouza
New member
Hey guys,
I'm new here and i'm not a programmer. i'm just a hard-working person who tries a lot a do a lot of research to code with a lot of errors. That being said, i'm trying to do TOS coding the famous Larry Williams strategy.
The strategy is to buy at the price of the three-bar moving average of the lows if the trend is positive, and take profits at the three-bar moving average of the highs.
Sell signals are just the opposite. This means you will sell short at the three-bar moving average of the highs (if the trend is negative) and take profits at the three-bar moving average of the lows.
The way i have setted the trend is EMA9, but when i run the code, not every time the code plot a order at the market and he is buying/selling in a non sense target sometimes. Can you guys help me?
Here's my code:
input price = close;
input priceLast = PriceType.LAST;
input priceH = high;
input priceL = low;
input Media3High = 3;
input Media3Low = 3;
input length = 9;
input displace = 0;
input averageType = AverageType.SIMPLE;
input averageType2 = AverageType.EXPONENTIAL;
def bid = close (priceType = priceLast);
def ask = close (priceType = priceLast);
plot avgSELL = MovingAverage(averageType, high[-displace], Media3High);
plot avgBUY = MovingAverage(averageType, low[-displace], Media3Low);
plot AVG = MovingAverage(averageType2, price[-displace], length);
AVG.AssignValueColor(if AVG > AVG[1] then Color.GREEN else if AVG < AVG[1] then Color.RED else Color.YELLOW);
AVG.SetLineWeight(2);
avgBUY.AssignValueColor(Color.GREEN);
avgSELL.AssignValueColor(Color.RED);
def buy = ask or bid crosses avgBUY;
def sell = ask or bid crosses avgSELL;
AddOrder(OrderType.BUY_AUTO, buy, avgBUY, 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN);
AddOrder(OrderType.SELL_AUTO, sell, avgSELL, 1, tickcolor = Color.RED, arrowcolor = Color.WHITE);
---------------------------------------------------------------------------------------------------------------------------
thanks in advance.
I'm new here and i'm not a programmer. i'm just a hard-working person who tries a lot a do a lot of research to code with a lot of errors. That being said, i'm trying to do TOS coding the famous Larry Williams strategy.
The strategy is to buy at the price of the three-bar moving average of the lows if the trend is positive, and take profits at the three-bar moving average of the highs.
Sell signals are just the opposite. This means you will sell short at the three-bar moving average of the highs (if the trend is negative) and take profits at the three-bar moving average of the lows.
The way i have setted the trend is EMA9, but when i run the code, not every time the code plot a order at the market and he is buying/selling in a non sense target sometimes. Can you guys help me?
Here's my code:
input price = close;
input priceLast = PriceType.LAST;
input priceH = high;
input priceL = low;
input Media3High = 3;
input Media3Low = 3;
input length = 9;
input displace = 0;
input averageType = AverageType.SIMPLE;
input averageType2 = AverageType.EXPONENTIAL;
def bid = close (priceType = priceLast);
def ask = close (priceType = priceLast);
plot avgSELL = MovingAverage(averageType, high[-displace], Media3High);
plot avgBUY = MovingAverage(averageType, low[-displace], Media3Low);
plot AVG = MovingAverage(averageType2, price[-displace], length);
AVG.AssignValueColor(if AVG > AVG[1] then Color.GREEN else if AVG < AVG[1] then Color.RED else Color.YELLOW);
AVG.SetLineWeight(2);
avgBUY.AssignValueColor(Color.GREEN);
avgSELL.AssignValueColor(Color.RED);
def buy = ask or bid crosses avgBUY;
def sell = ask or bid crosses avgSELL;
AddOrder(OrderType.BUY_AUTO, buy, avgBUY, 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN);
AddOrder(OrderType.SELL_AUTO, sell, avgSELL, 1, tickcolor = Color.RED, arrowcolor = Color.WHITE);
---------------------------------------------------------------------------------------------------------------------------
thanks in advance.
Last edited by a moderator: