1) this
int candle; bool bear, bull, neutral, Candle; if(Close[1]<Open[1]Candle= bear; if(Close[1]>Open[1])Candle= bull; if(Close[1]==Open[1])Candle= neutral;// the previous candle type, I have to setup the time initialization next return(candle);
belongs in the section start
2) int candle; cant be bear, bull or neutral
3) u need to check if there is a new bar If not, you will get a file in size u cant imagine
4) what for u need the int i;
Hi
It will be the previous bar, will set this to perform the check at 2200 gmt and then it will check the type of candle the previous bar is (Close[1])?
So it will save in the file what the candle is that closed at 2200.
I am not sure about the int i; as I am new to coding, I was wondering if I can have some help with this?
Just wondering what this means: "2) int candle; cant be bear, bull or neutral"
Thanks
Antony
I have moved:
int candle; bool bear, bull, neutral, Candle; if(Close[1]<Open[1]Candle= bear; if(Close[1]>Open[1])Candle= bull; if(Close[1]==Open[1])Candle= neutral;// the previous candle type, I have to setup the time initialization next return(candle);
To the start:
//+------------------------------------------------------------------+ //| candle.mq4 | //| Copyright © 2010, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int candle; bool bear, bull, neutral, Candle; if(Close[1]<Open[1])Candle= bear; if(Close[1]>Open[1])Candle= bull; if(Close[1]==Open[1])Candle= neutral; return(candle); int handle; int init() { //Open file///////////////////////////////////////////////////////////////////////////////////////////////////////// handle=FileOpen("data1.csv",FILE_CSV|FILE_READ|FILE_WRITE,','); if(handle<1) { Comment("File data1.csv not found, the last error is ", GetLastError()); return(false); } else { Comment("Ok"); FileWrite(handle, "Time","Pair","Candle type"); Comment("1"); } return(handle); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i; //Write to file////////////////////////////////////////////////////////////////////////////////////////////// FileWrite(handle, Candle, TimeCurrent(), Symbol(), candle); return(0); } //+------------------------------------------------------------------+
Thanks
Antony
I have moved:
To the start:
Thanks
Antony
no u don't
i said to start section & not to start of the file
- exactly
bool bear, bull, neutral, Candle; if(Close[1]<Open[1])Candle= bear; if(Close[1]>Open[1])Candle= bull; if(Close[1]==Open[1])Candle= neutral;
equivalent code:bool Candle; if(Close[1]<Open[1])Candle= 0; if(Close[1]>Open[1])Candle= 0; if(Close[1]==Open[1])Candle= 0;
maybe you want an enumeration, something likeint Candle; // INT not bool #define bear 1 #define bull 2 #define neutral 3 if(Close[1]<Open[1])Candle= bear; else if(Close[1]>Open[1])Candle= bull; else Candle= neutral;
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I am trying to save the final candle of the trading day to a csv file, logging the currency pair and the candle type ie bull, bear, neutral.
I have used this code below and modifed it for my use but I am new to coding and cant seem to get it to work, please can anyone help with this?
Thank you
Antony