Need help with my first indicator

 

Ok this is nothing special I just want to make an indicator that increases in value by 1 if bid is greater than last bid price or decreases in value if bid is less than last bid price.

The variable I used for last bid price is called Last_Bidprice which I try to assign to bid. I have no idea what represents the line on my indicator and that is one of the things I want to learn.

I hope I get some laughs and I know this is really bad but I'm just trying to jumpstart my learning because I feel I'm getting nowhere just reading this literature

which has very little examples.

So here we go this is what I did that will not work:


//+------------------------------------------------------------------+
//| ##last bid price.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
double Last_Bidprice = 0;
Last_Bidprice = Bid;
int line = 0;
line = ExtMapBuffer1;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();

if (Bid = > Last_Bidprice);
{
line ++


}
else if (Bid = < Last_Bidprice)
{
line --
}

//----

//----
return(0);
}
//+------------------------------------------------------------------+



I'm just looking for some pointers to learn how to code. I don't care about this indicator it's just to learn something.

Thank you, CV

 

hey,

the general indicator idea as outlined doesnt make much sense to me, but I cleaned the code and changed it so it can reflect your logic. I am attaching the file, it compiles fine.

Please note the changes in your start() function...

Hope the above helps!

thank you

Automated (automatedfx@gmail.com)

--
http://www.forexmosaic.com/ - free publishing, analyzing and portfolio building service

Files:
Reason: