abnovice

• Newbie
• Posts: 3
« on: February 13, 2017, 01:03:38 pm »
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)
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

Code: [Select]
`// Project Moving Average Band System// Tradingsystem "long only" for the SP500  ETF// Goal: Long Term Capital Growth// Definition Optimize VariableMALength = Optimize( "SMA", 30, 35, 45, 1 );// Optimizes from 20 to 60 in 1 steps inital is 40MAWidth = 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 AverageC1 = MA(C, MALength);// Definition CloseC2 = C;// Definition Upper BandC3 = C1*MAWidth/100+C1;//Definition Lower BandC4 = C1-C1*MAWidth/100;// Definition Buy SignalBuy = Cross(C2,C3);// Defintion Sell SignalSell = Cross(C4,C2);Plot( C, "C", colorBlack, styleCandle );e = Equity();Plot( e, "Equity", colorGreen, styleLine | styleOwnScale );`

davidp13

• Newbie
• Posts: 2
« Reply #1 on: February 22, 2017, 03:18:07 am »
this code should help

SetPositionSize(100, spsValue);

• Newbie
• Posts: 1