help with this formula

#1
I want to change the next formula to backtest and scan in amibroker. The original is from basic languaje(prorealtime software) to backtest. Please tell me separately the formulas to backtest and to scan .

Many, many thanks

cap=volume*close


Rem cap sirve para filtrar smallcaps
maxi=highest[52](close)

distancia1=(maxi-close[0])/maxi*100


myCPM = CALL "Capital proporcional medio"[52]

rem CPM guarda el promedio de 5 semanas del CPM

CPM5 = (myCPM+myCPM[1]+myCPM[2]+myCPM[3]+myCPM[4])/5


mydistancia, ignored = CALL "Distancia MM30"
resultado=0
if mydistancia >2 then
resultado=1
endif






ignored, myFR = CALL "RSCMansfield2"
resultadomansfield=0
if myFR>0.10 then
resultadomansfield=1
endif









// Condiciones para entrada de posiciones largas
IF NOT LongOnMarket AND resultadomansfield and resultado and distancia1<3 AND CPM5>0 and mydistancia<9 and myFR>0.10 and cap>1000000 THEN
BUY 1000 CONTRACTS AT MARKET
ENDIF

// Condiciones de salida de posiciones largas
If LongOnMarket AND WeightedAverage[30](close)[2]<WeightedAverage[30](close)[1]and WeightedAverage[30](close)[1]> WeightedAverage[30](close)and close< WeightedAverage[30](close) THEN
SELL AT MARKET
ENDIF
 
#2
I think thi is the solution


_SECTION_BEGIN("DISTANCIA A MAXIMOS");


//poner "cap" en otro lugar despues
cap=Volume*Close;

// cap sirve para filtrar smallcaps

Maxi=HHV(Close,52);
distancia1=(maxi-Close[0])/maxi*100;

_SECTION_END();


_SECTION_BEGIN("CAPITAL PROPORCIONAL MEDIO(CPM)");


CPM = Volume * Close;
volmax = HHV(CPM, 52); // 52 days, not week
vol_ = ((CPM * 100)/volmax) * (4/5); // 52 days, not week
volpmed = EMA(vol_, 52);
CPM2 = vol_ - volpmed;

// CPM guarda el promedio de 5 semanas del CPM

CPM2 = (CPM+CPM[1]+CPM[2]+CPM[3]+CPM[4])/5;

IIf(CPM2>0,1,0);

_SECTION_END();






_SECTION_BEGIN("DISTANCIA A mm30");

// Indicador creado por Javier Alfayate
// mide el riesgo en valor absoluto

wm30 = WMA(Close, 30);

cero = ParamColor("Color", ColorRGB(0,0,0));
distancia = IIf(Close>wm30, (Close-wm30)/Close * 100,
IIf(Close<wm30, (wm30-Close)/Close * 100, 0));

IIf(distancia<9,1,0);
IIf(distancia>2,1,0);

_SECTION_END();

baseprice = Sum((Close/Foreign("^GSPC","Close")),52)/52;
graphmansfield = ((Close/Foreign("^GSPC","Close")/baseprice)-1)*10;
Ligne0 = 0;
IIf(graphmansfield>0.10,1,0);

_SECTION_END();
Buy=IIf(Cap>1000000,1,0);
Buy = IIf(CPM2>0,1,0);
Buy=IIf(distancia1<3,1,0);
Buy=IIf(distancia<9,1,0);
Buy=IIf(distancia>2,1,0);
Buy=IIf(graphmansfield>0.10,1,0);
Sell = IIf(Close<wm30,1,0);
 

Similar threads