Back to Community
Set Limit Price to SMA

Can anyone assist with explaining how to make a limit price out of a moving average?

I can't seem to be able to use

for security in context.STOCKS_TO_BUY.index  
    CurrentPrice= float(data.current([security], 'price'))  
    BuyPrice=float(CurrentPrice* context.PercentOfCurrentPrice)  
    Quantity= int((WeightOrder*cash)/BuyPrice)  
    if get_open_orders(security):  
    if data.can_trade(security):  
        order(security, StockShares,  

I can't figure out how to calculate the SMA then pass onto the limitorder(buyprice)