SimpleEquityRecorder

Orders Execution
It automatically opens orders when conditions are reached
Miscellaneous
Uses files from the file systemIt writes information to file
0 Views
0 Downloads
0 Favorites
SimpleEquityRecorder
#define copyright "simple buy/sell and hold - for equity recording - by transcendreamer"
extern int MAGIC=13123123;
extern double balance=5000;
extern double position = 0.01;
extern datetime start = D'2009.01.01 00:00';
bool opened=false;
datetime savedtime=0;
void init()
{
int handle=FileOpen(Symbol()+Period()+"_equity.csv",FILE_WRITE|FILE_CSV);
FileSeek(handle,0,SEEK_END);
FileWrite(handle,"TIME",Symbol());
FileClose(handle);
}
void start()
{
if(Time[0]==savedtime) return; savedtime=Time[0];
if(Time[0]>=start){
if(!opened){
if(position>0) OrderSend(Symbol(),OP_BUY,position,Ask,0,0,0,"",MAGIC,0,Blue);
if(position<0) OrderSend(Symbol(),OP_SELL,-position,Bid,0,0,0,"",MAGIC,0,Red);
opened=true;}
int handle=FileOpen(Symbol()+Period()+"_equity.csv",FILE_READ|FILE_WRITE|FILE_CSV);
FileSeek(handle,0,SEEK_END);
FileWrite(handle,TimeToStr(Time[0]),AccountEquity()-balance);
FileClose(handle);
}}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---