Dear Friends,

i wanna code a simple trading System on weekly charts for the sp500 index with the envelope indicator.

the idea: taking a simple 40 week moving average and build two bands with plus 3 % and minus 3 % of the simple 40 week moving average.

(Long only System)

buy: Close > upperband

sell: Close < lowerband

when the System goes long it should buy 10.000 usd irrespective from the total equity

how i have to code this?

At the moment the system every time invest 100 % of the euity`?

some further question for understanding: to proof ist the Parameters a stable enough- i thougt i optimize the System with the, msci world, msci europe and msci USA too?

i would take the best average Parameters of all 4 indices (sp500, msci world, msci europe, msci USA) to trade the sp500.

what do you think of the idea? (i know ist my Option, i only would aks if the logic is smart oder stupid :-) thank you so much for short help!

PS: i´m novice with amibroker so i would be glas for every help i get to learn the first steps.

Dear Marcus

`// Project Moving Average Band System`

// Tradingsystem "long only" for the SP500 ETF

// Goal: Long Term Capital Growth

// Definition Optimize Variable

MALength = Optimize( "SMA", 30, 35, 45, 1 );

// Optimizes from 20 to 60 in 1 steps inital is 40

MAWidth = Optimize( "MAW", 3, 2.5, 5, 0.1 );

// Optimizes from 1 % to 7.5% in 0.1 % steps inital is 3.0 %

// Definition Simple Moving Average

C1 = MA(C, MALength);

// Definition Close

C2 = C;

// Definition Upper Band

C3 = C1*MAWidth/100+C1;

//Definition Lower Band

C4 = C1-C1*MAWidth/100;

// Definition Buy Signal

Buy = Cross(C2,C3);

// Defintion Sell Signal

Sell = Cross(C4,C2);

Plot( C, "C", colorBlack, styleCandle );

e = Equity();

Plot( e, "Equity", colorGreen, styleLine | styleOwnScale );