Simple Coding Help - No Promise.

pratapvb

Well-Known Member
no amit ji i want its on macd not on bar

Thanks for reply

Abhishek
peak since buy signal?

then just do highestsince(buy, ml) ;

similarly lowestsince
 
Code:
// basic priceatbuy code by Tomasz Janeczko, multiple modifications by trash

delay = 1;
SetTradeDelays( delay, delay, delay, delay );// used in analysis
SetPositionSize( 10, spsPercentOfEquity );

if ( delay > 0 )
{
    array  = Open;
}
else
{
    array  = Close;
}

Buy   = Sell = 0;
Short = Cover = 0;
BuyPrice = SellPrice = array;

_MA = MA( C, 20 );
BuyConditions = Cross( C, _MA );

priceatbuy = Null;  
priceatsell = Null;
patba = Null; // PriceAtBuy Array (for plotting only)
patse = Null;

for ( i = delay; i < BarCount; i++ )
{
    SellSignal = array[ i ] > priceatbuy;

[COLOR="red"]Here is a condition, right? Sellsignal is true if array[i] 
is higher than priceatbuy. But how can this conditional work
 if priceatbuy is null, as setted above? It means it 
will always be null. [/COLOR]

    if ( SellSignal AND NOT IsNull( priceatbuy ) )

[COLOR="red"]Again, how can SellSignal be anything
 other than null? or is sellsignal some kind of 
built in function? [/COLOR]

    {
        Sell[ i - delay ] = 1;
        priceatbuy = Null;
        priceatsell = SellPrice[i];
    }

    BuySignal = BuyConditions[ i - delay ];

    if ( IsNull( priceatbuy ) AND BuySignal )
    {
        Buy[ i - delay ] = 1;
        priceatbuy = BuyPrice[ i ];
        priceatsell = Null;
    }

    // to plot price at buy and sell you need an ARRAY, not scalar
    patba[ i ] = priceatbuy; 
    patse[ i ] = priceatsell;    
}

SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%), Vol %g {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ), V ) );
Plot( C, "Close", ParamColor( "Color Price", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle(), 0, 1, 0, 0);

Plot( patba, "priceatbuy", colorGreen, styleLine, Null, Null, 0, 1 );
Plot( patse, "priceatsell", colorRed, styleLine, Null, Null, 0, 1 );
Plot( _MA, "MA", ParamColor( "Color MA", colorCycle ), styleLine );

PlotShapes( Buy*shapeUpArrow, colorGreen, 0, H, -15 );
PlotShapes( Buy*shapeHollowUpArrow, colorWhite, 0, H, -15 );
PlotShapes( Ref( Buy, -delay )*shapeHollowSmallCircle, colorGreen, 0, BuyPrice, 0 );

PlotShapes( Sell*shapeDownArrow, colorRed, 0, H, -15 );
PlotShapes( Sell*shapeHollowDownArrow, colorWhite, 0, H, -15 );
PlotShapes( Ref( Sell, -delay )*shapeHollowSmallCircle, colorRed, 0, SellPrice, 0 );
Hello, Mr. Trash. Well, I think I got a bit better at working with AFL. So my questions here, now, are just code wise. I just want to try to understand the creation process of this code you showed here a while ago. I'll post my questions in the above code ared, in RED.

If you, or anyone else, could solve my questions, I would be really glad.

Thanks!!
 
Code:
SetBarFillColor(IIf(C > O, GetChartBkColor(), colorRed)); 
Plot( C, "Close", IIf(C > EMA(C,50), colorGreen, colorRed), styleCandle | styleNoTitle);

Dear Mr.Happy,

will you please correct this code for this conditon. two successive close above ema50 and when the third or successive candle breaks the first two candle high we can change the candle color to Green. and when 2 successive candles closed below ema50 and the third or the succesive candle breach the low of the first two candle the candle become red.

i am a beginer with a very little knowledge in coding....please guide me

SetBarFillColor(IIf(C > O, GetChartBkColor(), colorRed));
Plot( C, "Close", IIf(C > EMA(C,50),-2) == 1 AND Ref(EMA(C,50), -1)) == 1 AND Close > HHV(High, 2)), colorGreen, colorRed), styleCandle | styleNoTitle);
 

ajeetsingh

Well-Known Member
do anybody has this afl? posted here in tradeji itself
Komal,
This is my personal system
Developed for my personal use only.
Sorry not for sale or sharing......
Though I can tell that system is targeted for 1% daily with minimal SL
Scans 200 stocks and give signals in 2-3 stocks only
Its based totally on 200 EMA, MA, DEMA and reflection of price from the same,
without looking future.
So please dont search for the same
You can also try to build the same.
see images below:





Logic is simple, based on bouncing back of price from big EMA's
That's All
Happy Trading
 

Similar threads