Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi Everyone, I am pretty new to EasyLanguage and I am currently trying to test my first strategy. It is a mean-reverting strategy based on a keltner channel, basically entering short at the top of the channel and long at the bottom.
However to avoid hitting multiple stops in a row when there is a trend, I'd like to be able to only enter longs if my last trade was a short and was stopped out. This way I can only have one stop in a row when going long or short and then can only enter the opposite side.
The way I tried to do it is to have 2 variables, one for when I am long and the stop is hit and one when I am short and the stop is hit. However, I can't seem to find a way to make it work as I always have multiple stops in a row.
If anyone has ideas or a solution I'd be happy to hear your thoughts.
If NoStopLong = True and Price crosses above LowerBand Then Begin
Buy ("Long") Cts contracts next bar at market ;
NoStopShort = True;
end;
If NoStopShort = True and Price crosses below UpperBand Then Begin
SellShort ("Short") Cts contracts next bar at market ;
NoStopLong = True ;
end;
// StopLoss
If ( MarketPosition = 1 ) Then begin
If Price <= (entryprice - Stoploss1) Then NoStopLong = False ;
If ( CurrentContracts = Cts) then sell ("Long_stoploss1") cts contracts next bar at (entryprice - Stoploss1) stop;
If ( CurrentContracts = Cts) and Price crosses above Avg then sell ("tgtB") cts contracts next bar at market ;
end;
If ( MarketPosition = -1 ) Then begin
If Price >= (entryprice + Stoploss1) then NoStopShort = False ;
If ( CurrentContracts = Cts) then buytocover ("short_stoploss1") cts contracts next bar at (entryprice + Stoploss1) stop;
If ( CurrentContracts = Cts) and Price crosses under Avg then buytocover ("tgtS") cts contracts next bar at market ;
end;
Can you help answer these questions from other members on NexusFi?
I would suggest using the print reserved word for checking the values of your two variables. This way you can see if the are correctly set and should prevent another entry.
If you want to make sure that the exit actually was triggered using a StrategyHost object comes to mind as this way you can obtain the names of the orders that were triggered.
However, this will require using Object Oriented EasyLanguage.
What you use in your print statement is up to you - anything that you think would be helpful.
From looking at your print statement you appear to print variable and reserved word names only, but not the value of those, though.
Something along the lines of the below might give you a good start: