NexusFi: Find Your Edge


Home Menu

 





Adjusting standard indicator (plotting arrows)


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,769 views
    2. thumb_up 6 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Adjusting standard indicator (plotting arrows)

  #1 (permalink)
 RDK91 
Antwerp
 
Posts: 455 since Jun 2016

I am currently trying to add an indicator to my trading system and i would like it to create some alerts.

The indicator i am currently trying to adjust is CCI_Average.
With the standard code this indicator allows for an audio and visual alert to pop up once the CCI value crosses the overbought or oversold area. I have already managed to adjust the code so now the alert pops up when the CCI value crosses both the overbought or oversold are AND the CCI average at the same time.

What i would like to get done now is that once the alert is triggered, the indicator also draws an up arrow for buy signals and a down arrow for sell signals.

I have found some guidelines online but they all seem to be outdated.
Here is the code i am currently working with:

 
Code
using System;
using System.Drawing;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    public class CCI_AverageCUSTOMandARROW : IndicatorObject
    {
        private VariableSeries<Double> m_ccivalue;

        private VariableSeries<Double> m_cciavg;

        private IPlotObject Plot1;

        private IPlotObject Plot2;

        private IPlotObject Plot3;

        private IPlotObject Plot4;

        public CCI_AverageCUSTOMandARROW(object ctx) :
            base(ctx){
            overbought = 100;
            oversold = (-1*100);
            cciavglength = 10;
            ccilength = 11;
        }

        [Input]
        public int ccilength { get; set; }

        [Input]
        public int cciavglength { get; set; }

        [Input]
        public double oversold { get; set; }

        [Input]
        public double overbought { get; set; }

        protected override void Create(){
            m_ccivalue = new VariableSeries<Double>(this);
            m_cciavg = new VariableSeries<Double>(this);
            Plot1 =
                AddPlot(new PlotAttributes("CCI", 0, Color.Cyan,
                                           Color.Empty, 0, 0, true));
            Plot2 =
                AddPlot(new PlotAttributes("CCIAvg", 0, Color.Blue,
                                           Color.Empty, 0, 0, true));
            Plot3 =
                AddPlot(new PlotAttributes("OverBot", 0, Color.Green,
                                           Color.Empty, 0, 0, true));
            Plot4 =
                AddPlot(new PlotAttributes("OverSld", 0, Color.Green,
                                           Color.Empty, 0, 0, true));
        }

        protected override void CalcBar(){
            m_ccivalue.Value = Bars.CCI(ccilength);
            m_cciavg.Value = m_ccivalue.Average(cciavglength);
            Plot1.Set(0, m_ccivalue.Value);
            Plot2.Set(0, m_cciavg.Value);
            Plot3.Set(0, overbought);
            Plot4.Set(0, oversold);
            if (this.CrossesOver(m_ccivalue, m_cciavg)&&(this.CrossesOver(m_ccivalue, oversold))){
                Alerts.Alert("Indicator indicating BUY");
            }
            else{
                if (this.CrossesUnder(m_ccivalue, m_cciavg)&&(this.CrossesUnder(m_ccivalue, overbought))){
                    Alerts.Alert("Indicator indicating SELL");
                }
            }
        }
    }
}


Thanks in advance!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
26 thanks
What is Markets Chat (markets.chat) real-time trading ro …
15 thanks
ApexTraderFunding.com experience and review
13 thanks
GFIs1 1 DAX trade per day journal
12 thanks
EG Indicators
11 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629


Hi RDK91,

you can utilize arrow objects for that and this should get you going:

https://www.multicharts.com/trading-software/index.php/4.3_Plotting_on_the_Chart

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 RDK91 
Antwerp
 
Posts: 455 since Jun 2016


ABCTG View Post
Hi RDK91,

you can utilize arrow objects for that and this should get you going:

https://www.multicharts.com/trading-software/index.php/4.3_Plotting_on_the_Chart

Regards,

ABCTG

Thanks! This really helped me out!
I managed to get it working, the only problem now is that the arrow is plotted over the candle sticks instead of above it for a sell and below it for a buy. Once i got that fixed it will be finishes, thanks again!

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

RDK91,

you are welcome and I am glad to hear that.
Without seeing the code it's tricky to point you in the right direction, but you can use different plot locations or arrow directions based on the signal. This way one arrow could point up using a green color and be located under a bar, while the other arrow could point down using a red color and a location above the high.

Regards,

ABCTG


RDK91 View Post
Thanks! This really helped me out!
I managed to get it working, the only problem now is that the arrow is plotted over the candle sticks instead of above it for a sell and below it for a buy. Once i got that fixed it will be finishes, thanks again!


Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
 RDK91 
Antwerp
 
Posts: 455 since Jun 2016


ABCTG View Post
RDK91,

you are welcome and I am glad to hear that.
Without seeing the code it's tricky to point you in the right direction, but you can use different plot locations or arrow directions based on the signal. This way one arrow could point up using a green color and be located under a bar, while the other arrow could point down using a red color and a location above the high.

Regards,

ABCTG

Currently the code is like this:

 
Code
IArrowObject arrowData1 = DrwArrow.Create(new ChartPoint(Bars.CurrentBar, BarsOfData(1).Close[0]), false);
				arrowData1.Size = 10;

The upward arrows are blue right now and the down arrows are red (not sure yet how i can change this).
I will also attach a screenshot so you can see what i meant by the arrows are plotted over the candles instead of above/below.




My coding experience is 0 so i really appreciate you pointing me in the right direction!

Edit: managed to change the colors!

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

RDK91,

you are using the Close as location in your code:
 
Code
new ChartPoint(Bars.CurrentBar, BarsOfData(1).Close[0])
Using the High or Low, depending on the signal should do it.

Regards,

ABCTG


RDK91 View Post
Currently the code is like this:

 
Code
IArrowObject arrowData1 = DrwArrow.Create(new ChartPoint(Bars.CurrentBar, BarsOfData(1).Close[0]), false);
				arrowData1.Size = 10;

The upward arrows are blue right now and the down arrows are red (not sure yet how i can change this).
I will also attach a screenshot so you can see what i meant by the arrows are plotted over the candles instead of above/below.




My coding experience is 0 so i really appreciate you pointing me in the right direction!

Edit: managed to change the colors!


Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 RDK91 
Antwerp
 
Posts: 455 since Jun 2016


ABCTG View Post
RDK91,

you are using the Close as location in your code:
 
Code
new ChartPoint(Bars.CurrentBar, BarsOfData(1).Close[0])
Using the High or Low, depending on the signal should do it.

Regards,

ABCTG

I wish i could give you more likes! You are my hero!

Everything is exactly as i wanted it now, thank you so much!

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

RDK91,

you are welcome and thank you for the kind words.

You might want to consider posting the code for the benefit of others in the futures.io community.

Regards,

ABCTG


RDK91 View Post
I wish i could give you more likes! You are my hero!

Everything is exactly as i wanted it now, thank you so much!


Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
 RDK91 
Antwerp
 
Posts: 455 since Jun 2016



ABCTG View Post
RDK91,

you are welcome and thank you for the kind words.

You might want to consider posting the code for the benefit of others in the futures.io community.

Regards,

ABCTG

You are right, here is the code! This is just the standard CCI_Average code that i have adjusted so i will only post the part that i have adjusted, the rest is just standard, apart from the settings.

 
Code
protected override void CalcBar(){
            m_ccivalue.Value = Bars.CCI(ccilength);
            m_cciavg.Value = m_ccivalue.Average(cciavglength);
            Plot1.Set(0, m_ccivalue.Value);
            Plot2.Set(0, m_cciavg.Value);
            Plot3.Set(0, overbought);
            Plot4.Set(0, oversold);
            if (this.CrossesOver(m_ccivalue, m_cciavg)&&(this.CrossesOver(m_ccivalue, oversold))){
                Alerts.Alert("Indicator indicating BUY");
				IArrowObject arrowData1 = DrwArrow.Create(new ChartPoint(Bars.CurrentBar, BarsOfData(1).Low[1]), false);
				arrowData1.Size = 5;
				arrowData1.Color = Color.White; 
				
            }
            else{
                if (this.CrossesUnder(m_ccivalue, m_cciavg)&&(this.CrossesUnder(m_ccivalue, overbought))){
                    Alerts.Alert("Indicator indicating SELL");
					IArrowObject arrowData1 = DrwArrow.Create(new ChartPoint(Bars.CurrentBar, BarsOfData(1).High[1]), true);
					arrowData1.Size = 5;
					arrowData1.Color = Color.White;

Reply With Quote




Last Updated on April 24, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts