Quantopian's community platform is shutting down. Please read this post for more information and download your code.
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  
    WeightOrder=float(1.00/context.MaxOrders)  
    CurrentPrice= float(data.current([security], 'price'))  
    BuyPrice=float(CurrentPrice* context.PercentOfCurrentPrice)  
    Quantity= int((WeightOrder*cash)/BuyPrice)  
    if get_open_orders(security):  
        continue  
    if data.can_trade(security):  
        order(security, StockShares,  
            style=LimitOrder(BuyPrice)  
        )

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