Simple Coding Help - No Promise.

I thinkg what you are asking is buy if price cross stop loss line but close is above stop loss line and sell if price cross stop loss line but close is below stop loss line then fire signal in scan
No Nehal,

In the above example .... the last one was a sell signal and stops for the same was 2511.45 on closing basis ( 5 mins candle close above 2511.45 to trigger buy ).

One of the candles touched 2511.65 at 11:30 to 11:40 and prices came down after that.

What I want is when I run a auto scan @ 11:40 .... I should get Bajaj Auto listed as it touched the stoploss line and still in sell... If possible the Stoploss line can also be given in the scan...

Thanks in advance...

Hope I am clear ...
 
Last edited:
Seniors,

The Bank Nifty Future Daily chart published in Money99.in is very impressive.
But it is not refreshing well. Seniors let us know whether any similar AFL available.
So that we can get the chart refreshed instantly.

PriyaRamesh
 
Hi Everyone,

Sorry for this newbie question but I am quite new to Amibroker and I am trying to create a simple filter that will list all stocks that has:

- DMI positive crossover today

AND

- RSI above 30

Both Conditions must be satisfied and the columns are:

Stock Code, "+DI minus -DI value" and RSI Value.

Your help is really appreciated as I can go and continue making adjustments as I go along so I really need to start with the basics. Thanks!
 
Hi Everyone,

Sorry for this newbie question but I am quite new to Amibroker and I am trying to create a simple filter that will list all stocks that has:

- DMI positive crossover today

AND

- RSI above 30

Both Conditions must be satisfied and the columns are:

Stock Code, "+DI minus -DI value" and RSI Value.

Your help is really appreciated as I can go and continue making adjustments as I go along so I really need to start with the basics. Thanks!
Filter you want is usually called Explorer in Amibroker

Code provided below will do the job. You need to run it in Automatic Analysis. It will show nothing on chart.

Code:
p = Param("Period",10,10,20,1);
Filter = Cross(PDI(p),MDI(p)) & (RSI(p) > 30);

AddColumn(PDI(p), "+DI");
AddColumn(MDI(p), "-DI");
AddColumn(RSI(p), "RSI");
 

Nehal_s143

Well-Known Member
many times signal keep coming & vanish till candle get closed, is there any method to plot signal only after close of candle and not when candle forming is in process or plot on last candle after opening of new candle ?

i want to use code in this afl
Code:
_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0); 
GfxSetOverlayMode(1);
SetTradeDelays(1,1,1,1);

//XShift - allows to visually shift the chart past the last bar. 
Plot( C, "Close", colorPink, styleCandle, XShift =1); 


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));



Factor=Param("Factor",4,1,10,1);
Pd=Param("ATR Periods",6,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount-1; i++) {
      TrendUp[i] = Null;
      TrendDown[i] = Null;
    
      trend[i]=1;
  
      
      if (Close[i]>Up[i-1]) {
        trend[i]=1;
        if (trend[i-1] == -1) changeOfTrend = 1;
        
      }
      else if (Close[i]<Dn[i-1]) {
        trend[i]=-1;
        if (trend[i-1] == 1) changeOfTrend = 1;
      }
      else if (trend[i-1]==1) {
        trend[i]=1;
        changeOfTrend = 0;      
      }
      else if (trend[i-1]==-1) {
        trend[i]=-1;
        changeOfTrend = 0;
      }

      if (trend[i]<0 && trend[i-1]>0) {
        flag=1;
      }
      else {
        flag=0;
      }
      
      if (trend[i]>0 && trend[i-1]<0) {
        flagh=1;
      }
      else {
        flagh=0;
      }
      
      if (trend[i]>0 && Dn[i]<Dn[i-1]){
        Dn[i]=Dn[i-1];
      }
      
      if (trend[i]<0 && Up[i]>Up[i-1])
        { Up[i]=Up[i-1];
      }
      
      if (flag==1)
      {  Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
        } 
      if (flagh==1)
        { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
        }
      if (trend[i]==1) {
        TrendUp[i]=Dn[i];
        if (changeOfTrend == 1) {
            TrendUp[i-1] = TrendDown[i-1];
            changeOfTrend = 0;
        }
      }
      else if (trend[i]==-1) {
        TrendDown[i]=Up[i];
        if (changeOfTrend == 1) {
            TrendDown[i-1] = TrendUp[i-1];
            changeOfTrend = 0;
        }
      }
  } 

Plot(TrendUp,"Trend",colorGreen);
Plot(TrendDown,"Down",colorRed);

Buy = trend==1;
Sell=trend==-1;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;


BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "Super Trend AFL code from www.marketcalls.in" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ 
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+"  ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

TrendSL=IIf(trend==1,TrendUp,TrendDown);

for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = TrendSL[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
 
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = TrendSL[i];
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);
 
 
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];
 
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleNoRescale|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleNoRescale|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleNoRescale|styleDots, Null, Null, Offset);

//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

/* 
for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount-5,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount-5,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount-5,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount-5,tar3,Null,Clr);
 
}*/
 
messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
 
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;
 
y = pxHeight;
 
GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "Marketcalls - Supertrend"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + TrendSL + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;




//Magfied Market Price
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorGreen) ); 
Hor=Param("Horizontal Position",940,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1); 
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True ); 
GfxSetBkMode( colorBlack );  
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );
 
}

_SECTION_END();
 
Last edited:

Nehal_s143

Well-Known Member
I got below afl from net friend, he says its very good trading system.

When I used this afl I am getting error, senior members please check if error can resloved



Code:
//============================Start of Chart Display Style=============================//
SetOption ( "EveryBarNullCheck", True);
_N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} - O : %g, H : %g, L : %g, C : %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue ( ROC ( C, 1 ) ) ));
SetChartOptions ( 0,chartShowArrows|chartShowDates | chartWrapTitle);
_SECTION_BEGIN ( "Chart Display Theme" );
ChartDisplayTheme = ParamList ( "Chart Display Theme", "White background with B/W candles|Black background with R/G candles", 1 );
param_ShowSystemTitle = ParamToggle ( "Show System Title ?", "No|Yes", 1 );
_SECTION_END ();
TA_ChartDisplayTheme (ChartDisplayTheme);
//============================End of Chart Display Style=============================//
//============================Take User Inputs=============================//
_SECTION_BEGIN ( "Alerts" );
Param_AudioAlert = ParamToggle ( "Audio / text Alert?", "No|Yes", 1 );
Param_ShowValuesBox = ParamToggle ( "Display values in Box?", "No|Yes", 1 );
Param_BoxLocation = ParamList ( "Box Location?", "Left Top|Left Bottom|Right Top|Right Bottom", 0 );
Param_BoxBackgroundColour = ParamColor ( "Box background colour?",colorDarkGrey);
Param_HideBoxBehindChart = ParamToggle ( "Hide Box behind Chart?", "No|Yes" );
_SECTION_END ();
_SECTION_BEGIN ( "Money Management" );
Param_Show_Equity = ParamToggle ( "Show Equity ?(Enter correct INITIAL EQUITY in AA Settings)", "No|Yes" );
Param_Margin = Param ( "Margin required (used for backtesting only)", 15, 0.001, 100, 0.001 );
Param_LotSize = Param ( "Lot Size - DO NOT CHANGE", 50, 5, 5000, 5 );
Param_NoOfLots = Param ( "No of lots normally traded (used for backtesting only)", 2, 1, 10000, 1 );
Param_drawdown= ParamList ( "Trailing Stoploss Method - DO NOT CHANGE", "% of total trade value|Fixed amount per share" );
Param_Stoploss_percent = Param ( "Stoploss % per trade", 0.7, 0.01, 5, 0.01 );
Param_Stoploss_amount = Param ( "Stoploss Amount per share", 15, 0.01, 50000, 0.01 );
_SECTION_END ();
//============================End of User Inputs=============================//
//==========================Start of Show Resistance and Support Lines===============================//
_SECTION_BEGIN ( "Support-Resistance" );
Param_ShowResSup = ParamToggle ( "Show Resistance / Support ?", "No|Yes" );
Param_HowManyRS = Param ( "How many Support / Resistance to show ?", 2, 0, 10, 1 );
Param_ResSupVolatility = Param ( "Support / Resistance Volatility ", 0.1, 0.1, 100, 0.1 );
Param_SupLineColor = ParamColor ( "Support Line Color",colorBrightGreen);
Param_SupLineStyle = ParamStyle ( "Support Line Style", styleLine|styleNoTitle);
Param_ResLineColor = ParamColor ( "Resistance Line Color",colorRed);
Param_ResLineStyle = ParamStyle ( "Resistance Line Style", styleLine|styleNoTitle);
//if(Param_ShowResSup AND Param_HowManyRS> 0 ) TA_ShowSupportResistance (Param_HowManyRS,Param_ResSupVolatility,Param_SupLineColor,Param_ResLineColor,Param_SupLineStyle,Param_ResLineStyle);
_SECTION_END ();
//===========End of Resistance and Support Lines===========//
_SECTION_BEGIN ( "Trading System" );
//====================Show Reversals ?====================//
Param_ShowReversals = ParamToggle ( "Show possible reversals ?", "No|Yes" );
if(Param_ShowReversals) TA_ShowReversals ();
//====================End of Show Reversals ?====================//
//====================Start of Trading System====================//
Param_ShowArrows = ParamToggle ( "Show Buy/Sell/Short/Cover Arrows ?", "No|Yes", 1 );
firstBarEntryExit = ParamToggle ( "First bar trade entry / exit ?", "No|Yes" );
A = Param ( "A - 14, 2, 25, 1 );
B = Param ( "B - 5, 2, 25, 1 );
CC = Param ( "C - 5, 1, 25, 1 );
D = Param ( "D - 5, 1, 25, 1 );
E = Param ( "E - 18, 1, 20, 1 );
TA_TradingSystemCheckEntry (A,B,CC,D,E,firstBarEntryExit);
_SECTION_END ();
//Settings for Backtester;
//SetOption("InitialEquity", 100000);
SetOption ( "AllowSameBarExit", False);
SetOption ( "AllowPositionShrinking", True);
SetOption ( "FuturesMode", True);
SetOption ( "InterestRate", 0 );
SetOption ( "MaxOpenPositions", 1 );
RoundLotSize = Param_LotSize;
SetOption ( "MinShares",RoundLotSize);
SetOption ( "PriceBoundChecking",False);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",12.5/RoundLotSize);
SetOption ( "AccountMargin",Param_Margin);
SetOption ( "ReverseSignalForcesExit",True);
SetOption ( "UsePrevBarEquityForPosSizing",True);
SetOption ( "GenerateReport", 1 );
SetOption ( "MaxOpenLong", 1 );
SetOption ( "MaxOpenShort", 1 );
PositionSize = C*RoundLotSize*Param_NoOfLots;
SetTradeDelays ( 1, 1, 1, 1 );
BuyPrice = Open;
SetOption ( "RefreshWhenCompleted",True);
//End of Settings for Backtester
TA_TradingSystemCheckExit (Param_drawdown,Param_NoOfLots,Param_Stoploss_Percent,Param_Stoploss_amount,Param_LotSize,firstBarEntryExit);
//====================End of Trading System====================//
//==================Plot Equity, Arrows, AudioAlerts and box containing values================//
TA_PlotEquityArrowsAlertsValueBox (Param_BoxLocation, Param_Show_Equity,Param_ShowArrows,Param_AudioAlert,param_ShowSystemTitle,Param_ShowValuesBox, Param_HideBoxBehindChart,Param_BoxBackgroundColour);
//=================== End of Plot Arrows, AudioAlerts and box containing values================//
//=================== Start of Volume Display================//
_SECTION_BEGIN ( "Volume Selector" );
showVolume = ParamToggle ( "Show Volume ?", "No|Yes", 1 );
displayStyle = ParamList ( "Volume Display Mode", "Normal Volume|Coloured Volume|Volume at Price|Volume at Price (grouped)|Volume at Price + Volume|Volume at Price + Coloured Volume|Volume at Price (grouped) + Volume|Volume at Price (grouped) + Coloured Volume|Customised VAP / candles|Customised VAP / candles + Volume|Customised VAP / candles + Coloured Volume" );
Param_NormalVolumeColor = ParamColor ( "Normal Volume Colour", colorDarkBlue);
Param_NormalVolumeStyle = ParamStyle ( "Normal Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram );
Param_UpVolumeColor = ParamColor ( "Up Volume Colour", colorGreen);
Param_DownVolumeColor = ParamColor ( "Down Volume Colour", colorRed);
Param_ColouredVolumeStyle = ParamStyle ( "Coloured Volume Style", styleHistogram | styleOwnScale | styleNoLabel, maskHistogram);
Param_VAPLinesCount = Param ( "VAP Lines Count", 100, 5, 1000, 1 );
Param_VAPLinesWidth = Param ( "VAP Lines Width", 40, 1, 100, 1 );
Param_VAPVolumeColor = ParamColor ( "VAP Color", colorGold);
Param_VAPSide = ParamToggle ( "VAP Side", "Left|Right" );
Param_VAPOverlay = 4 * ParamToggle ( "VAP Z-order", "On top|Behind", 1 );
Param_VAPStyle = 2 * ParamToggle ( "VAP(grouped) Style", "Fill|Lines", 1 );
Param_Segment = Param ( "No. of candles for Customized VAP", 10, 2, 1000, 1 );
if(showVolume)
{
segmentValue = IIf ( Interval () < inDaily, Day (), Month () );
segmentValue = segmentValue != Ref ( segmentValue, - 1 );
if(displayStyle == "Normal Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
}
else if(displayStyle == "Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
}
else if (displayStyle == "Volume at Price" )
{
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle== "Volume at Price (grouped)" )
{
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if (displayStyle == "Volume at Price + Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle == "Volume at Price + Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
PlotVAPOverlay ( Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPOverlay );
}
else if (displayStyle== "Volume at Price (grouped) + Volume" )
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if (displayStyle== "Volume at Price (grouped) + Coloured Volume" )
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
PlotVAPOverlayA (segmentValue, Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide | Param_VAPStyle | Param_VAPOverlay);
}
else if(displayStyle== "Customised VAP / candles" ) TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
else if(displayStyle== "Customised VAP / candles + Volume" ) 
{
Plot ( Volume, "Vol ", Param_NormalVolumeColor, Param_NormalVolumeStyle, 2 );
TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
}
else if(displayStyle== "Customised VAP / candles + Coloured Volume" ) 
{
Plot ( Volume, "Vol ", IIf ( C > O, Param_UpVolumeColor,Param_DownVolumeColor), Param_ColouredVolumeStyle, 2 );
TA_ShowCustomizedVAP (Param_Segment,Param_VAPLinesCount, Param_VAPLinesWidth, Param_VAPVolumeColor, Param_VAPSide,Param_VAPStyle,Param_VAPOverlay);
}
_SECTION_END ();
}
//=================== End of Volume Display================//
 

hmp

Well-Known Member
This is afl for multi time framing. I would like to have red/green color band along with scanning/exploration for dotted yellow(5 min) & grey stepped( 1 hour) cross over as shown in image.
Thanks & regards.
_SECTION_BEGIN("Trend Color");

HaClose =EMA((O+H+L+C)/4,3);
HaOpen = IIf(BarIndex()>0,AMA( Ref( HaClose, -1 ), 0.5 ),Open);
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );

p1=Param("Extreme period1",5,3,10);
p2=Param("Extreme period2",8,3,20);
p3=Param("Extreme period3",13,3,50);
sc=Param("Score Limit",3,1,7);

HaDiff = IIf(HaClose>HaOpen, 1, IIf((O+H+L+C)/4<HaOpen,-1,0));
HaDiff1 = IIf(HaClose>EMA(HaClose,p1), 1, IIf(HaClose<EMA(HaClose,p1),-1,0));
HaDiff2 = IIf(HaClose>EMA(HaClose,p2), 1, IIf(HaClose<EMA(HaClose,p2),-1,0));
HaDiff3 = IIf(HaClose>EMA(HaClose,p3), 1, IIf(HaClose<EMA(HaClose,p3),-1,0));
HaDiff4 = IIf(EMA(HaClose,p1)>EMA(HaClose,p2), 1, IIf(EMA(HaClose,p1)<EMA(HaClose,p2),-1,0));
HaDiff5 = IIf(EMA(HaClose,p2)>EMA(HaClose,p3), 1, IIf(EMA(HaClose,p2)<EMA(HaClose,p3),-1,0));
HaDiff6 = IIf(HaClose>Ref(HaClose,-1), 1, IIf(HaClose<Ref(HaClose,-1),-1,0));

TScore = HaDiff + HaDiff1 + HaDiff2 + HaDiff3 + HaDiff4 + HaDiff5 + HaDiff6;

FillColor = IIf(TScore>sc AND NOT (Ref(TScore,-1)<sc AND Avg<Ref(Avg,-1)),colorLime,
IIf(TScore<-sc AND NOT (Ref(TScore,-1)>-sc AND Avg>Ref(Avg,-1)),ColorRGB(100,0,0),colorWhite));
mycolor=IIf(Tscore>0, colorGreen,colorRed);

SetBarFillColor(Fillcolor);

PlotOHLC(O,H,L,C,"Candlestick",myColor,styleCandle|styleLine);
_SECTION_END();

_SECTION_BEGIN("Min");
//

T = Param("Time", 3,1, 60,1);
TimeFrameSet( T* in1Minute ); // switch to 5 minute frame

P = Param("30Min P", 9, 3, 100,1);

ma30_9 = MA( C, P);
Plot( TimeFrameExpand( ma30_9, T* in1Minute), " EMA T",ParamColor( "T EMA", colorCycle ), ParamStyle("T Min style",styleLine | styleThick));
TimeFrameRestore(); // restore time frame to original



TimeFrameSet( in5Minute ); // switch to 5 minute frame

P = Param("5 Min P", 9, 3, 100,1);

ma5_13 = MA( C, P);
Plot( TimeFrameExpand( ma5_13, in5Minute), " EMA 5Min",ParamColor( "5Min EMA", colorCycle ), ParamStyle("5Min style",styleLine | styleThick));
TimeFrameRestore(); // restore time frame to original

TimeFrameSet( in15Minute); // switch to 15 minute frame

P = Param("15 Min P", 11, 3, 100,1);

ma5_15 = MA( C, P);
Plot( TimeFrameExpand( ma5_15, in15Minute), " EMA 15Min",ParamColor( "15Min EMA", colorCycle ), ParamStyle("15Min style",styleLine | styleNoRescale));
TimeFrameRestore(); // restore time frame to origina

TimeFrameSet( inHourly ); // switch now to hourly
P1 = Param("Hr P", 21, 3, 100,1);
mah_9 = MA( C, P1 ); // moving average from hourly data
Plot( TimeFrameExpand( mah_9, inHourly), " EMA Hrly",ParamColor( "Hr EMA", colorCycle ), ParamStyle("Hr style",styleLine | styleThick| styleNoRescale));
TimeFrameRestore(); // restore time frame to original

TimeFrameSet( inDaily ); // switch now to hourly
P2 = Param("Daily P", 21, 3, 100,1);
mah_13D = MA( C, p2 ); // moving average from daily data
Plot( TimeFrameExpand( mah_13D, inDaily), " EMA Daily",ParamColor( "Daily EMA", colorCycle ), ParamStyle("Daily style",styleLine | styleThick| styleNoRescale));
TimeFrameRestore(); // restore time frame to original


_SECTION_END();


//---- pivot points
DayH = TimeFrameGetPrice("H", inDaily,-1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily,-1);//low
DayC = TimeFrameGetPrice("C", inDaily,-1);//close
DayO = TimeFrameGetPrice("O", inDaily,-1);// current day open
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
PP = (DayH + DayL + DayC) / 3 ;

D = (DayH - DayL)/2;
R1 = D+DayC;

R2 = (DayH-DayL)+DayC;

R3 = R2 +D ;

S1 = DayC - D;

S2 = DayC - (DayH - DayL);

S3 = S2 - D;

style = styleLine + styleNoRescale;
rcolor = colorBlue;
scolor = colorRed;
pcolor = colorPink;

Plot( PP, " P P", ParamColor( "PP", colorTeal ), ParamStyle("PPStyle") );
Plot(R1,"RES",colorRed, styleLine|styleDashed| styleNoRescale );
Plot(R2,"Mid",colorBlue, styleLine|styleDashed| styleNoRescale);
Plot(R3,"SUP",colorGreen, styleLine|styleDashed| styleNoRescale );
Plot(S1,"RES",colorRed, styleLine|styleDashed| styleNoRescale );
Plot(s2,"Mid",colorBlue, styleLine|styleDashed| styleNoRescale);
Plot(S3,"SUP",colorGreen, styleLine|styleDashed| styleNoRescale );




_SECTION_END();

//============== TITLE ==============
_SECTION_BEGIN( "Title" );



y = Status( "pxchartheight" );

GfxTextOut( ("n j e t h v a @ y m a i l . c o m "), 20, y -30);

_SECTION_END();

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.8 ), styleNoLabel| styleNoRescale | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
 
Last edited:

Similar threads