Im testing a simple strategy enter long when the price is above the MAs , I wanted to see if the variable are behaving properly including the entry / exit and stop loss but I encounter this behavior where the position have its own exit, even without specifying any rules, on zorro manual Stop is default to 0. Can someone explain why is it happening
Heres the code:
Code
function run() {
set(TICKS|LOGFILE);
// Minute
BarPeriod = 1;
Capital = 10000;
LookBack = 500;
NumWFOCycles = 10;
Margin = 0.50 * Capital;
while(asset(loop(Assets))){
vars Close = series(priceClose());
vars Low = series(priceLow());
int EMA13TimePeriod = 13;
int EMA8TimePeriod = 8;
int EMA5TimePeriod = 5;
int ADXTimePeriod = 14;
vars EMA13 = series(EMA(Close, EMA13TimePeriod));
vars EMA8 = series(EMA(Close, EMA8TimePeriod));
vars EMA5 = series(EMA(Close, EMA5TimePeriod));
vars ADX = series(ADX(ADXTimePeriod));
MaxLong = MaxShort = 1;
if (Close > EMA13 && Close > EMA8 && Close > EMA5)
{
enterLong();
}
plot("EMA13",EMA13,LINE,ORANGE);
plot("EMA8",EMA8,LINE,ORANGE);
plot("EMA5",EMA5,LINE,ORANGE);
plot("ADX",ADX,NEW|LINE,BLUE);
}
}
Re: Position stopped even without stop loss / exit rule
[Re: marr]
#477510 07/03/1914:3407/03/1914:34
Sell 1@325.32: -2088 Bid 325.12 at 13:09:00
Opn 327.21 Cls 325.32 Spr 0.200000 Slp 342.11 Rol -0.00 Com 0.00 Net 1
Max Loss 0.00 -> 2087.88
Max Bars 0 -> 569-480
clearly Max Loss have something to do with my issue, tho i can't find about this on the manual
Re: Position stopped even without stop loss / exit rule
[Re: marr]
#477517 07/04/1906:3607/04/1906:36
I wanted to prevent this but i dont understant why the trades are exiting too early even without specifying exitlong and stop, since they are default at 0, i should expect a 1 huge loss
Re: Position stopped even without stop loss / exit rule
[Re: marr]
#477521 07/04/1907:2307/04/1907:23
the margin that I used came from a book, it is originally 5% of my capital, and experimented with different values, tho the time of margin call is different, but i wanted to know why the trade exits too early which causes failure of the system , even specifying hard rules
Re: Position stopped even without stop loss / exit rule
[Re: marr]
#477528 07/04/1914:2507/04/1914:25
A margin call is not good. That your trades are closed is then the least of your worries!
Delete your lines with "Margin" and "Capital", they are the reason of the margin call. Your trade signal is also wrong. Begin with the tutorial, there is also a workshop where you learn what "Margin" and "Capital" are and how to use them.
Re: Position stopped even without stop loss / exit rule
[Re: Petra]
#477529 07/04/1914:3807/04/1914:38
I understand that the strategy is bad, i dont mind margin call actually, its just, there are trades that exit at 0 sec after it enter which is kinda weird for me, since I did not set up a stop loss and risk which is now default to 0 and the code doesnt have exitLong() that would make the trade exit right away. That is the mystery that i am trying to look out for days.
Here is the testrade logs of some part on the image. ive also display the duration of the trade.