Simple Coding Help - No Promise.

Sirs,
Pls Give a script (Java or other) for Auto saving RT data to Amibroker default DataBase and also to an Additional DataBase in a Different Drive & Folder.

Thank u
Shiraj
This is JScript code that will invoke Save thru COM


Code:
var oAB = new ActiveXObject("Broker.Application");

oAB.LoadDatabase( "C:\\Program Files (x86)\\Amibroker\\Data" );
///....
/// Do your stuff here .....
///...
oAB.SaveDatabase( );
 
This is JScript code that will invoke Save thru COM


Code:
var oAB = new ActiveXObject("Broker.Application");

oAB.LoadDatabase( "C:\\Program Files (x86)\\Amibroker\\Data" );
///....
/// Do your stuff here .....
///...
oAB.SaveDatabase( );
Thank u MasterMindJi
wiil cry for HELP if " doing my stuff " calls my bluff.
Thank u

Shiraj
 
I want afl to plot high/low of 1st weekly bar of the month.

sample code written for 1st hourly bar is as below

TimeFrameSet(inHourly);
up=ValueWhen(TimeNum()==101459,H,1);
dn=ValueWhen(TimeNum()==101459,L,1);
TimeFrameRestore();
up1=TimeFrameExpand(up,inHourly);
dn1=TimeFrameExpand(dn,inHourly);
Plot(dn1,"dn line",colorBlue,styleDots);
Plot(up1,"up line",colorBlue,styleDots);


I want same code for 1st week bar high/low
 
I want afl to plot high/low of 1st weekly bar of the month.

sample code written for 1st hourly bar is as below

TimeFrameSet(inHourly);
up=ValueWhen(TimeNum()==101459,H,1);
dn=ValueWhen(TimeNum()==101459,L,1);
TimeFrameRestore();
up1=TimeFrameExpand(up,inHourly);
dn1=TimeFrameExpand(dn,inHourly);
Plot(dn1,"dn line",colorBlue,styleDots);
Plot(up1,"up line",colorBlue,styleDots);


I want same code for 1st week bar high/low
Plot(ValueWhen(Ref(Month(),-1) != Month(), TimeFrameGetPrice("H", inWeekly, 0)), "", colorBlue);
Plot(ValueWhen(Ref(Month(),-1) != Month(), TimeFrameGetPrice("L", inWeekly, 0)), "", colorRed);
 
Last edited:

Rish

Well-Known Member
Request

I have AFL (not mine), for Maximum and Minimum high / low marking for 4 (candle) days..

_SECTION_BEGIN("4hl method");
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
DC=TimeFrameGetPrice( "C", inDaily, 0);
DC1=TimeFrameGetPrice( "C", inDaily, -1);
dh=TimeFrameGetPrice( "H", inDaily, 0);
dh1=TimeFrameGetPrice( "H", inDaily, -1);
dh2=TimeFrameGetPrice( "H", inDaily, -2);
dh3=TimeFrameGetPrice( "H", inDaily, -3);
dh4=TimeFrameGetPrice( "H", inDaily, -4);
DL=TimeFrameGetPrice( "L", inDaily, 0);
dl1=TimeFrameGetPrice( "l", inDaily, -1);
dl2=TimeFrameGetPrice( "l", inDaily, -2);
dl3=TimeFrameGetPrice( "l", inDaily, -3);
dl4=TimeFrameGetPrice( "l", inDaily, -4);
do1=TimeFrameGetPrice( "O", inDaily, -1);
doo=TimeFrameGetPrice( "O", inDaily, 0);
Maxh1=Max(dh1,dh2);
Maxh2=Max(dh3,dh4);
Maxh=Max(Maxh1,Maxh2);
Plot(Maxh,"maxh",colorBrown,styleLine);

Minl1=Min(dl1,dl2);
Minl2=Min(dl3,dl4);
Minl=Min(Minl1,Minl2);
Plot(Minl,"minl",colorYellow,styleLine);
Buy = Cross(Close , Maxh);
Sell = Cross( Minl,Close);
PlotShapes(Sell*shapeDownArrow,colorRed);
PlotShapes(Buy*shapeUpArrow,colorGreen);
Title = EncodeColor(colorBlack)+ "excel trade" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlue) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+" 4dh= "+WriteVal(Maxh)+" 4dL= "+WriteVal(Minl);

Filter=(Buy OR Sell) ;
NumColumns = 0;
AddColumn(Close,"CMP", 1.2);
AddColumn( IIf( Buy, 66, 83 ), "Signal" , formatChar,2,4 );
AddColumn(doo,"open", 1.2);
AddColumn(dH,"HIGH", 1.2);
AddColumn(dL,"low", 1.2);
AddColumn(dC,"close", 1.2);
AddColumn(Maxh,"buy value", 1.2);
AddColumn(Minl,"sell value", 1.2);

_SECTION_END();

I request and require

1st Condition......110 candle Maximum high / Minimum low marking / deduction....

2nd Condition.....if the next candle close is below Maxium High (1st Condition) candle low...we should have marking or sell Singal.....vis versa if the next candle close is above the Minimum Low (1st Condition) Candle high...we should have marking or Buy Signal...

Can anybody help in this......
 
Can I directly fire orders from my AFL script ( not through charts) to Nest trader using Nest Plus API?

Is it necessary that charts need to be open always to fire the order from Amibroker to Nest Trader.. How to fire orders from generated scan results of AFL??
 
Can I directly fire orders from my AFL script ( not through charts) to Nest trader using Nest Plus API?

Yes

Is it necessary that charts need to be open always to fire the order from Amibroker to Nest Trader..

No

How to fire orders from generated scan results of AFL??

Similar to approach you'd take on chart
Replies are embedded above
 

Nehal_s143

Well-Known Member
Request

I have AFL (not mine), for Maximum and Minimum high / low marking for 4 (candle) days..

_SECTION_BEGIN("4hl method");
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
DC=TimeFrameGetPrice( "C", inDaily, 0);
DC1=TimeFrameGetPrice( "C", inDaily, -1);
dh=TimeFrameGetPrice( "H", inDaily, 0);
dh1=TimeFrameGetPrice( "H", inDaily, -1);
dh2=TimeFrameGetPrice( "H", inDaily, -2);
dh3=TimeFrameGetPrice( "H", inDaily, -3);
dh4=TimeFrameGetPrice( "H", inDaily, -4);
DL=TimeFrameGetPrice( "L", inDaily, 0);
dl1=TimeFrameGetPrice( "l", inDaily, -1);
dl2=TimeFrameGetPrice( "l", inDaily, -2);
dl3=TimeFrameGetPrice( "l", inDaily, -3);
dl4=TimeFrameGetPrice( "l", inDaily, -4);
do1=TimeFrameGetPrice( "O", inDaily, -1);
doo=TimeFrameGetPrice( "O", inDaily, 0);
Maxh1=Max(dh1,dh2);
Maxh2=Max(dh3,dh4);
Maxh=Max(Maxh1,Maxh2);
Plot(Maxh,"maxh",colorBrown,styleLine);

Minl1=Min(dl1,dl2);
Minl2=Min(dl3,dl4);
Minl=Min(Minl1,Minl2);
Plot(Minl,"minl",colorYellow,styleLine);
Buy = Cross(Close , Maxh);
Sell = Cross( Minl,Close);
PlotShapes(Sell*shapeDownArrow,colorRed);
PlotShapes(Buy*shapeUpArrow,colorGreen);
Title = EncodeColor(colorBlack)+ "excel trade" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlue) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+" 4dh= "+WriteVal(Maxh)+" 4dL= "+WriteVal(Minl);

Filter=(Buy OR Sell) ;
NumColumns = 0;
AddColumn(Close,"CMP", 1.2);
AddColumn( IIf( Buy, 66, 83 ), "Signal" , formatChar,2,4 );
AddColumn(doo,"open", 1.2);
AddColumn(dH,"HIGH", 1.2);
AddColumn(dL,"low", 1.2);
AddColumn(dC,"close", 1.2);
AddColumn(Maxh,"buy value", 1.2);
AddColumn(Minl,"sell value", 1.2);

_SECTION_END();

I request and require

1st Condition......110 candle Maximum high / Minimum low marking / deduction....

2nd Condition.....if the next candle close is below Maxium High (1st Condition) candle low...we should have marking or sell Singal.....vis versa if the next candle close is above the Minimum Low (1st Condition) Candle high...we should have marking or Buy Signal...

Can anybody help in this......
this afl is similar to the afl posted by me in past....
 
Hi my dear friends;
I need to add exploring for this wonderful afl.exploring sell buy.i am waiting for your kindness


//ELLIOT Fractals
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleCandle
| ParamStyle("Style") | GetPriceStyle() );
// Paste the code below to your price chart somewhere and green ribbon means both
// both MACD and ADX trending up so if the red ribbon shows up the MACD and the ADX
// are both trending down.

_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();


Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();

_SECTION_END();

_SECTION_BEGIN("LEMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 200, 1, 10 );
lema = EMA (Close,Periods)+ EMA((Close-EMA(Close,Periods)),Periods);
Plot( lEMA, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("ELLIOTT Fractals");
/*
The basic definition of an 'up' fractal is a bar high that is both higher than the two bars immediately preceding it
and higher than the two bars immediately following it.
The lows of the bars are NOT considered in determining the up fractal progression.

If two bars in the progression have equal highs followed by two consecutive bars with lower highs,
then a total of six bars rather than the usual five bars will make up the progression.
The first High becomes the counting fractal. Reverse for 'down' fractals.

The 5 bar formation works best on Daily or longer time frame charts.For intraday data charts we often use 9 bar, 13 bar and 21 bar formations for fractal counting
*/
Up5BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND Ref(H,1) < H AND Ref(H,2) < H;
Up6BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND (H == Ref(H,1)) AND Ref(H,2) < H AND Ref(H,3) < H;
Down5BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND Ref(L,1) > L AND Ref(L,2) > L;
Down6BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND (L == Ref(L,1)) AND Ref(L,2) > L AND Ref(L,3) > L;

//TODO: More filtering: Show only troughs that are around atrough in trix(9).

PlotShapes( IIf(Down5BarFractal ,shapeSmallUpTriangle,0) ,colorBlack, 0, L,-12);
PlotShapes( IIf(Down6BarFractal ,shapeSmallUpTriangle,0) ,colorBlack, 0, L,-12);

PlotShapes( IIf(Up5BarFractal ,shapeSmallDownTriangle,0) ,colorBlack, 0, H,-12);
PlotShapes( IIf(Up6BarFractal ,shapeSmallDownTriangle,0) ,colorBlack, 0, H,-12);

Up = (Up5BarFractal OR Up6BarFractal);
Down = (Down5BarFractal OR Down6BarFractal);
//Removing false fractals:
DownSignal = Flip(Ref(Up,-1), Ref(Down,-1));
UpSignal = Flip(Ref(Down,-1), Ref(Up,-1));

LastHigh[0] = H[0];
LastLow[0] = L[0];

LastLowIndex = 0;
LastHighIndex = 0;
Valid = 0;
for (i=1; i < BarCount; i++)
{

LastHigh = LastHigh[i-1];
LastLow = LastLow[i-1];
if (Up)
{
Valid = True;
if (DownSignal)
{
//Sequence of 2 Up Fractals. Validate only the higher one.
Valid = H >= H[LastHighIndex];
Valid[LastHighIndex] = H[LastHighIndex] > H;
}
LastHigh = Max(H, H[LastHighIndex ]);
LastHighIndex = i;
}

if (Down)
{
Valid = True;
if (UpSignal)
{
//Sequence of 2 Down Fractals. Validate only the lower one.
Valid = L <= L[LastLowIndex];
Valid[LastLowIndex] = L[LastLowIndex] < L;
}

LastLow = Min(L, L[LastLowIndex]);
LastLowIndex = i;
}
}

TrixN = Trix(9);
TroughLow = Ref(TrixN, -3) > TrixN AND Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN AND Ref(TrixN, 3) > TrixN;
TroughHigh = Ref(TrixN, -3) < TrixN AND Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN AND Ref(TrixN, 3) < TrixN;
//TroughLow = Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN;
//TroughHigh = Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN;
ZeroValid = Cross(TrixN, 0) OR Cross(0, TrixN) OR Ref(Cross(TrixN, 0),1) OR Ref(Cross(0, TrixN),1);
ValidLow = TroughLow OR Ref(TroughLow, 1) OR Ref(TroughLow, 2) OR Ref(TroughLow, 3) OR Ref(TroughLow, 4);// OR Ref(TroughLow, 5));
ValidHigh = TroughHigh OR Ref(TroughHigh, 1) OR Ref(TroughHigh, 2) OR Ref(TroughHigh, 3) OR Ref(TroughHigh, 4);// OR Ref(TroughHigh, 5));

//Plot(LastHigh-10 ,"LastHigh", colorBlue, styleLine);
//Plot(LastLow-10 ,"LastLow ", colorRed, styleLine);
//Plot(Valid*5 + 10 ,"LastLow ", colorGreen, styleLine | styleThick);

//PlotShapes( IIf(Down AND Valid,shapeSmallCircle,0) ,colorGreen, 0, L,-12);
//PlotShapes( IIf(Up AND Valid,shapeSmallCircle,0) ,colorYellow, 0, H,-12);
Maxi = Up AND (ValidHigh OR ZeroValid);
Mini = Down AND (ValidLow OR ZeroValid);
PlotShapes( IIf(Down AND (ValidLow OR ZeroValid),shapeSmallUpTriangle,0) ,colorBlue, 0, L,-12);
PlotShapes( IIf(Up AND (ValidHigh OR ZeroValid),shapeSmallDownTriangle,0) ,colorOrange, 0, H,-12);
Buy=Cover=IIf(Down AND (ValidLow OR ZeroValid),1,0);
Sell=Short=IIf(Up AND (ValidHigh OR ZeroValid),1,0);
//Plot(UpSignal*3+5,"UpSignal", colorBlue, styleLine| styleThick);
//Plot(DownSignal*3 ,"DownSignal", colorRed, styleLine| styleThick);

/*
LastMaxi = 0;
LastMini = 0;
ElliotLines = 0;
State = 0;
for (i=1; i < BarCount; i++)
{
State = State[i-1];
if (Maxi)
{
State = 1;//down
}

if (Mini)
{
State = 2;
}

}

PlotShapes(IIf(State > 0, shapeSmallCircle, 0), IIf(State == 1, colorRed, colorBlue), 0, IIf(State == 1, H, L), -5);
*/
//Line = LineArray( x0, y0, x1, y1, 1 );
//Plot( Line, "Trend line", colorBlue );

/*
Wave B
Usually 50% of Wave A
Should not exceed 75% of Wave A
Wave C
either 1 x Wave A
or 1.62 x Wave A
or 2.62 x Wave A
*/
function CorrectiveRatios(StartPrice, A, B, C, RatioDelta, Delta)
{

ALength = abs(startPrice - A); BLength = abs(A-B);
CLength = abs(B-C);

Ratio1 = BLength / CLength ;
Cond1 = Ration1 >= 0.5 - RatioDelta AND ratio1 <= 0.75 + RatioDelta;
Cond2 = abs(Clength - ALength) < Delta OR abs(Clength - 1.62 * ALength) < Delta OR abs(CLength - 2.62 * ALength) < Delta;

return Cond1 AND Cond2;
}

function ImpulseRules(StartPrice, One, Two, Three, Four, Five)
{
//Wave 2 should be beneath wave 1 start:
Cond1 = Two > StartPrice AND Two < One;
//Wave 4 - the same:
Cond2 = Four > Two AND Four < Three;
//Wave 5 should be <= wave 3
Cond3 = abs(Three-Two) >= abs(Five - Four);
//Wave 1 should be smaller than wave five, making wave 3 the biggest:
Cond4 = abs(StartPrice - One) < abs(Five - Four);
return Cond1 AND Cond2 AND Cond3 AND Cond4;
}
_SECTION_END();
 

Similar threads