Simple Coding Help - No Promise.

casoni

Well-Known Member
Hello,

Check this

TimeFrameSet( inDaily);
ma1 = EMA(C, 5 );
ma2 = EMA(C, 10 );
TimeFrameRestore();
ema1= TimeFrameExpand( ma1, inDaily,expandLast);
ema2=TimeFrameExpand( ma2, inDaily,expandLast);
conditionA=(ema1>ema2);
conditionB=(ema2>ema1);

Plot(ema1,"",IIf(conditiona,5,4),1);
Plot(ema2,"",31,1);


breakoutime=ParamTime( "brk Time ", "9:25:00" );
afterbreakout0 = Cross(TimeNum(),breakoutime);
myc= IIf(afterbreakout0, colorYellow,47);
P = ParamField( "Price field" );
xO = ValueWhen(afterbreakout0,P);
Plot(XO,"4th Bar",1,32);

SetBarFillColor( myc);
PlotOHLC(O,H,L,C,"",myc,132);
 

ethan hunt

Well-Known Member
Hello,

Check this

TimeFrameSet( inDaily);
ma1 = EMA(C, 5 );
ma2 = EMA(C, 10 );
TimeFrameRestore();
ema1= TimeFrameExpand( ma1, inDaily,expandLast);
ema2=TimeFrameExpand( ma2, inDaily,expandLast);
conditionA=(ema1>ema2);
conditionB=(ema2>ema1);

Plot(ema1,"",IIf(conditiona,5,4),1);
Plot(ema2,"",31,1);


breakoutime=ParamTime( "brk Time ", "9:25:00" );
afterbreakout0 = Cross(TimeNum(),breakoutime);
myc= IIf(afterbreakout0, colorYellow,47);
P = ParamField( "Price field" );
xO = ValueWhen(afterbreakout0,P);
Plot(XO,"4th Bar",1,32);

SetBarFillColor( myc);
PlotOHLC(O,H,L,C,"",myc,132);
Thanks for your AFL.

The main purpose of this AFL was to backtest the system.

Backtesting is not working as buy sell attributes are missing.
 
hi, all afl experts. pls code this strategy.

strategy is mainly karthik sri's 2 candle strategy with some modification.

Strategy ----

We look for subsequent Two Green/White candle for Long & Two Red/Black candle for Short.

Rules ----

for Buy -- 1. 2nd of the same color should not go below 50% of the previous candle.
2. 2nd candle =< 1st candle
3. 1st candle must be above 20 ema. otherwise setup is invalid.

for Short --- vice versa.

if possible, put some alert. i want alert at the start of 10th minute, that alert me for trade opportunity.
if that is not possible then put alert at the end of valid setup.
 

casoni

Well-Known Member
Thanks for your AFL.

The main purpose of this AFL was to backtest the system.

Backtesting is not working as buy sell attributes are missing.
Yes i know ..
that i have left part for you , to complete :)
 
PHP:
/* Done by    Rajandran R  */ 
/* Author of www.marketcalls.in  */ 
  
_SECTION_BEGIN("N Bar High/Low Dots"); 
  
SetBarsRequired(100000,0); 
  
GraphXSpace = 15; 
  
SetChartOptions(0,chartShowArrows|chartShowDates); 
  
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0))); 
  
GfxSetBkMode(0); 
  
GfxSetOverlayMode(1); 
  
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); 
  
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0); 
  
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 
  
nhigh = Param("N Bar High", 20, 1,100,1); 
nlow =  Param("N Bar Low", 20, 1,100,1); 
  
nhi = HHV(H,nhigh); 
nlow = LLV(L,nlow); 
  
hidot = IIf(nhi>Ref(nhi,-1),True,False); 
lowdot = IIf(nlow<Ref(nlow,-1),True,False); 
  
Plot(IIf(hidot,H,Null),"High Dots",coloryellow,style = styleDots | styleThick | stylenoline); 
Plot(IIf(lowdot,L,Null),"Low Dots",colororange,style = styleDots | styleThick | stylenoline); 
  
_SECTION_END();


courtesy --- market calls


could we have scan/explore function to enable scan in this afl !


best rgds


sumit
 

amitrandive

Well-Known Member
PHP:
/* Done by    Rajandran R  */ 
/* Author of www.marketcalls.in  */ 
  
_SECTION_BEGIN("N Bar High/Low Dots"); 
  
SetBarsRequired(100000,0); 
  
GraphXSpace = 15; 
.
.
 
_SECTION_END();


courtesy --- market calls


could we have scan/explore function to enable scan in this afl !


best rgds


sumit
Try this

Code:
/* Done by    Rajandran R  */ 
/* Author of www.marketcalls.in  */ 
  
_SECTION_BEGIN("N Bar High/Low Dots"); 
  
SetBarsRequired(100000,0); 
  
GraphXSpace = 15; 
  
SetChartOptions(0,chartShowArrows|chartShowDates); 
  
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0))); 
  
GfxSetBkMode(0); 
  
GfxSetOverlayMode(1); 
  
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); 
  
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0); 
  
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 
  
nhigh = Param("N Bar High", 20, 1,100,1); 
nlow =  Param("N Bar Low", 20, 1,100,1); 
  
nhi = HHV(H,nhigh); 
nlow = LLV(L,nlow); 
  
hidot = IIf(nhi>Ref(nhi,-1),True,False); 
lowdot = IIf(nlow<Ref(nlow,-1),True,False); 
  
Plot(IIf(hidot,H,Null),"High Dots",colorYellow,style = styleDots | styleThick | styleNoLine); 
Plot(IIf(lowdot,L,Null),"Low Dots",colorOrange,style = styleDots | styleThick | styleNoLine); 
  
_SECTION_END();  

Filter=hidot OR lowdot ;
AddColumn(IIf(Hidot,Hidot,Null)  ," New High "  ,6.2,1.2,colorGreen);
AddColumn(IIf(Lowdot,Lowdot,Null)," New Low ",6.2,1.2,colorOrange);

_SECTION_END();
 

casoni

Well-Known Member
That's mission impossible for me.

Kindly help !
Okay check this ....


fast=Param("Ma Fast",5,3,20,1);
slow=Param("Ma Slow",10,6,40,1);
TimeFrameSet( inDaily);
ma1 = EMA(C, fast );
ma2 = EMA(C, slow );
TimeFrameRestore();
ema1= TimeFrameExpand( ma1, inDaily,expandLast);
ema2=TimeFrameExpand( ma2, inDaily,expandLast);
conditionA=(ema1>ema2);
conditionB=(ema1<ema2);

Plot(ema1,"",IIf(conditiona,5,4),1);
Plot(ema2,"",31,1);

breakoutime=ParamTime( "brk Time ", "9:25:00" );
afterbreakout0 = Cross(TimeNum(),breakoutime);
myc= IIf(afterbreakout0, colorYellow,31);
P = ParamField( "Price field" );
xO = ValueWhen(afterbreakout0,P);
Plot(XO,"4th Bar",1,32);
SetBarFillColor( myc);
PlotOHLC(O,H,L,C,"",myc,132);

Buy=Cover=IIf(conditionA,afterbreakout0,0);
PlotShapes(Buy*1,5,0,L,-15);
Sell=short=IIf(conditionB,afterbreakout0,0);
PlotShapes(Short*2,4,0,H,-15);
BuyPrice=CoverPrice=ValueWhen(Buy,P,1);
SellPrice=ShortPrice=ValueWhen(Short,P,1);

PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorGreen,0,buyPrice,0);
PlotShapes(IIf(short,shapeSmallCircle,shapeNone),colorRed,0,ShortPrice,0);

Hope, this meets your requirement
 
conversion to metastock data to amibroker

sir
i seen ur thread hope u can identify mine problem , i can upload data from meta stock downloader bt i can't use it in amibroker
please tell me way how to use that data

Thanks
Ishwar
 

casoni

Well-Known Member
Re: conversion to metastock data to amibroker

sir
i seen ur thread hope u can identify mine problem , i can upload data from meta stock downloader bt i can't use it in amibroker
please tell me way how to use that data

Thanks
Ishwar
you can import those data into amibroker
via import wizard
in amibroekr toolbar go to FILE > IMPORT WIZARD , show your data path ,
then define data format [ I.e define fields , as per your uploaded data / export data from MS ]
 

Similar threads