Traders Laboratory - View Single Post - Easylanguage and Script Help
View Single Post
  #25 (permalink)  
Old 03-28-2008, 07:51 AM
Blu-Ray's Avatar
Blu-Ray Blu-Ray is offline
Blu-Ray is or is not online

Trader Specs
 
Join Date: Nov 2006
Location: England
Posts: 399
Thanks: 92
Thanked 33 Times in 21 Posts
Re: Easylanguage and Script Help

Quote:
View Post
Wow!

Thanks so much!

I now only have one problem.

For some reason when using the showme all the points it plots are correct but when using the strategy it only show about 80% of the trades that it should do. Is there something wrong?

One final thing (I think ) How do I change to script so it won't sell anything when there is 1 hour till closing and then start again the next morning? (To prevent holding trades when the market has closed)

Blu-Ray - I have to hand it to you and everyone else that has been helping me. I appreciated it so much. You don't understand the stress it was causing me that no one could help me. Then I found this forum

Cheers,
Darknite.
With regards to it only taking 80% of the trades as per the show me, I would guess the next bar did not take out the low of the signal bar, as this strategy only sends the sellshort order on the very next bar.

Here's the revised code with an endtime added as an input:

Inputs:
ProfTarget(30),StopLoss(1 ),endtime(1900);

Vars:
ShortEntry(0), Permission(0), Mintick(0), mystop(0), MP(0);

MP = marketposition;
Mintick = minmove/pricescale;

Condition1 = C[1] data2 >C[2] data2 and H data2 > H [1]data2 and H data2 > H[2] data2 and C data2 < O data2;

if condition1 and MP = 0 and time < endtime then begin
ShortEntry = Low - (1*mintick);
mystop = High + (Stoploss*mintick);
permission = 1;
end;

if permission = 1 then begin
SellShort next bar at ShortEntry Stop;
Permission = 0;
end;

if mp = -1 then begin
buytocover ("ProfitTarget") next bar at ShortEntry - (ProfTarget*mintick) limit;
buytocover ("StoppedOut") next bar at mystop stop;
end;


Also add either of these two lines to the end of the code....

This one will close your position if you've got an open position and it's after the endtime. Note: It will close the position whether it's in profit or loss.

if mp = -1 and time > endtime then buytocover next bar at market;

Or the second one will set the exit on the close of the session, again whether it's in profit or loss. ( But note this should only be used on historical simulations, as depending on the instrument it can lead to your exit being taken on the open of the next day)

if mp = -1 and time > endtime then setexitonclose;


Hope this helps

Blu-Ray

__________________
Remember - Take the path of least resistance.
Reply With Quote