Coding help - page 50

 

How can I clear/delete a txt file

Hi,

I am using this functions:

File Operations via WinAPI - MQL4 Articles

How should I clear the text in my csv-File?

Or how can I delete it?

 

To clear the file use _lcreat(simply create a new empty file)

To delete the file you could use DeleteFileAor DeleteFileWfunctions (they are not declared in that example but are in the same kernel32.dll library - both are having a single argument - a string containing the name and the path of the file to delete)

sunshineh:
Hi,

I am using this functions:

File Operations via WinAPI - MQL4 Articles

How should I clear the text in my csv-File?

Or how can I delete it?
 

and to make it withe colour rsi w/ alert?! color_rsi_with_allert.mq4

mladen:
Hiyieldrater2

Here is this version. It is using a regular rsi not the one you proposed. There are a couple of reasons but the main reason is that Figuerelli rsi depends on the number of bars it is calculated on what result you are going to get. Here is a simple comparison of the same indicator calculated for 5000 bars (upper) and 1000 bars (lower)

So I decided not to use that one for that reason (since case like the one above makes it a repainting indicator).

Anyway, in the attached indicator there is one parameter that might need an explanation : Level. It is the number of pivot levels you wish to be drawn. It can draw from 0 (just pivot line) to level 3 (up to support and resistance level 3). Default is 2 but change it as you wish. Using the pivot line gives to the indicator a sort of floating zero line and it seems that if you use the pivot as a zero line cross that signals are faster than the regular levels crosses

Have a nice weekend
 

for rsi + pivots - #466

zigflip:
and to make it withe colour rsi w/ alert?! color_rsi_with_allert.mq4
 

Hi, thank you for your tipp,

but both functions

bool DeleteFileA(string buffer);

and

bool DeleteFileW(string buffer);

doesn't work :-(

I only got "false" als return value.

Do you have another tipp?!

 

Make sure that the file is closed (by any instance of code(s)) before you try to delete it. Other than that, if the path and the file name are correct, it should work

sunshineh:
Hi, thank you for your tipp,

but both functions

bool DeleteFileA(string buffer);

and

bool DeleteFileW(string buffer);

doesn't work :-(

I only got "false" als return value.

Do you have another tipp?!
 

...

Tried it and it works

Here is a working example (in which you can chose if you wish just to delete or you wish to delete and then immediately create an empty file - this example is an indicator that does it on every new bar, but it can work in any code)

//------------------------------------------------------------------

//

//------------------------------------------------------------------

#property indicator_chart_window

#import "kernel32.dll"

int _lopen (string path, int of);

int _lcreat (string path, int attrib);

int _llseek (int handle, int offset, int origin);

int _lread (int handle, string buffer, int bytes);

int _lwrite (int handle, string buffer, int bytes);

int _lclose (int handle);

int DeleteFileA(string path);

#import

extern bool doCreate = true;

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init() { return(0); }

int start()

{

static datetime lastDeleted=0;

if (lastDeleted!=Time[0])

{

lastDeleted = Time[0]; int result = DeleteFileA("E:\\test\\testfile.txt"); Comment(result);

if (doCreate)

{

int handle = _lcreat("E:\\test\\testfile.txt",0); if (handle > -1) _lclose(handle);

}

}

return(0);

}
sunshineh:
Hi, thank you for your tipp,

but both functions

bool DeleteFileA(string buffer);

and

bool DeleteFileW(string buffer);

doesn't work :-(

I only got "false" als return value.

Do you have another tipp?!
 

Hi,

lot's of thanks for your code-snippet!!!

It works also on my laptop, but when I want to change the time, so that the indicator has to create, write and delete a few times per minute (3x), it doesn't work anymore :-(

So I think I have to overwrite my old entries each time...

 

MT4 alert indicator only at certain time

Hi Mladen (and others), do you know of a price alert indicator that only checks price at a certain time?

 

time_vlines.mq4

Andrewsurfer:
Could someone change this indicator to show only one line (today) not for all days.

Anyone? Please.

Files: