Simple Coding Help - No Promise.

Romeo1998

Well-Known Member
Thanks mate.

I getting errors in the first five lines bro. Variable 'buy' used without having been initialized. And same errors for the other four lines too.
Hello @JediStar Sir,
Earlier code was for Augubhai Sir's ORB system v1.1 :)
this code is for Moving Average Exploration :)
Code:
_SECTION_BEGIN("Moving Average Exploration");
MA20=MA(C, 20);
MA50=MA(C, 50);
MA100=MA(C,100);
MA200=MA(C,200);
buycond = C>MA20 AND MA20>MA50 AND MA50>MA100 AND MA100>MA200;
sellcond = C<MA20 AND MA20<MA50 AND MA50<MA100 AND MA100<MA200;
Buy=Cover= buycond;
Sell = Short = sellcond;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
Filter = Buy OR Sell OR Short OR Cover;
AddColumn(Close, "Close", 1.2);
AddColumn(Volume, "Volume", 1.2);
AddColumn(MA(C, 9), "MA9");
AddColumn(MA(C, 20), "MA20");
AddColumn(MA(C, 50), "MA50");
AddColumn(MA(C, 100), "MA100");
AddColumn(MA(C, 200), "MA200");
AddColumn(IIf(Buy,c,Null),"Buy",1.2);
AddColumn(IIf(Sell,c,Null),"Sell",1.2);
AddColumn(IIf(Short,c,Null),"Short",1.2);
AddColumn(IIf(Cover,c,Null),"Cover",1.2);
_SECTION_END();
Best of Luck :)
 
Thanks so much mate... you are amazing.

Strangely the output that I was expecting doesnt seem to reflect, and the blame is on me 100%.

I just reviewed this group and I see this group is more for trading intraday, and I believe that is for the same reason, besides you no body else pitched in, but I am glad you did :).

Anyways I sincerely appreciate your assistance here. God bless you more abundance.

Cheers
JS
 
Dear Sir,
I am new to amibroker i am not aware how to create new formula in amibroker, even code also. Somewhere i find a file for amibroker formula & pasted. Can you help me to know what is this formula meaning i.e. moving average time period, supertrend,Buy sell signal, MACD etc in details. I will be highly obliged. Thanks in advance.


_SECTION_BEGIN("My Trading System");
NewTradingSystem();
_SECTION_END();
_SECTION_BEGIN("Trend Lines");
p1 = Param("TL 1 Periods", 13, 5, 50, 1);
p2 = Param("TL 2 Periods", 3, 3, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGreen), ParamColor("TL Dn Colour", colorRed));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
Plot(TL2, "TriggerLine 2", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();
 
Hi Legends/expert in afl coding
What I am trying to do-
  1. I am trying to plot daily highest or lowest price in any time frame I am using. I want to use it for eod data in which I have minimum timeframe daily and in separate chart for intraday in time frame I am using for analysis.
    I am trying to plot line chart . If in same period high or low. I want to plot both for same day as occur.
    Suppose if after open it was high first then my line first shows that high and when after that high it goes to low on same period it will plot that low also without repainting that that high already done.
Basically I want to plot this to count my elliot wave properly and get more clear picture to save my time. want to make it like wave chart by Glenn Neely for neo wave count manually.
For that I get little success with this code
_SECTION_BEGIN("Price");
x=IIf(C>O,H,L);
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(x , "Price", colorBlue,styleDots );
_SECTION_END();
This is screen short

Now problem -
When closing high or low after open without retracement then showing ok. But after open if low or high and then close above or below open then it shows only condition met open above high or low. So that error I am not able to solve.
If required separate coding for EOD and intraday no problem we save both and use accordingly.
Humble request to every one who knew afl coding very well to help me to solve this. And this can help all of us.
Thanz a lot in advance.
Regards
Manish
 

RadhuK

Well-Known Member
Hi all
Need help

I want line drawn between yesterday's HIGH and day before yesterday's High
and line between yesterday's Low and day before yesterday's Low
as shown in first chart

The code I used from Amibroker Help gave the result in chart shown below.
Code I used …

tHY = TimeFrameGetPrice("H", inDaily, -1, expandFirst);
tLY = TimeFrameGetPrice("L", inDaily, -1, expandFirst);
tHYY = TimeFrameGetPrice("H", inDaily, -2, expandFirst);
tLYY = TimeFrameGetPrice("L", inDaily, -2, expandFirst);
MyPeriod = 2;
for( i = 0; i < MyPeriod AND i < BarCount; i++ )
{
y0=LastValue(tHYY);
y1=LastValue(tHY);
x0=BarCount - 1 - LastValue(tHYY);
x1=BarCount - 1 - LastValue(tHY);
Line = LineArray( x0, y0, x1, y1 ,1,usebarindex = True );
Plot( Line, "Trend line", colorBRIGHTGREEN );
y0=LastValue(tLYY);
y1=LastValue(tLY);
x0=BarCount - 1 - LastValue(tLYY);
x1=BarCount - 1 - LastValue(tLY);
Line = LineArray( x0, y0, x1, y1 ,1,usebarindex = True );
Plot( Line, "Trend line", colorRED );
}
GRASIM  GETTING THIS.png
GRASIM OK.png


Please help me with correct code.
 
please someone convert this easy ninjatrader code to amibroker

Code:
  using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Xml.Serialization;
namespace NinjaTrader.Indicator
{
 

    [Description("the GValue indicator")]
    public class EOTGvalu : NinjaTrader.Indicator.Indicator
    {
        private DataSeries demaSeries;
        private DataSeries gvSeries;
        private double plotLevel;
        private double sensitivity = 90.0;

        protected override void Initialize()
        {
            base.Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Cross, "GValuBuy"));
            base.Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Cross, "GValuSell"));
            base.CalculateOnBarClose = true;
            base.Overlay = false;
            base.PriceTypeSupported = false;
            this.demaSeries = new DataSeries(this);
            this.gvSeries = new DataSeries(this);
            base.Name="EOTGvalu";
        }

        protected override void OnBarUpdate()
        {
            NinjaTrader.Indicator.EMA ema = base.EMA(base.Close, 0x22);
            NinjaTrader.Indicator.EMA ema2 = base.EMA(base.Close, 0x37);
            this.demaSeries.Set(Math.Abs((double) (ema[0] - ema2[0])));
            MAX max = base.MAX(this.demaSeries, 0x59);
            double num = 0.0;
            if (max[0] > 0.0)
            {
                num = 100.0 * ((ema[0] - ema2[0]) / max[0]);
            }
            if (num >= this.sensitivity)
            {
                this.GValuSeries.Set(1.0);
                this.GValuSell.Set(this.plotLevel);
            }
            else if (num <= -this.sensitivity)
            {
                this.GValuSeries.Set(-1.0);
                this.GValuBuy.Set(this.plotLevel);
            }
            else
            {
                this.GValuSeries.Set(0.0);
            }
        }

        [Browsable(false), XmlIgnore]
        public DataSeries GValuBuy
        {
            get
            {
                return base.Values[0];
            }
        }

        [Browsable(false), XmlIgnore]
        public DataSeries GValuSell
        {
            get
            {
                return base.Values[1];
            }
        }

        [Browsable(false), XmlIgnore]
        public DataSeries GValuSeries
        {
            get
            {
                return this.gvSeries;
            }
        }

        [GridCategory("Parameters")] [Description("Where in the panel do you want to plot GValu?")]
        public double PlotLevel
        {
            get
            {
                return this.plotLevel;
            }
            set
            {
                this.plotLevel = Math.Max(-9999.0, value);
            }
        }

        [Description("How Sensitive Do you Want GValu to be?")] [GridCategory("Parameters")]
        public double Sensitivity
        {
            get
            {
                return this.sensitivity;
            }
            set
            {
                this.sensitivity = Math.Max(0.01, value);
            }
        }
    }
}
 

josh1

Well-Known Member
I want an Alert for High Volume Bar.
Code:
_SECTION_BEGIN("HighVol");

//Peaking Volumes
HiVolume = IIf(V > (2 * EMA(V,10)), True, False);
LoVolume = IIf(V < (2 * EMA(V,10)), True, False);
HiVolume = ExRem(HiVolume,LoVolume);
LoVolume = ExRem(LoVolume,HiVolume);
IIf(HiVolume, Say (" High Volume be alert"),Null);

PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);

_SECTION_END();
This alert keeps repeating for every bar. I want it only for High Volume Bar. Please help. Thanks
 

Similar threads