Hello dear sirs,
I'll try to apply in AFL an idea for the intraday trending. The idea is that it takes some Long or Short positions and closes in a Target, while there is a stop level too. Other times it is successful (profit) and others not (losses). So I thought I'd pass these signals on a daily chart to look at, what could be causes the losses to be avoided. So I did (for example) the following effort, but I did not.
Is there a possibility for some help? Thanks for any help.
Buy=Cross(MACD(),0);
Sell=Cross( 0, MACD());
BuyPrice = ValueWhen(buy , Close);
SellPrice = ValueWhen(sell , Close);
loss= SellPrice< BuyPrice ;
bir = Status( "barinrange" );
dn = DateNum();
bi = BarIndex();
dt = DateTime();
Plot( ml = MACD(),"MACD", colorRed,1 );
PlotGrid(0, colorBlue);
PlotShapes(IIf(Sell, shapeHollowCircle,shapeNone),IIf(loss,colorRed,colorGreen),0,ml,0);
PlotShapes(IIf(Buy, shapeSmallCircle,shapeNone),5,0,ml,0);
//my first step is In Intraday - lower time frame to run an exploration and store a custom array in statickvar with dateNum()
if( Status( "Action" ) == actionExplore )
{
Filter = Sell;
SetOption( "NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn( sell, "SellSignal", 1 );
AddColumn( IIf( Sell, loss, Null ) , "loss", 1, colorDefault, IIf( loss, colorRed, colorDefault ) );
for( i = 0; i < BarCount; i++ )
{
if( bir[i] )
{
// store a custom array in staticvar with dateNum()
IIf( Sell[i] , StaticVarSet( "SYS_dateSell_" + i, dn[i] ,1) , Null );
}
}
}
// my second step is to see if debbuger is right? and looks ok
// Then i try to PlotShapes on the chart on dayly (or higher Time Frame)
// but no luck....what i am doing wrong here?
if(ParamTrigger(" for debuger", "press to run Once") )
{
for( i = 0; i < BarCount; i++ )
{
if(Sell[i] and loss[i] ) // if we have a loss potition
{
//SV= StaticVarget( "SYS_dateSell_" + i);
specificDay= DateTimeConvert(2, StaticVarget( "SYS_dateSell_" + i));
x= Lookup( loss[i], specificDay ); // <<< this line looks ok on the debbuger
PlotShapes(IIf(x[i], shapeDigit0,shapeNone),IIf(loss,colorRed,colorGreen),0,0,-50); // but PlotShapes NOT plot
_TRACE("#, dt"+ dn[i]+", look up= " + x);
_TRACE("#, dn= "+ dn[i]+", look up= " + x + ", specificDay "+DateTimeConvert(2, StaticVarget( "SYS_dateSell_" + i)));
//_TRACE("#, i= " + i + " ,SYS_dateSell_ = "+ StaticVarget( "SYS_dateSell_" + i) + ", specificDay "+DateTimeConvert(2, StaticVarget( "SYS_dateSell_" + i)) ) ;
}
}
}