Simple Coding Help - No Promise.

Exploration is not coded in AFL
Use scan , and it works on any time frame.

Image shows scans for 5 minute time frame.

Hi Amit,

Thanks a lot...

By the way - How do I run the scan automatically every 5 or 15 mins for the AFL and the new result should be alerted in the Alert window on the left pane ?

IS it possible ?

Thanks
 

Nehal_s143

Well-Known Member
No need to learn if for such simple stuff as of now; :rofl:

This requirement can be fulfilled by if's country cousin IIf. Since it is possible that C may not be greater than TLINE and also not less than BLINE, I've instructed Amibroker to Plot Null for such scenarios.

Code:
Plot(
IIF(C>TLINE, BLINE, IIf(C<BLINE, TLINE, NULL))
, "",colorCustom1,styleStaircase,styleDashed);
yes sir very true, mainly during range bound market many times C will be greater than TLINE and also not less than BLINE

for such condition i had planed to use nick ma swing with price band to remain in the trade, in direction of main trend

i tried to use following code, getting error missing argument

Code:
Plot(IIf(C>TLINE, BLINE,
     IIf(C>BLINE AND C<TLINE AND j6ft>NW6ft,
     IIf(C<TLINE AND C>BLINE AND j6ft<NW6ft,
     IIf(C<BLINE, TLINE)))), "",colorCustom1,styleStaircase,styleDashed);
 
No need to learn if for such simple stuff as of now; :rofl:

This requirement can be fulfilled by if's country cousin IIf. Since it is possible that C may not be greater than TLINE and also not less than BLINE, I've instructed Amibroker to Plot Null for such scenarios.

Code:
Plot(
IIF(C>TLINE, BLINE, IIf(C<BLINE, TLINE, NULL))
, "",colorCustom1,styleStaircase,styleDashed);

Nehal

You cannot merge two output variables in one single IIf. For color, you cannot use the same IIf that returns Plot values; you will have to use different set of IIf statement.

Within each distinct set, you can have hundreds of nested IIfs (nested into one another) as long as they return same array type.

Code:
Plot(
      IIF(C>TLINE, BLINE, IIf(C<BLINE, TLINE, NULL)) // [B]First set[/B] of IIF is for data to be plotted
, "",
      IIF(C>TLINE, colorOrange, IIf(C<BLINE, colorGreen, colorBlack)) // [B]Second set[/B] of IIF is for the color

, styleStaircase,styleDashed);
 
Last edited:
I am new to amibroker. I have request to gurus in amibroker. I have an AFL for buy sell signal. I do not want open all the charts but I want the AFL to check all the scrips in my watch list and send buy sell signal.
kindly help me
 
I am new to amibroker. I have request to gurus in amibroker. I have an AFL for buy sell signal. I do not want open all the charts but I want the AFL to check all the scrips in my watch list and send buy sell signal.
kindly help me
I am old to amibroker. I have a request to all Kanakrajas. I want divine power to see AFLs of all Kanakrajas that they did not post so that I can answer their queries that I did not understand.

And also, I want AFL to tell me to Buy only when the scrip is actually going to go up and not otherwise.

Kindly help me
 
Can someone share the AFL code for today POC and yesterday POC per market profile? Need volume profile values and not VWAP.. Tks in advance
 
Hi Friends,

Just want a small scan for this AFL ...

It is not a normal scan for buy/sell signals...

I want the scan for the given below condition :

If the candle touches the stoploss line in the last 5 mins ( depends on the timeframe I scan ) then when I run the scan after 5 mins it should name the stock.

Hope I am clear ....

Regards

Code:
_SECTION_BEGIN("_ChartTemplat_GD-B_dark");

//-------------------------------------------------------------------------
//----Anweisungen abhängig vom Charttyp------------------------------------
dec = (Param("Decimals",2,0,7,1)/10)+1;
	bi = BarIndex();
	Lbi = LastValue(BarIndex());
	sbi = SelectedValue(bi);
	x1= BarCount-1;


Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1);

cs = GetPriceStyle();   // CS == ChartStyle
choose = ParamToggle("Charttypabhängigkeit?", "Yes|No"); 


if(choose == 0){ 
   if(cs == styleBar){
		chartArt = "bar";
	} 
	else if (cs == styleCandle){
		chartArt = "candle";
	}else{
		chartArt = "line";	
	}

} else {
	chartArt = "";
};


//-------------------------------------------------------------------------
//---- ChartFarben --ChartStyle--------------------------------------------

if(!choose )
	SetChartBkColor( ParamColor("HintergrundFarbe", ColorRGB( 0, 50, 50 ) ) );  // Hintergrund >> nur wenn ChartTemplet greift 

line_color_up =  ParamColor("Line_Color_UP", ColorRGB( 46, 139 , 87 ) );   //- UP - DOWN - 
line_color_down = ParamColor("Line_Color_DOWN", ColorRGB(  220, 20, 60 ) );  //- UP - DOWN - 

bar_color_up =  ColorRGB( 44, 138 , 84);
bar_color_down  = ColorRGB( 220, 22, 60); 

candle_color_up =  ColorRGB( 0, 0, 255);
candle_color_down  = ColorRGB( 255, 0, 0); 
candle_rahmen = ColorRGB( 128, 128 , 128);

spezial_color = ParamColor( "PinBar-Color", ColorRGB( 255, 255 , 0) );


//-------------------------------------------------------------------------
//---- Bedingungen --------------------------------------------------------

// PinBars werden anders coloriert
// Bars/Lines/Candles bei denen open und close dicht beieiander liegen werden anders farbieg dargestellt
// zur Vereinfachung, ist der Abstand Hoch - Tief um Faktor "pinbar_faktor" größer als der Abstand Open-Close, gilt die Bedingung             

pinbar_faktor = Param( "Pinbar-Faktor", 5, 1, 10, 0.1);
bedingungOpenNearClose = abs(H-L)/ pinbar_faktor > abs(O-C) ;
bedingungUp = O< C;


style =  styleNoTitle | ParamStyle("Style");


if(chartArt == "line"){
	Plot( C, "Price", IIf(bedingungOpenNearClose, spezial_color,   IIf( bedingungUp, line_color_up, line_color_down) ),style |styleThick | GetPriceStyle());  // |styleThick

}else if (chartArt == "bar"){
	Plot( C, "Price", IIf( bedingungOpenNearClose, spezial_color, IIf( bedingungUp, bar_color_up, bar_color_down) ),style | GetPriceStyle()); 

}else if (chartArt == "candle"){
	// bei CandleChart wird hiermit die FüllFarbe definiert
	SetBarFillColor( IIf( bedingungUp, candle_color_up, candle_color_down) );
	// Color definiert bei CandlChart den Rahmen
	Plot( C, "Price", IIf (bedingungOpenNearClose, spezial_color, candle_rahmen  ),  style | GetPriceStyle());

}else{
	// StandartChart
	_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 ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
	_SECTION_END();
}

_SECTION_END();

//-------------------------------------------------------------------------
//---- Indis --------------------------------------------------------------

//---ChartTypAbhängiges

if(chartArt == "line"){ 
	// wenn LinienChart
	_SECTION_BEGIN("High_Low_Line");
	HighLine = H;
	LowLine = L;
	farbe_HL = ColorRGB( 65, 65, 65 );
	Plot(HighLine, "", farbe_HL,styleLine|styleDashed|styleNoLabel); //  styleStaircase
	Plot(LowLine, "", farbe_HL,styleLine|styleDashed|styleNoLabel);  // styleLine
	_SECTION_END();

}
_SECTION_END();

_SECTION_BEGIN("NMA Swing");
SetBarsRequired(200,0);

//GraphXSpace = 5;
//SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",3,0.25,50,0.25),0.25,50,0.25);
Per= Optimize("atr",Param("atr",4,3,200,1),3,200,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose,  -1 ),  0.5 );
HaHigh = Max( H,  Max( HaClose,  HaOpen ) );
HaLow = Min( L,  Min( HaClose,  HaOpen ) );
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
j=Haclose;
//Plot(Haclose,"Vinod-cLOSE",IIf(Haclose > Ref(HaClose,-1), colorBrightGreen,
//IIf(Haclose < Ref(HaClose,-1), colorOrange,
//colorOrange)),
//styleLine|styleThick);




//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(10);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;  
NW[0] = 0;  


for(i = 1; i < BarCount; i++)
{
 if(Trend[i-1] == 1)                
 {
  if(j[i] < NW[i-1])                 
  {
   Trend[i] = -1;                   
   NW[i] = j[i] + Revers[i];        
  }
  else                              
  {
   Trend[i] = 1;
   if((j[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = j[i] - Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  } 
 }
 if(Trend[i-1] == -1)               
 {
  if(j[i] > NW[i-1])                
  {
   Trend[i] = 1;                    
   NW[i] = j[i] - Revers[i];        
  }
  else                              
  {
   Trend[i] = -1;
   if((j[i] + Revers[i]) < NW[i-1]) 
   {
    NW[i] = j[i] + Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}

//===============system================

Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=Cover=Cross(j,nw);
Sell=Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
/*Title = EncodeColor(colorWhite)+ "Vinod TIS Swing System" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ */
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1)+
EncodeColor(colorLime)+
WriteIf (Buy , " Go Long Above / Reverse Signal @ "+H+"  ","")+
WriteIf (Sell , " Exit Long Below / Reverse Signal @ "+L+"  ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ 
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss 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(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();

_SECTION_BEGIN("ema's");


/*_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}} ", O, H, L, C));

Title = Name() + "; " + Date() + 
	"\nEMA-1: "  + WriteVal(EMA(C, 1), 1.2) + 	EncodeColor(colorWhite)  + 
   "\nEMA-2: "  + WriteVal(EMA(C, 2), 1.2) + 	EncodeColor(colorCustom11)  + 
   "\nEMA-3: "  + WriteVal(EMA(C, 3), 1.2) + 	EncodeColor(colorCustom9)  + 
   "\nEMA-5: "  + WriteVal(EMA(C, 5), 1.2) + 	EncodeColor(colorDarkOliveGreen)  + 
   "\nEMA-8: "  + WriteVal(EMA(C, 8), 1.2) + 	EncodeColor(colorGold)  + 
	"\nEMA-13: "  + WriteVal(EMA(C, 13), 1.2) + 	EncodeColor(colorOrange)  + 
	"\nEMA-21: " + WriteVal(EMA(C, 21), 1.2) + 	EncodeColor(colorRed) + 
	"\nEMA-44: " + WriteVal(EMA(C, 44), 1.2) +   EncodeColor(colorBlue) , 0,H,L,C ));


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %1.2f, Hi %1.2f, Lo %1.2f, Close %1.2f (%.1f%%) Vol " + WriteVal( V, 1.0 ) + // " {{VALUES}} " + 
	
	"\nEMA-1: "  + WriteVal(EMA(C, 1), 1.2) + 	EncodeColor(colorWhite)  + 
   "\nEMA-2: "  + WriteVal(EMA(C, 2), 1.2) + 	EncodeColor(colorCustom11)  + 
   "\nEMA-3: "  + WriteVal(EMA(C, 3), 1.2) + 	EncodeColor(colorCustom9)  + 
   "\nEMA-5: "  + WriteVal(EMA(C, 5), 1.2) + 	EncodeColor(colorDarkOliveGreen)  + 
   "\nEMA-8: "  + WriteVal(EMA(C, 8), 1.2) + 	EncodeColor(colorGold)  + 
	"\nEMA-13: "  + WriteVal(EMA(C, 13), 1.2) + 	EncodeColor(colorOrange)  + 
	"\nEMA-21: " + WriteVal(EMA(C, 21), 1.2) + 	EncodeColor(colorRed) + 
	"\nEMA-44: " + WriteVal(EMA(C, 44), 1.2) + EncodeColor(colorBlue) , 0,H,L,C ));


_SECTION_BEGIN("Price1");
/*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 ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();*/
 
Last edited:

Nehal_s143

Well-Known Member
Hi Friends,

Just want a small scan for this AFL ...

It is not a normal scan for buy/sell signals...

I want the scan for the given below condition :

If the candle touches the stoploss line in the last 5 mins ( depends on the timeframe I scan ) then when I run the scan after 5 mins it should name the stock.

Hope I am clear ....

Regards

Code:
_SECTION_BEGIN("_ChartTemplat_GD-B_dark");

//-------------------------------------------------------------------------
//----Anweisungen abhängig vom Charttyp------------------------------------
dec = (Param("Decimals",2,0,7,1)/10)+1;
	bi = BarIndex();
	Lbi = LastValue(BarIndex());
	sbi = SelectedValue(bi);
	x1= BarCount-1;


Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1);

cs = GetPriceStyle();   // CS == ChartStyle
choose = ParamToggle("Charttypabhängigkeit?", "Yes|No"); 


if(choose == 0){ 
   if(cs == styleBar){
		chartArt = "bar";
	} 
	else if (cs == styleCandle){
		chartArt = "candle";
	}else{
		chartArt = "line";	
	}

} else {
	chartArt = "";
};


//-------------------------------------------------------------------------
//---- ChartFarben --ChartStyle--------------------------------------------

if(!choose )
	SetChartBkColor( ParamColor("HintergrundFarbe", ColorRGB( 0, 50, 50 ) ) );  // Hintergrund >> nur wenn ChartTemplet greift 

line_color_up =  ParamColor("Line_Color_UP", ColorRGB( 46, 139 , 87 ) );   //- UP - DOWN - 
line_color_down = ParamColor("Line_Color_DOWN", ColorRGB(  220, 20, 60 ) );  //- UP - DOWN - 

bar_color_up =  ColorRGB( 44, 138 , 84);
bar_color_down  = ColorRGB( 220, 22, 60); 

candle_color_up =  ColorRGB( 0, 0, 255);
candle_color_down  = ColorRGB( 255, 0, 0); 
candle_rahmen = ColorRGB( 128, 128 , 128);

spezial_color = ParamColor( "PinBar-Color", ColorRGB( 255, 255 , 0) );


//-------------------------------------------------------------------------
//---- Bedingungen --------------------------------------------------------

// PinBars werden anders coloriert
// Bars/Lines/Candles bei denen open und close dicht beieiander liegen werden anders farbieg dargestellt
// zur Vereinfachung, ist der Abstand Hoch - Tief um Faktor "pinbar_faktor" größer als der Abstand Open-Close, gilt die Bedingung             

pinbar_faktor = Param( "Pinbar-Faktor", 5, 1, 10, 0.1);
bedingungOpenNearClose = abs(H-L)/ pinbar_faktor > abs(O-C) ;
bedingungUp = O< C;


style =  styleNoTitle | ParamStyle("Style");


if(chartArt == "line"){
	Plot( C, "Price", IIf(bedingungOpenNearClose, spezial_color,   IIf( bedingungUp, line_color_up, line_color_down) ),style |styleThick | GetPriceStyle());  // |styleThick

}else if (chartArt == "bar"){
	Plot( C, "Price", IIf( bedingungOpenNearClose, spezial_color, IIf( bedingungUp, bar_color_up, bar_color_down) ),style | GetPriceStyle()); 

}else if (chartArt == "candle"){
	// bei CandleChart wird hiermit die FüllFarbe definiert
	SetBarFillColor( IIf( bedingungUp, candle_color_up, candle_color_down) );
	// Color definiert bei CandlChart den Rahmen
	Plot( C, "Price", IIf (bedingungOpenNearClose, spezial_color, candle_rahmen  ),  style | GetPriceStyle());

}else{
	// StandartChart
	_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 ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
	_SECTION_END();
}

_SECTION_END();

//-------------------------------------------------------------------------
//---- Indis --------------------------------------------------------------

//---ChartTypAbhängiges

if(chartArt == "line"){ 
	// wenn LinienChart
	_SECTION_BEGIN("High_Low_Line");
	HighLine = H;
	LowLine = L;
	farbe_HL = ColorRGB( 65, 65, 65 );
	Plot(HighLine, "", farbe_HL,styleLine|styleDashed|styleNoLabel); //  styleStaircase
	Plot(LowLine, "", farbe_HL,styleLine|styleDashed|styleNoLabel);  // styleLine
	_SECTION_END();

}
_SECTION_END();

_SECTION_BEGIN("NMA Swing");
SetBarsRequired(200,0);

//GraphXSpace = 5;
//SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",3,0.25,50,0.25),0.25,50,0.25);
Per= Optimize("atr",Param("atr",4,3,200,1),3,200,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose,  -1 ),  0.5 );
HaHigh = Max( H,  Max( HaClose,  HaOpen ) );
HaLow = Min( L,  Min( HaClose,  HaOpen ) );
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
j=Haclose;
//Plot(Haclose,"Vinod-cLOSE",IIf(Haclose > Ref(HaClose,-1), colorBrightGreen,
//IIf(Haclose < Ref(HaClose,-1), colorOrange,
//colorOrange)),
//styleLine|styleThick);




//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(10);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;  
NW[0] = 0;  


for(i = 1; i < BarCount; i++)
{
 if(Trend[i-1] == 1)                
 {
  if(j[i] < NW[i-1])                 
  {
   Trend[i] = -1;                   
   NW[i] = j[i] + Revers[i];        
  }
  else                              
  {
   Trend[i] = 1;
   if((j[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = j[i] - Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  } 
 }
 if(Trend[i-1] == -1)               
 {
  if(j[i] > NW[i-1])                
  {
   Trend[i] = 1;                    
   NW[i] = j[i] - Revers[i];        
  }
  else                              
  {
   Trend[i] = -1;
   if((j[i] + Revers[i]) < NW[i-1]) 
   {
    NW[i] = j[i] + Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}

//===============system================

Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=Cover=Cross(j,nw);
Sell=Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
/*Title = EncodeColor(colorWhite)+ "Vinod TIS Swing System" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ */
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1)+
EncodeColor(colorLime)+
WriteIf (Buy , " Go Long Above / Reverse Signal @ "+H+"  ","")+
WriteIf (Sell , " Exit Long Below / Reverse Signal @ "+L+"  ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ 
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss 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(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();

_SECTION_BEGIN("ema's");


/*_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}} ", O, H, L, C));

Title = Name() + "; " + Date() + 
	"\nEMA-1: "  + WriteVal(EMA(C, 1), 1.2) + 	EncodeColor(colorWhite)  + 
   "\nEMA-2: "  + WriteVal(EMA(C, 2), 1.2) + 	EncodeColor(colorCustom11)  + 
   "\nEMA-3: "  + WriteVal(EMA(C, 3), 1.2) + 	EncodeColor(colorCustom9)  + 
   "\nEMA-5: "  + WriteVal(EMA(C, 5), 1.2) + 	EncodeColor(colorDarkOliveGreen)  + 
   "\nEMA-8: "  + WriteVal(EMA(C, 8), 1.2) + 	EncodeColor(colorGold)  + 
	"\nEMA-13: "  + WriteVal(EMA(C, 13), 1.2) + 	EncodeColor(colorOrange)  + 
	"\nEMA-21: " + WriteVal(EMA(C, 21), 1.2) + 	EncodeColor(colorRed) + 
	"\nEMA-44: " + WriteVal(EMA(C, 44), 1.2) +   EncodeColor(colorBlue) , 0,H,L,C ));


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %1.2f, Hi %1.2f, Lo %1.2f, Close %1.2f (%.1f%%) Vol " + WriteVal( V, 1.0 ) + // " {{VALUES}} " + 
	
	"\nEMA-1: "  + WriteVal(EMA(C, 1), 1.2) + 	EncodeColor(colorWhite)  + 
   "\nEMA-2: "  + WriteVal(EMA(C, 2), 1.2) + 	EncodeColor(colorCustom11)  + 
   "\nEMA-3: "  + WriteVal(EMA(C, 3), 1.2) + 	EncodeColor(colorCustom9)  + 
   "\nEMA-5: "  + WriteVal(EMA(C, 5), 1.2) + 	EncodeColor(colorDarkOliveGreen)  + 
   "\nEMA-8: "  + WriteVal(EMA(C, 8), 1.2) + 	EncodeColor(colorGold)  + 
	"\nEMA-13: "  + WriteVal(EMA(C, 13), 1.2) + 	EncodeColor(colorOrange)  + 
	"\nEMA-21: " + WriteVal(EMA(C, 21), 1.2) + 	EncodeColor(colorRed) + 
	"\nEMA-44: " + WriteVal(EMA(C, 44), 1.2) + EncodeColor(colorBlue) , 0,H,L,C ));


_SECTION_BEGIN("Price1");
/*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 ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();*/

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
 

Similar threads