Hello, I want to buy after two consecutive down gaps at the open of next day and sell at the close of same day. I'm trying to learn EL before I commit to an account. Will this code work? if L[2] > H[1] AND L[1] > H[0] then begin Buy Next Bar at open; sell next bar at close; end; I don't know whether the sell command to exit position can be activated if inside the conditional and before a position is established. Thanks, Bill
I'm not sure but you may have to check MarketPosition first, like in: If MarketPosition = 1 then sell next bar at close; John
If you want to learn Easylanguage, you must join this news group, it is run by Samuel K. Tennis, author of âAsk Mr. EasyLanguageâ, creator of the EasyLanguage programming language. http://finance.groups.yahoo.com/group/MrEasyLanguage/
For daily bars, that will basically work because the orders placed will most certainly result in fills. So in this particular case, MarketPosition is not really needed unless you want to place these orders only when already flat. In that case, just qualify the orders: If MarketPosition = 0 Then if L[2] > H[1] AND L[1] > H[0] then begin Buy Next Bar at open; sell next bar at close; end; End;
This code will buy the open on the 3rd bar after 2 gaps down . The sell command is issued correctly and does not require a position before you send it.
Thank you all. Another question: if the third bar forms another down gap, will the code generate a new entry at the open of the fourth bar? Bill
No. If he does not use my code to check his MarketPosition, he will just increase the size of his long position.
this might help: http://www.amazon.com/Building-Winn..._bbs_sr_1/105-6364305-8478830?ie=UTF8&s=books <img src="http://ecx.images-amazon.com/images/I/51JF48982DL._SL500_BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg">